<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atomfull.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="0.3" xml:lang="en">
	<title>magnetiq.com</title>
	<link rel="alternate" type="text/html" href="http://magnetiq.com" />
	<tagline>Ates Goral's Personal Playground and Project Repository</tagline>
	<modified>2008-06-25T04:36:58Z</modified>
	<copyright>Copyright 2008</copyright>
	<generator url="http://wordpress.org/" version="2.0.2">WordPress</generator>
			<link rel="start" href="http://feeds.feedburner.com/magnetiq_atom" type="application/atom+xml" /><entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Adobe (Photoshop) Color Book Specification in HTML Format]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/314889221/" />
		<id>http://magnetiq.com/2008/06/18/adobe-photoshop-color-book-specification-in-html-format/</id>
		<modified>2008-06-18T20:30:26Z</modified>
		<issued>2008-06-18T20:30:26Z</issued>
		
	<dc:subject>Projects</dc:subject>
	<dc:subject>Photoshop</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[I finally sat down and created a friendlier, HTML version of the <a href="/2006/04/18/the-unofficial-photoshop-color-book-file-format-specification/">Unofficial Adobe Color Book Specification</a> by updating the original post. This obsoletes the <a href="/docs/PhotoshopColorBook.txt">80-column plain-text version</a> that I wrote up in 2003.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2008/06/18/adobe-photoshop-color-book-specification-in-html-format/"><![CDATA[<p>I finally sat down and created a friendlier, HTML version of the <a href="/2006/04/18/the-unofficial-photoshop-color-book-file-format-specification/">Unofficial Adobe Color Book Specification</a> by updating the original post. This obsoletes the <a href="/docs/PhotoshopColorBook.txt">80-column plain-text version</a> that I wrote up in 2003.
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2008/06/18/adobe-photoshop-color-book-specification-in-html-format/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[A Boulder Dash Clone in Only 20 Lines of JavaScript]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/314768845/" />
		<id>http://magnetiq.com/2008/06/18/a-boulder-dash-clone-in-only-20-lines-of-javascript/</id>
		<modified>2008-06-18T16:59:35Z</modified>
		<issued>2008-06-18T16:59:35Z</issued>
		
	<dc:subject>JavaScript</dc:subject>
	<dc:subject>DHTML</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[This was my very first entry for the quasi-regular, friendly <a href="http://ozoneasylum.com/29836">20-line JavaScript competition</a> over at <a href="http://ozoneasylum.com/">OZONE Asylum</a>, for the month of January 2008.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2008/06/18/a-boulder-dash-clone-in-only-20-lines-of-javascript/"><![CDATA[<p>This was my very first entry for the quasi-regular, friendly <a href="http://ozoneasylum.com/29836">20-line JavaScript competition</a> over at <a href="http://ozoneasylum.com/">OZONE Asylum</a>, for the month of January 2008. My entry titled &#8220;<a href="/bd20">Rockford the Invincible</a>&#8221; got the second place among some very impressive entries (I was actually a bit shocked that I got the second place).</p>
<div class="center">
<p><a href="/bd20"><img src="/wpmain/wp-content/uploads/2008/06/bd20_ss.png" alt="Rockford the Invincible"/></a></p>
<p><small>In-game screenshot. Click to play!</small>
</div>
<p><a id="more-70"></a></p>
<p>The winning entries were:</p>
<ol>
<li><a href="http://www.kaarellumi.com/asylum/html/dyn8_2.htm">Candle Flame</a> by Arthurio</li>
<li><a href="/bd20">Rockford the Invincible</a> by me</li>
<li><a href="http://www.p01.org/releases/DHTML_contests/files/20lines_castle_wolfenstein/">Castle Wolfenstein</a> by <a href="http://www.p01.org/">Mathieu &#8220;p01&#8243; Henri</a></li>
</ol>
<p>And here&#8217;s the explanation of how I managed to get placed above p01&#8217;s entry. Quoting Wrayal, that month&#8217;s topic setter and therefore judge:</p>
<blockquote><p>[On Castle Wolfenstein] Ok&#8230;maybe this one needs a little justification. A lot of people may have expected this to win. It was a fantastic script, don&#8217;t get me wrong! (&#8221;stop it! You are doing impossible things! What if reality find out?!&#8221; ;)) In particular, I thought the map showed exactly the sort of flair that would normally win. But we know you&#8217;re capable of this ;) you&#8217;ve set yourself too high a standard :P What can I say, it was a great script, but I&#8217;d be interested to see what else could be implemented - I liked the rockford entry for example for the many simultaneous actions.</p></blockquote>
<p>For those unfamiliar with the title, <a href="http://en.wikipedia.org/wiki/Boulder_Dash">Boulder Dash</a> is a classic game from the 80&#8217;s. I used to play it a lot on my Atari 800XL when I was a kid. Since being hooked on programming, writing Boulder Dash clones (or derivatives) has become a habitual thing that I do when I get my hands on a new programming language. A friend (who incidentally is the author of <a href="https://bouldercat.dev.java.net/">BoulderCat</a>) recently joked about this habit being my version of &#8220;<a href="http://en.wikipedia.org/wiki/Hello_world">Hello, world!</a>&#8220;.</p>
<p>Since I had to fit everything in 20 effective lines of JavaScript, this of course is not a complete implementation of Boulder Dash. For instance, Rockford, the main character, never dies. You can freely move around the monsters and stop falling boulders with your head. I&#8217;ve therefore called the game &#8220;Rockford the Invincible&#8221;. Just &#8220;Boulder Dash&#8221; would have been too obvious.</p>
<p>Here&#8217;s the JavaScript code behind the curtains. Note that some lines have comments with line numbers in them. Those are the <em>effective</em> lines of JavaScript, as (somewhat loosely) dictated by the line-counting rules of the contest.</p>
<pre name="code" class="js:nocontrols:nogutter">
            function move(src, dest) {
/*01*/          g.cells[dest].className = g.cells[src].className;
/*02*/          g.cells[src].className = "e";
/*03*/          return (g.cells[dest].ser = g.ser) != g.ser;
            }

/*04*/      window.onload = function() {
/*05*/          g = {
                    w: 15,
                    h: 15,
                    ser: 0,
                    rules: {
                        od: function() {
/*06*/                      [[0, g.w, g.w], [g.w, (v = [-1, 1][g.ci]), g.w + v], [g.w, -v, g.w - v]].every(function(vs) {
/*07*/                          return ("wod".indexOf(g.cells[i + vs[0]].className) &gt; -1 &#038;&#038; g.cells[g.d = i + vs[1]].className == "e" &#038;&#038; g.cells[i + vs[2]].className == "e") ? move(i, g.d) : true;
                            });
                        },
                        trbluvcm: function(o) {
/*08*/                      ([(m = (o &gt;&gt; 1) - 1), 0].every(function(dv) {
/*09*/                          return (g.cells[g.d = i + [-g.w, 1, g.w, -1][nv = (g.ci + dv) &#038; 3]].className == "e") ? move(i, g.d, g.cells[i].className = g.k.charAt(nv + o)) : true;
                            })) ? g.cells[i].className = g.k.charAt(((g.ci - m) &#038; 3) + o) : false;
                        },
                        qfkj: function() {
/*10*/                      ("esd".indexOf(g.cells[g.d = i + (nv = [[0, 0], [-g.w, 1], [1, 2], [g.w, 1], [-1, 3]][g.mouse ? (Math.abs(g.dx = (g.mouse.x &gt;&gt; 4) - (i % g.w)) &gt; Math.abs(g.dy = (g.mouse.y &gt;&gt; 4) - Math.floor(i / g.w)) ? (g.dx &gt; 0 ? 2 : 4) : (g.dy &gt; 0 ? 3 : (g.dy &lt; 0 ? 1 : 0))) : 0])[0]].className) &gt; -1) ? move(i, g.d, g.cells[i].className = g.k.charAt(nv[1])) : g.cells[i].className = g.k.charAt(0);
                        }
                    },
                    cells: document.getElementsByTagName("td"),
                    maze: document.getElementById("maze")
                };

/*11*/          document.getElementById("cap").onmousedown = function(event) {
/*12*/              g.mouse = {
                        x: (g.evt = window.event || event).layerX || g.evt.x,
                        y: g.evt.layerY || g.evt.y
                    };
                };

/*13*/          setInterval(function() {
/*14*/              g.maze.className = "f_" + (++g.ser &#038; 7);

/*15*/              for (i = 0; i &lt; g.h * g.w; i++) {
/*16*/                  for (g.k in g.rules) {
/*17*/                      (g.cells[i].ser != g.ser) ? ((g.ci = g.k.indexOf(g.cells[i].className)) &gt; -1 ? g.rules[g.k](g.ci &#038; 4) : false) : false;
                        }
                    }
                }, 100);
            }

/*18*/      Array.prototype.every = Array.prototype.every || function(callback, that) {
/*19*/          for (var i = 0; i &lt; this.length &#038;&#038; callback.call(that || this, this[i]); i++);
/*20*/          return i == this.length;
            }
</pre>
<p>&nbsp;
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2008/06/18/a-boulder-dash-clone-in-only-20-lines-of-javascript/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Generating &#8220;Unified Diff&#8221; Files with ClearCase]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/153528976/" />
		<id>http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/</id>
		<modified>2007-09-07T16:19:11Z</modified>
		<issued>2007-09-07T16:19:11Z</issued>
		
	<dc:subject>Source Control</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[In my company, we recently migrated from <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</a> to <a href="http://en.wikipedia.org/wiki/Clearcase">ClearCase</a>. We were a bit thrown off by the fact that ClearCase doesn't readily provide <a href="http://en.wikipedia.org/wiki/Diff">diff</a> files that span multiple files. We have all been used to reviewing CVS diff files which do so. People here had to come up with their own scripts to remedy this issue.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/"><![CDATA[<p>In my company, we recently migrated from <a href="http://en.wikipedia.org/wiki/Concurrent_Versions_System">CVS</a> to <a href="http://en.wikipedia.org/wiki/Clearcase">ClearCase</a>. We were a bit thrown off by the fact that ClearCase doesn&#8217;t readily provide <a href="http://en.wikipedia.org/wiki/Diff">diff</a> files that span multiple files. We have all been used to reviewing CVS diff files which do so. People here had to come up with their own scripts to remedy this issue. <a id="more-39"></a>Here&#8217;s what I&#8217;ve been using so far:</p>
<pre>cleartool lsco -cvi -r -s | xargs -n1 cleartool diff -pred -ser |
    egrep -v "^(Files|Directories) are identical"</pre>
<p>This Unix shell command will generate the diff output (which you can redirect to a file) recursively (<em>-r</em>) for all files that are checked out within the current directory, on the current view (<em>-cvi</em>). </p>
<p>The output is not exactly a unified diff file (I believe that it can&#8217;t be directly used with the <a href="http://en.wikipedia.org/wiki/Patch_%28Unix%29">patch</a> command) but it still is a human-readable diff that spans multiple files.</p>
<p>The reason that I use <em>-serial_format</em> (<em>-ser</em>) and not <em>-diff_format</em> is that <em>-diff_format</em> suppresses the file headers and obviously a &#8220;unified diff&#8221; file doesn&#8217;t make sense when you don&#8217;t know where each individual file starts and ends.
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2007/09/07/generating-unified-diff-files-with-clearcase/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[ACB2XML 2.0b - Export Adobe Color Book Data as XML]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/115234539/" />
		<id>http://magnetiq.com/2007/05/08/acb2xml/</id>
		<modified>2007-05-09T03:51:17Z</modified>
		<issued>2007-05-09T03:51:17Z</issued>
		
	<dc:subject>Freeware</dc:subject>
	<dc:subject>Photoshop</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[Here's a freeware tool that I had written back in 2003, shortly after reverse-engineering the <a href="/2006/04/18/the-unofficial-photoshop-color-book-file-format-specification/">Adobe Color Book Format</a>. This command-line Windows application extracts color data from color book files and generates XML.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2007/05/08/acb2xml/"><![CDATA[<p>Here&#8217;s a freeware tool that I had written back in 2003, shortly after reverse-engineering the <a href="/2006/04/18/the-unofficial-photoshop-color-book-file-format-specification/">Adobe Color Book Format</a>. This command-line Windows application extracts color data from color book files and generates XML. Once the color data is safely in XML domain, the rest is up to your imagination&#8230;</p>
<div class="download">Download <a href="/downloads/acb2xml20.zip">acb2xml20.zip</a> (30 KB)</div>
<p><a id="more-36"></a></p>
<p>If you don&#8217;t already know what color books are, there&#8217;s the <em>Custom Colors</em> dialog which appears when you click the <em>Custom</em> button on the <em>Color Picker</em> dialog. There, you can pick colors from a variety of color books which represent standard color catalogs by organizations like <a href="http://pantone.com/">Pantone</a>, <a href="http://toyocolor.com/">Toyo</a>, <a href="http://trumatch.com/">Trumatch</a>, etc. The color book data is kept in files under the <em>Presets/Color Books</em> folder of your Photoshop installation. On Windows, they have the <em>.acb</em> extension.</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/custom_colors.jpg" width="400" height="279" alt="Custom Colors Dialog"/></p>
<p><small>Custom Colors Dialog</small>
</div>
<p>To extract data, just pass in the filename of a color book. The resulting XML will go to standard output. To capture to a file, just redirect the output:</p>
<pre>acb2xml focoltone.acb &gt; focoltone.xml</pre>
<p>For long filenames or filenames with spaces, quote the filenames:</p>
<pre>acb2xml "PANTONE process coated.acb" > "PANTONE process coated.xml"</pre>
<p>The resulting output will look something like this:</p>
<pre name="code" class="xml:nocontrols:nogutter">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;color-book version=&quot;1.0&quot; xmlns=&quot;http://magnetiq.com/ns/2007/05/colorbook&quot;&gt;
    &lt;version&gt;1&lt;/version&gt;
    &lt;id&gt;0bb9&lt;/id&gt;
    &lt;title&gt;&lt;![CDATA[$$$/colorbook/FOCOLTONE/title=FOCOLTONE]]&gt;&lt;/title&gt;
    &lt;prefix&gt;&lt;![CDATA[$$$/colorbook/FOCOLTONE/prefix=FOCOLTONE ]]&gt;&lt;/prefix&gt;
    &lt;postfix&gt;&lt;![CDATA[$$$/colorbook/FOCOLTONE/postfix=]]&gt;&lt;/postfix&gt;
    &lt;description&gt;&lt;![CDATA[$$$/colorbook/FOCOLTONE/description=]]&gt;&lt;/description&gt;
    &lt;colors&gt;860&lt;/colors&gt;
    &lt;page-size&gt;5&lt;/page-size&gt;
    &lt;page-offset&gt;2&lt;/page-offset&gt;
    &lt;color-space&gt;CMYK&lt;/color-space&gt;
    &lt;color&gt;
        &lt;name&gt;1070&lt;/name&gt;
        &lt;alias&gt;&lt;![CDATA[1070  ]]&gt;&lt;/alias&gt;
        &lt;cyan&gt;100&lt;/cyan&gt;
        &lt;magenta&gt;0&lt;/magenta&gt;
        &lt;yellow&gt;0&lt;/yellow&gt;
        &lt;black&gt;0&lt;/black&gt;
    &lt;/color&gt;
    &lt;color&gt;
        &lt;name&gt;1071&lt;/name&gt;
        &lt;alias&gt;&lt;![CDATA[1071  ]]&gt;&lt;/alias&gt;
        &lt;cyan&gt;0&lt;/cyan&gt;
        &lt;magenta&gt;100&lt;/magenta&gt;
        &lt;yellow&gt;0&lt;/yellow&gt;
        &lt;black&gt;0&lt;/black&gt;
    &lt;/color&gt;
    ...
</pre>
<p>ACB2XML currently supports <a href="http://en.wikipedia.org/wiki/Cmyk">CMYK</a>, <a href="http://en.wikipedia.org/wiki/Rgb">RGB</a> and <a href="http://en.wikipedia.org/wiki/Lab_color_space">Lab</a> color spaces.</p>
<h3>Known Issues</h3>
<ul>
<li>Some textual information is enclosed in CDATA blocks, instead of doing proper XML escaping. While this has no harm whatsoever, I may fix it in the future.</li>
</ul>
<h3>Legalese</h3>
<p><em>Adobe&reg; and Photoshop&reg; are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States and/or other countries.</em>
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2007/05/08/acb2xml/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Burrito 1.0b - FTP to POP3 Protocol Translator]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/114698050/" />
		<id>http://magnetiq.com/2007/05/07/burito-10b-ftp-to-pop3-protocol-translator/</id>
		<modified>2007-05-07T05:04:19Z</modified>
		<issued>2007-05-07T05:04:19Z</issued>
		
	<dc:subject>Freeware</dc:subject>
	<dc:subject>Experiments</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[With Burrito you can read and manage your e-mails with any FTP client! It acts as a POP3/FTP protocol translator -- it's actually an FTP server that translates FTP commands to POP3 commands and serves your e-mail messages as individual files. You can view, delete and copy your e-mail messages as if they were files on an FTP server.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2007/05/07/burito-10b-ftp-to-pop3-protocol-translator/"><![CDATA[<p>With Burrito you can read and manage your e-mails with any FTP client! It acts as a POP3/FTP protocol translator &#8212; it&#8217;s actually an FTP server that translates FTP commands to POP3 commands and serves your e-mail messages as individual files. You can view, delete and copy your e-mail messages as if they were files on an FTP server.</p>
<div class="download">Download <a href="/downloads/burrito10b.exe">burrito10b.exe</a> (479 KB)</div>
<p><a id="more-14"></a></p>
<p>This is a programming experiment that dates back to 2002. Having played around with POP3 for a while (see <a href="/2006/07/10/e-res-q-13/">E-Res-Q</a>), I just wanted to prove to myself that POP3/FTP protocol translation could work (and I guess I also had more free time back then). Burrito is certainly not a utility that would appeal to the general public, due to its obscure function. The only real-life scenario I can think of is an employee trying to circumvent the company firewall that blocks POP3 traffic (which is something I&#8217;ve experienced first-hand).</p>
<h3>Very Brief Usage Instructions</h3>
<p>The <em>About</em> tab has an <em>Check for update</em> button which takes you back to this site to tell you that you&#8217;re using the most recent version of Burrito (since I currently don&#8217;t have any intentions of releasing updates).</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2007/05/idle.jpg" width="400" height="313" alt="About Tab"/></p>
<p><small>About Tab</small>
</div>
<p>In the <em>Options</em> tab, you can determine how you&#8217;ll be passing the POP3 username and server to your FTP server. The password that you use for the FTP connection is used as the POP3 server password, so Burrito doesn&#8217;t have to know your password in advance. However, the POP3 username and password must be combined and used as the FTP username. You can change the username-server separator here (defaults to &#8220;\&#8221;).</p>
<p>You can also configure how filenames for individual messages are to be composed. The default is to use the name of the sender, followed by a dash, followed by the message subject. The default file extension is &#8220;.eml&#8221;. After copying files to your local disk, you should be able to simply double click to view them in Outlook Express. Use &#8220;.msg&#8221; etc. to match whatever e-mail client you&#8217;re actually using.</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2007/05/options.jpg" width="400" height="313" alt="Options Tab"/></p>
<p><small>Options Tab</small>
</div>
<p>By default, Burrito listens on port 21, on all IP addresses. The <em>Security</em> tab allows you to tweak the FTP server listen settings.</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2007/05/security.jpg" width="400" height="313" alt="Security Tab"/></p>
<p><small>Security Tab</small>
</div>
<p>Here&#8217;s how a typical FTP client configuration looks like (I use <a href="http://ghisler.com" target="_blank">Total Commander</a>):</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2007/05/ftpsettings.jpg" width="373" height="403" alt="FTP Client Settings"/></p>
<p><small>FTP Client Settings</small>
</div>
<p>And here&#8217;s how your e-mail messages appear as files in your FTP client:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2007/05/ftpaction.jpg" width="400" height="300" alt="FTP Client in Action"/></p>
<p><small>FTP Client in Action</small>
</div>
<p>For every FTP connection you establish with Burrito, it will typically open a POP3 connection to the server that specified in the FTP username. It has a connection sharing feature for when multiple FTP clients access the same POP3 account.</p>
<p>Because Burrito doesn&#8217;t download entire messages until you attempt to do an FTP-copy, simply listing and deleting messages are typically faster than a normal POP3 client. Therefore, it can actually be used for cleaning up a POP3 account after it gets choked by a huge messages or spam.</p>
<p>Cool? I guess so. Pointless? Probably :)</p>
<h3>Known Issues</h3>
<ul>
<li>After the system wakes up from hibernation/suspension, the FTP listen port becomes unresponsive. Momentarily chaning the <em>FTP server listen mode</em> in the <em>Security</em> tab to some other mode may (depending on the mode change) reset the listen port.</li>
</ul>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2007/05/07/burito-10b-ftp-to-pop3-protocol-translator/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Verifying the Integrity of an Easynews Download without a Checksum File]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/87426720/" />
		<id>http://magnetiq.com/2007/02/06/verifying-the-integrity-of-an-easynews-download-without-a-checksum-file/</id>
		<modified>2007-02-07T00:20:29Z</modified>
		<issued>2007-02-07T00:20:29Z</issued>
		
	<dc:subject>Internet</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[Suppose you had to download a huge file from <a href="http://easynews.com/">Easynews</a> as a single piece because a multiple archive version wasn't available. Here's a method I came up with for verifying the integrity of an ISO image file that didn't come with a checksum.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2007/02/06/verifying-the-integrity-of-an-easynews-download-without-a-checksum-file/"><![CDATA[<p>Suppose you had to download a huge file from <a href="http://easynews.com/">Easynews</a> as a single piece because a multiple archive version wasn&#8217;t available. If the poster didn&#8217;t supply a checksum file (<a href="http://en.wikipedia.org/wiki/Md5">MD5</a>, <a href="http://en.wikipedia.org/wiki/SFV">SFV</a>) or <a href="http://en.wikipedia.org/wiki/Parchive">Parchive files</a>, you can&#8217;t readily tell if the file you&#8217;ve downloaded is intact. Here&#8217;s a method I came up with for verifying the integrity of an ISO image file that didn&#8217;t come with a checksum. I didn&#8217;t want to burn the ISO image without knowing that the file was intact, to avoid an interrupted or corrupt installation. <a id="more-29"></a></p>
<p>Take a look at the URL of a typical Easynews download:</p>
<pre class="code">
http://downloads.members.easynews.com/news/7/a/3 *snip*
/7a38dcc18a67ac805cff5abc5ef36d12011d39e6b.iso/foo.ISO
</pre>
<p>The file is inside a folder whose name contains a bunch of hexadecimal digits. Let&#8217;s break down the digits as follows:</p>
<pre class="code">
7a38dcc18a67ac805cff5abc5ef36d12
0
11d39e6b
</pre>
<p>I discovered that the first block of 32 characters (7a38dcc18a67ac805cff5abc5ef36d12) is the MD5 checksum for the file, and the last block of 8 characters (11d39e6b) is the CRC32 checksum. The zero in between probably has no significance.</p>
<p>Comparing either of these to the checksum you get for the downloaded copy should give you enough confidence that your download is intact. For getting the MD5 checksum, you could use Microsoft&#8217;s <a href="http://support.microsoft.com/kb/841290">File Checksum Integrity Verifier utility</a> on Windows:</p>
<pre class="code">
fciv -a "foo.ISO" -md5
//
// File Checksum Integrity Verifier version 2.05.
//
7a38dcc18a67ac805cff5abc5ef36d12 foo.iso
</pre>
<p>If this matches what&#8217;s in the folder name, it is safe to assume that your download is intact. Alternatively, you can use a SFV utility to compare the CRC32 checksums. The number following the filename in the SFV file below is the CRC32 checksum for that file:</p>
<pre class="code">
; Generated by WIN-SFV32 v1.0
; (Compatible: Total Commander 6.51)
foo.ISO 11D39E6B
</pre>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2007/02/06/verifying-the-integrity-of-an-easynews-download-without-a-checksum-file/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Default Constructor vs. Empty Constructor]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/62676522/" />
		<id>http://magnetiq.com/2006/12/16/default-constructor-vs-empty-constructor/</id>
		<modified>2006-12-17T04:50:59Z</modified>
		<issued>2006-12-17T04:50:59Z</issued>
		
	<dc:subject>C++</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[A while ago, I had wondered if there would be any difference at compile time between having an empty constructor and having no constructor at all (and thus using the default constructor). I did a quick investigation by writing a simple test application and looking at the disassembly. It turned out that there is actually a difference (in a <strong>debug</strong> build).]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2006/12/16/default-constructor-vs-empty-constructor/"><![CDATA[<p>While coding away new classes for your C++ project, do you have the habit of just dropping in a contructor definition, just in case you may in the future need to do some initialization at construction? A while ago, I had wondered if there would be any difference at compile time between having an empty constructor and having no constructor at all (and thus using the default constructor). I did a quick investigation by writing a simple test application and looking at the disassembly. It turned out that there is actually a difference (in a <strong>debug</strong> build). <a id="more-28"></a></p>
<p>I defined a class called &#8220;MyClass&#8221; which has a single integer member variable (of no significance to this test). The main function defines an array of 42 MyClass objects and then does some dummy arithmetic, just as a landmark for the assembly code following the initialization (if any) of the MyClass array.</p>
<p>I&#8217;ve interlaced the C++ code with the corresponding assembly code as comments so that you can see what&#8217;s happening behind the scenes for each line of C++ code. I believe the compiler I used was MS VC.</p>
<p>First, let&#8217;s see what happens when using the default constructor (not defining our own):</p>
<pre name="code" class="cpp:nocontrols:nogutter">
class MyClass {
private:
    int m_i;
};

int main(int argc, char* argv[]) {
    /*
    00401000  push        ebp
    00401001  mov         ebp,esp

    Allocate space in stack for our local variables;
        42 (array length) * 4 (size of MyClass) = 168
        2 (local variables x and y) * 4 (size of int) = 8
        --
        176 = 0xB0 (total)

    00401003  sub         esp,0B0h
    */
    MyClass a[42];
    int x = 2;
    /*
    00401009  mov         dword ptr [x],2 (Assign 2 to x)
    */
    int y = x * 2;
    /*
    00401010  mov         eax,dword ptr [x] (Get x)
    00401013  shl         eax,1 (Multiply by 2)
    00401015  mov         dword ptr [y],eax (Assign to y)
    */

    return 0;
    /*
    00401018  xor         eax,eax (Set return value to zero)
    */
}
</pre>
<p>You can see that there&#8217;s absolutely no compiled code associated with our array definition, apart from the single line of code for making room in the stack.</p>
<p>Let&#8217;s compare that to what happens when using an empty constructor:</p>
<pre name="code" class="cpp:nocontrols:nogutter">
class MyClass {
public:
    MyClass() {;}

private:
    int m_i;
};

int main(int argc, char* argv[]) {
    /*
    00401000  push        ebp
    00401001  mov         ebp,esp 

    Allocate space in stack for our local variables;
        42 (array length) * 4 (size of MyClass) = 168
        2 (local variables x and y) * 4 (size of int) = 8
        3 (internal loop variables)  * 4 (size of int) = 12
        --
        188 = 0xBC (total)</span>

    00401003  sub         esp,0BCh
    */
    MyClass a[42];
    /*
    00401009  mov         dword ptr [ebp-0B4h],2Ah (Loop 42 times)
    00401013  mov         dword ptr [ebp-0B8h],4
    0040101D  lea         eax,[a]
    00401023  mov         dword ptr [ebp-0BCh],eax 

    Execute the following code in the loop:

    00401029  mov         ecx,dword ptr [ebp-0B4h]
    0040102F  sub         ecx,1
    00401032  mov         dword ptr [ebp-0B4h],ecx
    00401038  cmp         dword ptr [ebp-0B4h],0
    0040103F  jl          main+55h (401055h)
    00401041  mov         edx,dword ptr [ebp-0BCh]
    00401047  add         edx,dword ptr [ebp-0B8h]
    0040104D  mov         dword ptr [ebp-0BCh],edx
    00401053  jmp         main+29h (401029h)
    */
    int x = 2;
    /*
    00401055  mov         dword ptr [x],2
    */
    int y = x * 2;
    /*
    0040105C  mov         eax,dword ptr [x]
    0040105F  shl         eax,1
    00401061  mov         dword ptr [y],eax
    */

    return 0;
    /*
    00401064  xor         eax,eax
    */
}
</pre>
<p>Whoops! There&#8217;s suddenly a big chunk of code introduced. If you look at what that piece of code is doing, it&#8217;s looping 42 times, but not doing anything apart from the overhead of the loop itself. This could potentially become significant if our array had hundreds of thousands of items instead of just a mere 42. Of course, this was what I observed with a MS VC debug build and other compilers may have different results, with different compiler optimization settings.
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2006/12/16/default-constructor-vs-empty-constructor/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Rendering N-sided Polygons with DHTML]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/54856281/" />
		<id>http://magnetiq.com/2006/11/28/rendering-n-sided-polygons-with-dhtml/</id>
		<modified>2006-11-28T05:16:29Z</modified>
		<issued>2006-11-28T05:16:29Z</issued>
		
	<dc:subject>Experiments</dc:subject>
	<dc:subject>JavaScript</dc:subject>
	<dc:subject>DHTML</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[With this technique, convex polygons with any number of sides can be rendered, with a solid color or a background image as the fill.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2006/11/28/rendering-n-sided-polygons-with-dhtml/"><![CDATA[<p><script src="/wpmain/wp-content/scripts/poly_popup.js"></script><br />
With this technique, convex polygons with any number of sides can be rendered, with a solid color or a background image as the fill. Click <a href="#" onclick="return popup()">here</a> or the image below to launch the demo (opens in a pop-up window).</p>
<div class="center">
<p><a href="#" onclick="return popup()"><img src="/wpmain/wp-content/uploads/2008/06/poly_ss.png" width="400" height="267" alt="DHTML Polygon Rendering Demo"/></a></p>
</div>
<p>You can probably figure it out on your own by playing with the checkboxes at the lower left corner of the pop-up, but read on to find out how it all works.<a id="more-26"></a></p>
<p>The demo renders only regular polygons, but any convex, irregular, closed area can be rendered.</p>
<p>We start with a list of vertices:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_vertices.png" width="376" height="380" alt="Vertices" class="bordered"/></p>
<p><small>The five vertices of a regular pentagon at an arbitrary orientation</small>
</div>
<p>Then we find the bounding rectangle (minimum and maximum x and y coordinates) of the vertices and apply the fill &lt;div&gt; with either a solid color or a background image:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_fill.png" width="376" height="380" alt="Fill" class="bordered"/></p>
<p><small>The bounding rectangle is used as the fill</small>
</div>
<p>Now the fill rectangle has to be masked to leave behind our filled polygon. Notice that each side of a polygon can be fitted with a right angle triangle:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_masks.png" width="376" height="380" alt="Masks" class="bordered"/></p>
<p><small>The right angle triangles and rectangles that act as masks</small>
</div>
<p>For vertices that lie on the bounding (or fill) rectangle, the right angle triangles will be flush with the sides of the bounding rectangle (I, II and III above). For vertices that fall inside the bounding rectangle, the right angle triangles (IV and V) will leave behind rectangles (VI). The number of rectangles depends on the number of sides of the polygon and also its orientation.</p>
<p>What we want to do now is to place triangles and rectangles over the numbered areas so that only the actual polygon will remain visible. For rectangular masks, absolutely positioned &lt;div&gt; elements (with the background color) will do the trick, but for triangles we&#8217;ll have to think about the rectangles that bound them:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_triangles.png" width="376" height="380" alt="Triangle masks" class="bordered"/></p>
<p><small>Bounding rectangles for triangular masks</small>
</div>
<p>Since we can&#8217;t have an infinite supply of right angle triangle images at all sorts of slants, we can simply resize isosceles right angle triangles to get any angle variations we want. We will need at least four different triangles, with their right angles at each corner. The filled parts of the triangles should be of the background color and the rest should be transparent:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_nw.png" width="75" height="75" class="bordered"/><img src="/wpmain/wp-content/uploads/2008/06/poly_ne.png" width="75" height="75" class="bordered"/><img src="/wpmain/wp-content/uploads/2008/06/poly_se.png" width="75" height="75" class="bordered"/><img src="/wpmain/wp-content/uploads/2008/06/poly_sw.png" width="75" height="75" class="bordered"/></p>
<p><small>Triangular masks for the NW, NE, SE and SW corners, respectively</small>
</div>
<p>Since these triangles will be resized, it&#8217;s important to make them sufficiently large to minimize aliasing. The images used in the demo are 600 x 600 in dimensions. Once the remaining areas are masked with the triangular masks, all we&#8217;re left with is our polygon:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/poly_final.png" width="376" height="380" alt="The polygon" class="bordered"/></p>
<p><small>Voilà!</small>
</div>
<p>The edges may look jagged a bit, but when the polygon is animated, it&#8217;s barely noticeable.</p>
<p>Concave areas can be filled if the angles don&#8217;t cause overlapping of the masks. I&#8217;ve played around with drawing n-spoked stars instead of convex polygons, but couldn&#8217;t perfect the method to entirely avoid overlaps. The technique can also be used for rendering circles, since as the side count grows, polygons eventually start to look like circles.
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2006/11/28/rendering-n-sided-polygons-with-dhtml/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[browsersize.com]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/51226140/" />
		<id>http://magnetiq.com/2006/11/18/browsersizecom/</id>
		<modified>2006-11-19T04:04:31Z</modified>
		<issued>2006-11-19T04:04:31Z</issued>
		
	<dc:subject>Projects</dc:subject>
	<dc:subject>Web Design</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[A simple website that I had put together a while ago, that harbors two simple tools that web designers may find useful. The <a href="http://browsersize.com/">main site</a> shows you decently current statistics on different screen resolutions that web surfers have nowadays. You could use that as a starting point for deciding on the dimensions for a non-fluid website layout.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2006/11/18/browsersizecom/"><![CDATA[<p>A simple website that I had put together a while ago, that harbors two simple tools that web designers may find useful. The <a href="http://browsersize.com/">main site</a> shows you decently current statistics on different screen resolutions that web surfers have nowadays. You could use that as a starting point for deciding on the dimensions for a non-fluid website layout.</p>
<div class="center">
<p><a href="http://browsersize.com/"><img src="/wpmain/wp-content/uploads/2008/06/browsersize.png" width="300" height="100" alt="browsersize.com"/></a></p>
</div>
<p><a href="http://setmy.browsersize.com/">setmy.browsersize.com</a> allows you to set your browser size to any desktop resolution without the need for extra add-ons/extensions. This is useful for seeing how users with different desktop resolutions will be viewing your website. <a href="http://whatsmy.browsersize.com/">whatsmy.browsersize.com</a> tells you your current desktop resolution and browser size along with all the installed popular plug-ins (with links to download sites for missing ones).
</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2006/11/18/browsersizecom/</feedburner:origLink></entry>
		<entry>
	  	<author>
			<name>Ates Goral</name>
		</author>
		<title type="text/html" mode="escaped"><![CDATA[Using Fewer Images]]></title>
		<link rel="alternate" type="text/html" href="http://feeds.feedburner.com/~r/magnetiq_atom/~3/48052187/" />
		<id>http://magnetiq.com/2006/08/27/using-less-images/</id>
		<modified>2006-08-27T05:23:00Z</modified>
		<issued>2006-08-27T05:23:00Z</issued>
		
	<dc:subject>Web Design</dc:subject>
	<dc:subject>CSS</dc:subject> 
		<summary type="text/plain" mode="escaped"><![CDATA[Image rollovers are usually composed of two individual images; one for the default state and one for when the mouse is hovered over the image or link. However, it bears some advantages to use a single image by taking advantage of CSS background image offsets.]]></summary>
		<content type="text/html" mode="escaped" xml:base="http://magnetiq.com/2006/08/27/using-less-images/"><![CDATA[<link rel="stylesheet" href="/wpmain/wp-content/uploads/2008/06/using_fewer_images.css" type="text/css"/>
<p>Image rollovers are usually composed of two individual images; one for the default state and one for when the mouse is hovered over the image or link. However, it bears some advantages to use a single image by taking advantage of CSS background image offsets. <a id="more-20"></a>Here&#8217;s how a rollover for an anchor is usually done:</p>
<p>The HTML code could look like something like this:</p>
<pre name="code" class="html:nocontrols:nogutter">
&lt;a href="#" id="yaprak"&gt;&amp;nbsp;&lt;/a&gt;
</pre>
<p>The associated CSS would then have items like:</p>
<pre name="code" class="css:nocontrols:nogutter">
a#yaprak {
    width: 64px;
    height: 64px;
    background-image: url(yaprak_bw.png);
    display: block;
    text-decoration: none;
}

a#yaprak:hover {
    background-image: url(yaprak_color.png);
}
</pre>
<p>Two individual images for the two states would have to be uploaded to the server and they would look like this:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/yaprak_bw.png" width="64" height="64" class="bordered" title="yaprak_bw.png"/><img src="/wpmain/wp-content/uploads/2008/06/yaprak_color.png" width="64" height="64" class="bordered" title="yaprak_color.png"/></p>
</div>
<p>Finally, the end result would be:</p>
<p><a href="#" id="yaprak_single" onclick="return false">&nbsp;</a>
<p>The default image that is visible to the user is the black &amp; white yaprak_bw.png and when you hover over the image, it&#8217;s replaced by yaprak_color.png with its full-color glory. However, if this is a user&#8217;s initial visit to the website and therefore the color image hasn&#8217;t already been cached, there may be a user-perceivable delay in switching to the color image. The net annoyance will depend on factors like the user&#8217;s connection speed, the load on the web server and most importantly, the attentiveness of the user. A couple of methods can be applied to pre-load alternate images to avoid the perceived latency but I will advocate for something else: don&#8217;t use separate alternate images in the first place. You can use a single image where the two rollover images are flush with eachother, side by side or one on top of another. Here&#8217;s how:</p>
<p>The HTML code is the same. The CSS this time has:</p>
<pre name="code" class="css:nocontrols:nogutter">
a#yaprak {
    width: 64px;
    height: 64px;
    background-image: url(yaprak_bw_color.png);
    display: block;
    text-decoration: none;
}

a#yaprak:hover {
    background-position: 64px 0;
}
</pre>
<p>There&#8217;s only a single image:</p>
<div class="center">
<p><img src="/wpmain/wp-content/uploads/2008/06/yaprak_bw_color.png" width="128 height="64" class="bordered" title="yaprak_bw_color.png"/></p>
</div>
<p>The end result is:</p>
<div class="center">
<p><a href="#" id="yaprak" onclick="return false">&nbsp;</a></p>
</div>
<p>Using fewer images might marginally speed up the load times for your website while also decreasing the load on your web server. Another scant advantage is that you&#8217;d have less images to worry about maintaining and uploading to your web server.</p>
]]></content>
	<feedburner:origLink>http://magnetiq.com/2006/08/27/using-less-images/</feedburner:origLink></entry>
	</feed>
