<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Geekchef.com &#187; Coding</title>
	<atom:link href="http://geekchef.com/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://geekchef.com</link>
	<description></description>
	<lastBuildDate>Sat, 09 Jul 2011 18:12:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Doom in Javascript (I&#8217;m jealous)</title>
		<link>http://geekchef.com/doom-in-javascript-im-jealous/</link>
		<comments>http://geekchef.com/doom-in-javascript-im-jealous/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 12:50:19 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Doom]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=251</guid>
		<description><![CDATA[Yes, someone ported Doom to javascript.  I must say I&#8217;m pretty jealous of that since I still haven&#8217;t had time to get a real grasp of the original code yet (and I got busy with ioquake3). Three cheers for this excellent hack. &#160; Edit:  The code to this program is now long gone. My guess ]]></description>
			<content:encoded><![CDATA[<p>Yes, someone ported <a title="Doom on Javascript" href="https://developer.mozilla.org/en-US/demos/detail/doom-on-the-web/" target="_blank">Doom to javascript</a>.  I must say I&#8217;m pretty jealous of that since I still haven&#8217;t had time to get a real grasp of the original code yet (and I got busy with <a title="ioquake3" href="http://ioquake3.org/" target="_blank">ioquake3</a>).</p>
<p>Three cheers for this excellent hack.</p>
<p>&nbsp;</p>
<p>Edit:  The code to this program is now long gone. My guess is it&#8217;s because the author embedded the graphics into the code which are not part of the GPL licence.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/doom-in-javascript-im-jealous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Japanese words for Ubuntu</title>
		<link>http://geekchef.com/random-japanese-words-for-ubuntu/</link>
		<comments>http://geekchef.com/random-japanese-words-for-ubuntu/#comments</comments>
		<pubDate>Wed, 04 May 2011 13:04:44 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Japanese]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=222</guid>
		<description><![CDATA[So I spend a lot of time in front of a computer.  This makes it a little harder to find time for vocabulary practice. I&#8217;m not so big on expensive devices that creates a list of Japanese words or kanji &#8211; I&#8217;m sure there&#8217;s an &#8220;app for that&#8221; &#8211; but this little trick I found ]]></description>
			<content:encoded><![CDATA[<p><a rel="lightbox" href="http://geekchef.com/wp-content/uploads/2011/05/konnichiha.png"><img class="alignright size-full wp-image-231" title="konnichiha-t" src="http://geekchef.com/wp-content/uploads/2011/05/konnichiha-t.png" alt="" width="100" height="53" /></a>So I spend a lot of time in front of a computer.  This makes it a little harder to find time for vocabulary practice.</p>
<p>I&#8217;m not so big on expensive devices that creates a list of Japanese words or kanji &#8211; I&#8217;m sure there&#8217;s an &#8220;app for that&#8221; &#8211; but this little trick I found is free, you can set all the parameters you want, and runs on Ubuntu (and probably some other Linux distro).</p>
<p>Open a console and type:</p>
<pre>notify-send こんにちは</pre>
<p>This nifty little program pops-up a notification bubble, just like the ones were are used to see for other purposes on Ubuntu. I then create a script that randomly selects a word or expression from a database then set a cron job that runs the script every minute or so.</p>
<p>However, you need to tweak it if you send your message from cron.  From a console, notify-send just uses your default X environment variables to display on your desktop but cron doesn&#8217;t know that and it won&#8217;t display anything. So you need to add your current X display before your script call.</p>
<pre>DISPLAY=:0.0 notify-send こんにちは</pre>
<p>Feel free to customize your script to your liking and make sure you read the man page to notify-send for more parameters (length of display, box title, etc.).</p>
<p>Happy hacking.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/random-japanese-words-for-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino: a board and a philosophy</title>
		<link>http://geekchef.com/arduino-a-board-and-a-philosophy/</link>
		<comments>http://geekchef.com/arduino-a-board-and-a-philosophy/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 03:24:22 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=172</guid>
		<description><![CDATA[I&#8217;ve been working at my new job for over a year and what&#8217;s really different from all my previous jobs is the close relation that I have now with hardware.  Of course, programmers use computers, which is primarily &#8220;hardware&#8221; but most of the hardware I use now is built on the spot.  And meeting all ]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working at my new job for over a year and what&#8217;s really different from all my previous jobs is the close relation that I  have now with hardware.  Of course, programmers use computers, which is primarily &#8220;hardware&#8221; but most of the hardware I use now is built on the spot.  And meeting all the tech guys that actually handle the hardware (both on the building and programming sides) is really interesting: I can peek into one&#8217;s microscope to see the boards up close, ask them questions about things that I never learned in programming classes, about compilers, peripherals and all sorts of hacks &#8230;  This got me a little more interested in building my own small electonic projects but I didn&#8217;t know where to start.</p>
<p>So one of my colleagues directed me to a fine website called <a title="Hack a Day" href="http://hackaday.com" target="_blank">Hack a Day</a>, which, according to him, is a good start for an amateur like me.  They have all sorts of posts for beginners to look into, especially <a title="Dev Board Breakdown" href="http://hackaday.com/2011/02/01/what-development-board-to-use/" target="_blank">a great article on various development boards to choose from</a>.  I heard a lot about the <a title="Arduino official site" href="http://arduino.cc" target="_blank">Arduino</a> board, which claims to be &#8220;open-source&#8221;.  I got curious and read a little about it.  The site also featured <a title="Arduino: The documentary." href="http://arduinothedocumentary.org/" target="_blank">this wonderful documentary</a> on the Arduino: Yes!  Open-source hardware exists and it&#8217;s something that falls right into the kind of things I&#8217;m interested in.  This documentary didn&#8217;t just give me some bits of information, it explained to me a philosophy; something, I believe, should always be a part of the art of programming.</p>
<p>Now I haven&#8217;t really used one yet, mind you.  But this got me really interested on getting one very soon.</p>
<p>You can check out the documentary below (and use full screen) or check out <a title="Arduino: The documentary." href="http://arduinothedocumentary.org/" target="_blank">http://arduinothedocumentary.org</a> for other viewing / downloading options.</p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="440" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="quality" value="high" /><param name="cachebusting" value="true" /><param name="bgcolor" value="#000000" /><param name="movie" value="http://www.archive.org/flow/flowplayer.commercial-3.2.1.swf" /><param name="flashvars" value="config={'key':'#$aa4baff94a9bdcafce8','playlist':['format=Thumbnail?.jpg',{'autoPlay':false,'url':'Arduino.The.Documentary.2010.English_512kb.mp4'}],'clip':{'autoPlay':true,'baseUrl':'http://www.archive.org/download/Arduino.TheDocumentary.English/','scaling':'fit','provider':'h264streaming'},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'plugins':{'controls':{'playlist':false,'fullscreen':true,'height':26,'backgroundColor':'#000000','autoHide':{'fullscreenOnly':true}},'h264streaming':{'url':'http://www.archive.org/flow/flowplayer.pseudostreaming-3.2.1.swf'}},'contextMenu':[{},'-','Flowplayer v3.2.1']}" /><embed type="application/x-shockwave-flash" width="400" height="225" src="http://www.archive.org/flow/flowplayer.commercial-3.2.1.swf" allowfullscreen="true" allowscriptaccess="always" cachebusting="true" bgcolor="#000000" quality="high" flashvars="config={'key':'#$aa4baff94a9bdcafce8','playlist':['format=Thumbnail?.jpg',{'autoPlay':false,'url':'Arduino.The.Documentary.2010.English_512kb.mp4'}],'clip':{'autoPlay':true,'baseUrl':'http://www.archive.org/download/Arduino.TheDocumentary.English/','scaling':'fit','provider':'h264streaming'},'canvas':{'backgroundColor':'#000000','backgroundGradient':'none'},'plugins':{'controls':{'playlist':false,'fullscreen':true,'height':26,'backgroundColor':'#000000','autoHide':{'fullscreenOnly':true}},'h264streaming':{'url':'http://www.archive.org/flow/flowplayer.pseudostreaming-3.2.1.swf'}},'contextMenu':[{},'-','Flowplayer v3.2.1']}"></embed></object></p>
<p>Happy hacking.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/arduino-a-board-and-a-philosophy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>QR Fun</title>
		<link>http://geekchef.com/qr-fun/</link>
		<comments>http://geekchef.com/qr-fun/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 19:27:59 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[QR]]></category>
		<category><![CDATA[xkcd]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=127</guid>
		<description><![CDATA[I was reading about QR codes lately.  They fascinate me somehow; just like mazes and fractals, they have this esoterical yet recognizable form, but unlike them, they can be much, much more: they store content. Finding QR encoders is easy enough (PhpQrCode works very well).  Since the specs are open (although a thorough explanation of ]]></description>
			<content:encoded><![CDATA[<p><a title="Guess what the content of this image is about ..." rel="lightbox" href="http://geekchef.com/wp-content/uploads/2011/01/site-big.png"><img class="size-full wp-image-128 alignright" title="Guess ..." src="http://geekchef.com/wp-content/uploads/2011/01/qr_site.png" alt="" width="116" height="116" /></a>I was reading about <a title="Wikipedia: QR Code" href="http://en.wikipedia.org/wiki/QR_Code" target="_blank">QR codes</a> lately.  They fascinate me somehow; just like mazes and fractals, they have this esoterical yet recognizable form, but unlike them, they can be much, much more: they store <em>content</em>. Finding QR encoders is easy enough (<a title="PHPQRCode" href="http://sourceforge.net/projects/phpqrcode/" target="_blank">PhpQrCode</a> works very well).  Since the specs are open (although a thorough explanation of the math behind it goes beyond my comprehension), I guess its easy to implement.  The real problem must be in the <em>decoding </em>procedure.  Since QR codes were meant to be decoded in warehouses using hand-held scanners, physical hurdles like dirt and image quality must be a nightmare to handle.  I found this library called <a title="ZXing" href="http://code.google.com/p/zxing/" target="_blank">ZXing</a> that gives an impressive array of features.  Written essentially for handhelds, there&#8217;s also a C++ port.  Once compiled, the default application does the job of reading QR codes in all image formats.</p>
<p>Now the real fun begins:  In the <a title="XKCD store: book" href="http://store.xkcd.com/xkcd/#xkcdvolume0" target="_blank">xkcd book</a> (volume 0), there are 5 QR codes located on the left side of page 100012 (you did notice that it uses a base 3 paging count, did you ?).  I scanned the page and ran it each QR code through the ZXing.  The results ?  Well, let&#8217;s just say that Randall is a fan of  Mario Cart on the <em>Wii</em> and he&#8217;s being the nice guy he always seems to be. <img src='http://geekchef.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>My next test was really interesting: I have an ash grey T-Shirt with a QR code on the back in crimson color, measuring 3 x 3 inches.  You can guess this was going to be a little more challenging.  Since I don&#8217;t have a handheld device, I merely used the camera on my iPod nano to film it and extracted each frame with MPlayer on my PC.  The first films I took were short with awful results, so I decided to take a longer film, zooming in and out, and tilting the camera to minimize the skewing and warping of the images.  This time, I got 106 hits out of 1066 frames, a 10% hit rate which is very good considering that I was randomly moving my camera.  No doubt with a real handheld, I would have gotten more precise hits.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/qr-fun/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Announcing libkanji v1.0</title>
		<link>http://geekchef.com/announcing-libkanji-v1-0/</link>
		<comments>http://geekchef.com/announcing-libkanji-v1-0/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 23:04:30 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Japanese]]></category>
		<category><![CDATA[libkanji]]></category>
		<category><![CDATA[kanji]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=87</guid>
		<description><![CDATA[It&#8217;s finally out. This is libkanji, my C library for Japanese kanji storage and retrieval. Although heavier on the storage side for now, the library essentially parses the KANJIDIC2 project&#8216;s XML file into a MySQL or PostgreSQL database. You can then build software on top of it to manipulate the data for customizing your kanji ]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s finally out.  This is libkanji, my C library for Japanese kanji storage and retrieval.  Although heavier on the storage side for now, the library essentially parses the <a href="http://www.csse.monash.edu.au/~jwb/kanjidic2/" target="_blank">KANJIDIC2 project</a>&#8216;s XML file into a MySQL or PostgreSQL database.  You can then build software on top of it to manipulate the data for customizing your kanji learning.</p>
<p>Still a lot of work to do (of course) but I&#8217;m happy with the results.</p>
<p>Get the tar.gz at <a href="https://sourceforge.net/projects/libkanji/" target="_blank">Sourceforge.net</a>.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/announcing-libkanji-v1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using 24 bit uncompressed TARGA files</title>
		<link>http://geekchef.com/using-targa-files/</link>
		<comments>http://geekchef.com/using-targa-files/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 14:56:27 +0000</pubDate>
		<dc:creator>narc</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[formats]]></category>
		<category><![CDATA[TGA]]></category>

		<guid isPermaLink="false">http://geekchef.com/?p=11</guid>
		<description><![CDATA[Every time I have a coding rage, I always end up needing some sort of image buffer I can blit directly into and saving it to a file. My favorite file format is the good ol&#8217; TARGA file format, better known as the file with the *.tga extension. You can find this format in games, ]]></description>
			<content:encoded><![CDATA[<p>Every time I have a coding rage, I always end up needing some sort of image buffer I can blit directly into and saving it to a file.  My favorite file format is the good ol&#8217; TARGA file format, better known as the file with the *.tga extension.  You can find this format in games, namely Quake 3 for saving screenshots.</p>
<p>I&#8217;m not going to give a detailed view of the TARGA specs.  I just want to use the lossless, true-color (24 bit colors) storing option the format provides.</p>
<p>TARGA&#8217;s are easy to implement but are little tricky: easy because they simply have an 18 byte header and the rest that follows are mere groups of 3 bytes representing each of the 24 bit pixels.  But there are also options regarding color palettes and compression, and that&#8217;s always tricky.</p>
<p>Let me just rapidly point, for my own needs, the most important parts of the specs:</p>
<p>In my latest implementation, this is the TGA header I created in C/C++:</p>
<pre>
   wh = width >> 8;
   hh = height >> 8;

   char header[18] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
      width - (wh << 8), wh,
      height - (hh << 8), hh,
      24, 0x20
   };
</pre>
<p>I first set the third byte to 2, indicating that I want a true-color, uncompressed image.</p>
<p>I then need to encode 2 byte values representing the width and height of the image. Those dimensions are stored in little endian format, which means that the lower part of the number comes first, then the higher part.</p>
<p>Since numbers are stored on 8 bit values, I isolate the higher part of the width and height like so:</p>
<pre>
   wh = width >> 8;
   hh = height >> 8;
</pre>
<p>It's then easy to get the lower part by shifting back 8 bits and substracting those values from the original dimensions.</p>
<pre>
   width - ( wh << 8 ), height - ( hh << 8 )
</pre>
<p>The 17th element is the bit per pixel (bpp) and I want the 24 bit version.</p>
<p>Finally, the final 18th element is more complicated as information about alpha depth is stored here.  I'm not using alpha at this point so I can ignore this.</p>
<p>But there is also something about a "direction" and that cannot be ignored.  In fact, lost into these 8 remaining bits is a special feature that determine whether the image is stored with the first line on top (which we all assume as normal) or with the first line at the bottom! The original format wrote the images upside-down.  Setting this value to 0, my image will be mirorred upside-down but still aligned to the left. Lighting up that bit at the 6th position of this field sets it right (hence the hexadecimal value 0x20).</p>
<p>All of this can be verified with the Gimp - our favorite graphics package : when first saving a TARGA file, it will ask whether you want RLE compression uncheck this) and where you want the origin to start (select Top left).</p>
<p>One final note concerns the encoding of the 24 bit pixels themselves.  While we are all used to the red-green-blue (RGB) encoding order, TARGAs uses blue-green-red (BGR).  So don't forget to swap, or else weird things will show up in your program.</p>
<p>Happy hacking.</p>
]]></content:encoded>
			<wfw:commentRss>http://geekchef.com/using-targa-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

