<?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>Mindstab.net &#187; Coding Archives  &#8211; Mindstab.net</title>
	<atom:link href="http://www.mindstab.net/tag/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mindstab.net</link>
	<description>Various projects and musings</description>
	<lastBuildDate>Tue, 27 Mar 2012 16:53:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Finding &#8220;lost&#8221; computers on the web the homebrew way</title>
		<link>http://www.mindstab.net/finding-lost-computers-web/</link>
		<comments>http://www.mindstab.net/finding-lost-computers-web/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 06:39:55 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=1043</guid>
		<description><![CDATA[During the course of updating my home computer I rebooted it because of a kernel update. Later that week at work I went to connect to my home computer and discovered that it&#8217;s dynamic IP had changed and it&#8217;s DNS name was invalid. So following common advice to &#8220;fix a problem two ways to prevent [...]]]></description>
			<content:encoded><![CDATA[<p>During the course of updating my home computer I rebooted it because of a kernel update.  Later that week at work I went to connect to my home computer and discovered that it&#8217;s dynamic IP had changed and it&#8217;s DNS name was invalid.</p>
<p>So following common advice to &#8220;fix a problem two ways to prevent it in the future&#8221; I fixed the DNS, but I also wanted an automated way to track my computers when and if their IPs changed.</p>
<p>So the first thing I needed was shared place to store the IP information.  Thinking about it I realized that Dropbox would work well for that.  So all I needed was a simple script.</p>
<p>So the solution was to put a script that determined the IP of the computer in Dropbox and have cron on all the computers run it.  Each user can call cron with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ crontab <span style="color: #660033;">-e</span></pre></div></div>

<p>And I created a crontab directory that I could add more scripts to later if need be with and run them hourly with the following entry</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>dan <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">run-parts</span> Dropbox<span style="color: #000000; font-weight: bold;">/</span>cron</pre></div></div>

<p>The script itself was a file called <i>getip</i> and it used whatsmyip.com&#8217;s automation detection script.</p>
<p><strong>getip</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh </span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span>.ip http:<span style="color: #000000; font-weight: bold;">//</span>automation.whatismyip.com<span style="color: #000000; font-weight: bold;">/</span>n09230945.asp
<span style="color: #007800;">tmp_file</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span>.ip
<span style="color: #007800;">dst_file</span>=Dropbox<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">hostname</span><span style="color: #000000; font-weight: bold;">`</span>.ip
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #c20cb9; font-weight: bold;">diff</span> <span style="color: #660033;">-q</span> <span style="color: #800000;">${tmp_file}</span> <span style="color: #800000;">${dst_file}</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null  ; <span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #800000;">${tmp_file}</span>  <span style="color: #800000;">${dst_file}</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p>Then I just created <i>Dropbox/var/log</i> and installed the crontab on all my computers, and volia, homebrew IP tracking for all my compters accessible to me from anywhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/finding-lost-computers-web/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Graduated but never done with school</title>
		<link>http://www.mindstab.net/graduated-school/</link>
		<comments>http://www.mindstab.net/graduated-school/#comments</comments>
		<pubDate>Sat, 07 Jan 2012 08:03:32 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[School]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=1035</guid>
		<description><![CDATA[So starting around October last year Stanford started the first few of its free online geared classes. I successful took and completed and passed the Artificial Intelligence class and the Machine Learning class. That, coupled with full time work, pretty much left me with no time for anything else. I was crazy busy for that [...]]]></description>
			<content:encoded><![CDATA[<p>So starting around October last year Stanford started the first few of its free online geared classes.  I successful took and completed and passed the <a href="http://ai-class.org">Artificial Intelligence class</a> and the <a href="http://ml-class.org">Machine Learning class</a>.  That, coupled with full time work, pretty much left me with no time for anything else.  I was crazy busy for that 10 weeks but I learned a bunch and it was fun.  Over the winter break, even though I&#8217;ve been busy, I&#8217;ve more or less recovered, and just in time, because in a few weeks a whole new batch of free online classes will be kicking off.  I&#8217;m going to see if it&#8217;ll be feasible for me to do 3 this time, but I might have to settle for 2.  So If I vanish against for another 10 weeks, that&#8217;ll be why. </p>
<p>This stuff is amazing and a lot of it simply isn&#8217;t available at the university I went to, so to have it now for free is a pretty big opportunity so I&#8217;m eager to cram in as much as I can before it goes for pay (it has the feel of a beta/demo that will go that way once material is built up and kinks worked out).  </p>
<p>So cheers! and see you again in the spring!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/graduated-school/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first kernel patch</title>
		<link>http://www.mindstab.net/kernel-patch/</link>
		<comments>http://www.mindstab.net/kernel-patch/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 06:47:13 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=1029</guid>
		<description><![CDATA[About 3 weeks ago Lennart Poettering posted A Plumber&#8217;s Wish List for Linux to his blog, which is one of the many Linux related blogs I read. Included on that list was a request to &#8220;expose CAP_LAST_CAP somehow in the running kernel at runtime&#8221;. Now I&#8217;d never contributed to the Linux kernel before, but in [...]]]></description>
			<content:encoded><![CDATA[<p>About 3 weeks ago Lennart Poettering posted <a href="http://0pointer.de/blog/projects/plumbers-wishlist.html">A Plumber&#8217;s Wish List for Linux</a> to his blog, which is one of the many Linux related blogs I read.  Included on that list was a request to &#8220;expose CAP_LAST_CAP somehow in the running kernel at runtime&#8221;.  </p>
<p>Now I&#8217;d never contributed to the Linux kernel before, but in college we had hacked on the Minix kernel to extend it and in University we had written our own kernel and implemented virtual memory, task switching, message passing and preemptive processes; so I was at least familiar and comfortable with kernel level development.  Looking at this task, I immediately thought, &#8220;hey, that is totally within my capabilities and I can probably squeeze it into my schedule&#8221;.</p>
<p>So I did.  I checked out the latest copy of the torvalds Linux repository and implemented the feature.  The actual implementation didn&#8217;t take too long. Mostly looking for the right place.  What did take a day or two was getting up to speed on Linux coding practices and patch submission protocol and procedure. They have a good process in place and it&#8217;s best not to step on toes so I did my research as best I could.  When I was ready I sent in my patch.</p>
<p>Andrew Morton picked it up, asked for a few enhancements, and those submitted, added it to his -mm tree for testing.  Then a few weeks later Linux 3.1 launched and the new merge window opened and today Andrew submitted his diff from the -mm branch including my patch to Linus and it was merged to his tree!</p>
<p><a href="http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=73efc0394e148d0e15583e13712637831f926720">http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=73efc0394e148d0e15583e13712637831f926720</a></p>
<p>I am now a Linux kernel contributor. I have a small piece of code in the Linux kernel that will ship with 3.2. It&#8217;s not huge, but I did it, and that gives me a real sense of pleasure and accomplishment.  Thanks to all who helped!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/kernel-patch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What have I been up to (summer 2011)</title>
		<link>http://www.mindstab.net/summer-2011/</link>
		<comments>http://www.mindstab.net/summer-2011/#comments</comments>
		<pubDate>Sun, 09 Oct 2011 03:58:51 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[School]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=1018</guid>
		<description><![CDATA[Well, aside from being pretty busy with work, I spent some more time playing with OpenGL and Lisp. I took my demo test of a spinning diamond up to the beginnings of a space flight sim. Now we have a ship that has a thruster that applies forward thrust, there is the beginnings of physics. [...]]]></description>
			<content:encoded><![CDATA[<p>Well, aside from being pretty busy with work, I spent some more time playing with OpenGL and Lisp.  I took my demo test of a spinning diamond up to the beginnings of a space flight sim.  Now we have a ship that has a thruster that applies forward thrust, there is the beginnings of physics.  The next logical step would be to add turning, but I wanted to do it with physics, which meant writing torque code and that&#8217;s about where I got side tracked and have stopped for the moment. Not super interesting yet, but not bad for someone who has never done 3D programming before.  The code is at <a href="https://github.com/dballard/flight-sim">https://github.com/dballard/flight-sim</a>.</p>
<p><center><br />
<iframe width="420" height="315" src="http://www.youtube.com/embed/8Y6zutbYWvg?rel=0" frameborder="0" allowfullscreen></iframe><br />
<a href="http://www.youtube.com/watch?v=8Y6zutbYWvg">View on YouTube</a><br />
<small><i>Video recorded with <a href="http://recordmydesktop.sourceforge.net/about.php">Record My Desktop</a></i></small><br />
</center></p>
<p>I then got distracted by the idea of a checkers AI by a few articles I read in August.  I decided to dust off my Ruby and give that a go but it didn&#8217;t get too far before I realized that I was going to have to get side tracked from search in to aggressive pruning and heuristics.  I was satisfied with the project even though it doesn&#8217;t really play because at it renewed me Ruby which had been shelved since some time last year and reminded me that search of this kind is bloody hard.  The code is at <a href="https://github.com/dballard/checkers">https://github.com/dballard/checkers</a>.  It can simulate a full game to any depth if you have the time.  If you have less than days or years per turn, it&#8217;s pretty much no good.</p>
<p>Now I&#8217;m getting further distracted by a few ideas in different directions yet again and I&#8217;m starting the Stanford <a href="http://ai-class.com">AI class</a> and <a href="http://ml-class.com">Machine Learning class</a> that they are offering online for free on monday.  That should keep me pretty much tied up until years end and I&#8217;m looking forward to it all!</p>
<p>Also thanks to my <a href="http://www.kobobooks.com/touch">Kobo Touch  eReader</a> I&#8217;ve been reading a ton, which is nice. I may have to give up my pace of a book every week or two for the next month or two to keep up with the new classes, we shall see.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/summer-2011/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>links for 2011-07-13</title>
		<link>http://www.mindstab.net/links-for-2011-07-13/</link>
		<comments>http://www.mindstab.net/links-for-2011-07-13/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 08:00:50 +0000</pubDate>
		<dc:creator>delicious</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Lisp]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/links-for-2011-07-13/</guid>
		<description><![CDATA[Zach&#039;s Journal &#8211; Making a small Lisp project with quickproject and Quicklisp Zach outlines how to start projects using quicklisp and quickproject (tags: lisp quicklisp project depends)]]></description>
			<content:encoded><![CDATA[<ul class="delicious">
<li>
<div class="delicious-link"><a href="http://xach.livejournal.com/278047.html?thread=674335">Zach&#039;s Journal &#8211; Making a small Lisp project with quickproject and Quicklisp</a></div>
<div class="delicious-extended">Zach outlines how to start projects using quicklisp and quickproject</div>
<div class="delicious-tags">(tags: <a href="http://www.delicious.com/mindstab/lisp">lisp</a> <a href="http://www.delicious.com/mindstab/quicklisp">quicklisp</a> <a href="http://www.delicious.com/mindstab/project">project</a> <a href="http://www.delicious.com/mindstab/depends">depends</a>)</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/links-for-2011-07-13/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release of Fink (my old Go AI bot)</title>
		<link>http://www.mindstab.net/release-fink-ai-bot/</link>
		<comments>http://www.mindstab.net/release-fink-ai-bot/#comments</comments>
		<pubDate>Sat, 09 Jul 2011 16:15:49 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Go]]></category>
		<category><![CDATA[Lisp]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=989</guid>
		<description><![CDATA[I woke up today to a message from a physics PhD student in the US asking about my old Lisp Go AI bot code (from the Mindstab Go AI competition of 2008) and if I was ever planning on releasing it or if he could get a look at it since Go and programming were [...]]]></description>
			<content:encoded><![CDATA[<p>I woke up today to a message from a physics PhD student in the US asking about my old Lisp Go AI bot code (from the Mindstab Go AI competition of 2008) and if I was ever planning on releasing it or if he could get a look at it since Go and programming were two of his hobbies.</p>
<p>&#8220;fink&#8221;, as my Go AI bot was called, was my frist real Lisp project, and in hindsight probably not that good, but I learned a lot from it and it was fun, which is all that really matters.  Possibly it&#8217;s most notable feature now is that it&#8217;s a Lisp program that speaks GTP and may provide a base for someone to write a better bot with.  So if someone else can learn something from it or use it, that would be pretty cool.  So here it is</p>
<p><a href="https://github.com/dballard/fink">https://github.com/dballard/fink</a></p>
<p>There&#8217;s some notes about it in it&#8217;s README.  I don&#8217;t recall if I documented it much but hopefully it can be made sense of :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/release-fink-ai-bot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spare time projects: OpenGL and Lisp</title>
		<link>http://www.mindstab.net/spare-time-projects-opengl-lisp/</link>
		<comments>http://www.mindstab.net/spare-time-projects-opengl-lisp/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 05:08:29 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=982</guid>
		<description><![CDATA[So as you may know I&#8217;m trying to keep up with programming exploratory side projects in my spare time, somewhat spurred on by among many things, The Cult of Done. After learning a bit about HTML5 and Canvas and writing the The Game of Life for Canvas I wanted to move on to something more [...]]]></description>
			<content:encoded><![CDATA[<p>So as you may know I&#8217;m trying to keep up with programming exploratory side projects in my spare time, somewhat spurred on by among many things, <a href="http://www.brepettis.com/blog/2009/3/3/the-cult-of-done-manifesto.html">The Cult of Done</a>.  After learning a bit about HTML5 and Canvas and writing the <a href="http://www.mindstab.net/life">The Game of Life for Canvas</a> I wanted to move on to something more meaty.  That&#8217;s about as far as I&#8217;d ever gone in graphics programming so I wanted to keep pushing on in that vein for a bit.  So I figured why not check out 3D land.  I briefly looked at WebGL but it&#8217;s not entirely ready just yet.  Some of the tech demos look decent but for one thing, there&#8217;s almost no interactivity in the more complicated ones like flight sims, I assume because a good IO system isn&#8217;t in place, so I figured why not go for straight up OpenGL.</p>
<p>The defacto language for OpenGL programming is C/C++ however I&#8217;ve done my share of C programming and I&#8217;m enjoying higher level languages for many things these days.  I have an ok relationship with Python but it doesn&#8217;t get me excited or anything, and I&#8217;m still working at getting better at Lisp which I am fond of so I thought why not use this as another excuess to work in Lisp?  And so against some people&#8217;s advice I&#8217;ve been exploring OpenGL programmign in Lisp.</p>
<p>I Googled around and found that the basic package is cl-opengl and using Quicklisp got that installed and found a very basic tutorial for getting a window to show with a tutorial at <a href="http://nklein.com/2010/06/nehe-tutorials-for-cl-opengl/">nklein.com from NeHe</a>.  It worked okish but not really.  Then I found <a href="http://3bb.cc/tutorials/cl-opengl/">3bb.cc&#8217;s cl-opengl tutorials</a> which were better.  They used SDL instead of GLUT to make a window and the first one worked and I had a raindow triangle.  Instead of going on, I started looking at the opengl.com tutorial&#8217;s in C and tried translating them.  I worked through the cube.c one, but it didn&#8217;t quite work, so after a bit I gave up.</p>
<p>I went back to the 3bb code and instead of continuing on with the tutorials, I just started working on it myself and googling for parts I needed and getting some help from a friend who&#8217;d done some heavier OpenGL programming in C.  I made the color change over time (like I learned for the game of life).  Then I made the triangle spin.  Then I added a second back triangle and made them spin.  Then I fleshed it out and made  pyramid, then a diamond that spun.  Then I finally made the spinning color changing diamond that also moved in a circle, refactoring the code a few times in the process.  </p>
<p>Now I have a nice simple tech demo and some code and understandings of the basics of OpenGL and 3D programming.  For about 8 days work in spare time I am very pleased.  I have more plans to move on to from here, but I&#8217;ll probably start a new project for it.  The code for all my demos is on github at <a href="https://github.com/dballard/cl-opengl-tests">https://github.com/dballard/cl-opengl-tests</a>.  The only one that really works is 3bb.lisp and you need cl-opengl and lispbuilder-SDL.  </p>
<p>Something I discovered is that the linear algebra scene for Lisp is confusing and a mess (IMHO).  There are a bunch of projects for it, all kind of a mess with no apparent blessed/defacto standard  library.  I looked at L-math, but the version in quicklisp seemed a bit broken :/.  This whole Lisp philosophy of always using the latest dev code instead of stable releases seems&#8230; against better sense. And seemed to fail me here. I looked at Femlisp/matlisp but their own FAQ talked about how their linear algebra implementation was slow and that&#8217;s all I wanted it for.  So in the end I just rolled my own.  It was fun and I had to remember some basic math from a few years ago.</p>
<p>Here&#8217;s the final product:</p>
<p><center><iframe width="425" height="349" src="http://www.youtube.com/embed/Pb8dpMMnPl8?hl=en&#038;fs=1" frameborder="0" allowfullscreen></iframe><br />
<a href="http://www.youtube.com/watch?v=Pb8dpMMnPl8">View on YouTube</a></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/spare-time-projects-opengl-lisp/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Drupal + Google Search Appliance + Multiple languages and collections</title>
		<link>http://www.mindstab.net/drupal-google-search-appliance-multiple-languages-collections/</link>
		<comments>http://www.mindstab.net/drupal-google-search-appliance-multiple-languages-collections/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 04:29:10 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=977</guid>
		<description><![CDATA[So at work we use Drupal a lot. And one of our clients has a Google Search Appliance (mini google in a box installed in their datacenter for their personal use) and runs sites that operate in multiple languages. So we installed the Drupal GSA module, flicked it on, and had Google searches. Of course [...]]]></description>
			<content:encoded><![CDATA[<p>So at work we use Drupal a lot.  And one of our clients has a Google Search Appliance (mini google in a box installed in their datacenter for their personal use) and runs sites that operate in multiple languages.  So we installed the Drupal GSA module, flicked it on, and had Google searches.  Of course since we had multiple languages, we set up GSA collections, one collection for each language.  Easy enough.  But by default the Drupal GSA module only takes one collection in it&#8217;s admin page.  So we did what we always do in this situation, we made the collection a <i>multilingual</i> variable, a kind of Drupal hack that enables that variable to have different values transparently depending on the site&#8217;s language.  Then we input each GSA collection into each language/site&#8217;s GSA config.  Done and good to go?  Nope.  All the searches were still in English for all the sites.  So on the French site we cleared the cache and then the searches were in French! &#8230; for all the sites. The Drupal GSA module was deeply not designed to work with multiple languages/collections it turned out.  </p>
<p>After about 2 hours debugging we figured it all out.  When the module is initialized, it pulls out all the config data, puts it in a hash, and hands it off to Drupal in the menu hook. Drupal stores it forever, and hands it off to the search function whenever it is called and so what ever language is active when the module is initialized determines what colleciton is used forever for all languages. Not cunning.  The fix however was straight forward and one line: in the search function, just disregard the passed in settings value for the collection and re-pull it.</p>
<p>For what it&#8217;s worth I filed a bug and patch (against 6.x-2.0-beta1, though it should work fine for all versions) with the module at <a href="http://drupal.org/node/1208892">http://drupal.org/node/1208892</a> but it seems it&#8217;s suffering from low maintainership.</p>
<p>Here it is as well, though it&#8217;s probably just as easy to copy/paste the line in directly.</p>

<div class="wp_syntax"><div class="code"><pre class="diff" style="font-family:monospace;">Index: google_appliance.module
===================================================================
<span style="color: #888822;">--- google_appliance.module	<span style="">&#40;</span>revision 14982<span style="">&#41;</span></span>
<span style="color: #888822;">+++ google_appliance.module	<span style="">&#40;</span>working copy<span style="">&#41;</span></span>
<span style="color: #440088;">@@ -1055,6 +1055,9 @@</span>
  *   Themed search results.
  */
 function google_appliance_search_view<span style="">&#40;</span>$search_base, $client, $collection, $keys = NULL, $title = NULL<span style="">&#41;</span> <span style="">&#123;</span>
<span style="color: #00b000;">+  </span>
<span style="color: #00b000;">+  $collection =  trim<span style="">&#40;</span>variable_get<span style="">&#40;</span>'google_appliance_default_collection', 'default_collection'<span style="">&#41;</span><span style="">&#41;</span>;</span>
<span style="color: #00b000;">+  </span>
   $form = drupal_get_form<span style="">&#40;</span>'google_appliance_search_form', NULL, $search_base, $client, $collection, $keys<span style="">&#41;</span>;
   // When POSTing back to an existing search-results page, the original
   // URL is accessed <span style="">&#40;</span>which re-runs that search<span style="">&#41;</span> and then the redirect for</pre></div></div>

<p>Now it works just fine and all our different language sites have searches and results in just their language. Splendid!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/drupal-google-search-appliance-multiple-languages-collections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Note on Javascript (all?) closures and the difference between reference and value</title>
		<link>http://www.mindstab.net/note-javascript-closures-difference-reference/</link>
		<comments>http://www.mindstab.net/note-javascript-closures-difference-reference/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 21:21:10 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=970</guid>
		<description><![CDATA[for&#40;var i=0; i&#60; 10; i++&#41; &#123; var t = setTimeout&#40; function &#40;&#41; &#123; alert&#40;i&#41;;&#125;, 200&#41;; &#125; This will results in 10 alerts all saying &#8217;10&#8242; and not as some might think 10 alerts of 1, 2, 3, &#8230;, 9, 10. This is because the function being called is a closure and contains a reference to [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> t <span style="color: #339933;">=</span> setTimeout<span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>This will results in 10 alerts all saying &#8217;10&#8242; and not as some might think 10 alerts of 1, 2, 3, &#8230;, 9, 10.  This is because the function being called is a closure and contains a reference to <i>i</i>, not the value of <i>i</i>.  When the first one is finally called, 200ms later, <i>i</i> contains the value of 10 since the loop is done executing when the function looks <i>i</i> up.  I suspect this has caused some people some headaches.</p>
<p>You can easily test this in Chrome&#8217;s javascript console as I did first ;)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/note-javascript-closures-difference-reference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Game of Life in HTML/Canvas</title>
		<link>http://www.mindstab.net/game-life-htmlcanvas/</link>
		<comments>http://www.mindstab.net/game-life-htmlcanvas/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 07:08:53 +0000</pubDate>
		<dc:creator>Dan Ballard</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.mindstab.net/?p=966</guid>
		<description><![CDATA[I&#8217;ve been wanting to play with HTML5&#8242;s canvas for a bit now and I&#8217;ve always liked Conway&#8217;s game of life since it was introduced to me in first year CS so it seemed like a good match. In the spare time of a few days I was easily able to cobble it together, and even [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to play with HTML5&#8242;s canvas for a bit now and I&#8217;ve always liked Conway&#8217;s game of life since it was introduced to me in first year CS so it seemed like a good match.  In the spare time of a few days I was easily able to cobble it together, and even add some nice controls and one novel (to me) feature: the rainbow color age effect, which cycles the color of the cells and darkens them with age so you can quickly see the age of cells on the board and get a pretty show.</p>
<p>The code is on <a href="https://github.com/dballard/Life-Canvas">github</a> and you can see it live on the <a href="http://www.mindstab.net/life">demo</a> I put up.</p>
<p>HTML5&#8242;s canvas is fun for simple things like this.  I don&#8217;t know how it would a) hold up for more complicated and practical applications, and b) how much &#8220;fun&#8221; it would still be.  Maybe I&#8217;ll find out, maybe not.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mindstab.net/game-life-htmlcanvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

