<?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>Groby's Coding Adventures</title>
	<atom:link href="http://www.codingadventures.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingadventures.com</link>
	<description>Captain's log</description>
	<lastBuildDate>Tue, 16 Jun 2009 11:32:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Dearth of Batch Queueing Systems</title>
		<link>http://www.codingadventures.com/2009/06/the-dearth-of-batch-queueing-systems/</link>
		<comments>http://www.codingadventures.com/2009/06/the-dearth-of-batch-queueing-systems/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:32:38 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=81</guid>
		<description><![CDATA[For a side project, I&#8217;ve been looking for a batch queueing system &#8211; i.e. a system that I simply submit a command script to, and the script gets executed on the next available server. The output is logged &#8211; while running &#8211; into a central database. Bonus points if there&#8217;s fine-grained control over what servers [...]]]></description>
			<content:encoded><![CDATA[<p>For a side project, I&#8217;ve been looking for a batch queueing system &#8211; i.e. a system that I simply submit a command script to, and the script gets executed on the next available server. The output is logged &#8211; while running &#8211; into a central database. Bonus points if there&#8217;s fine-grained control over what servers get chosen.</p>

<p>And it turns out, solutions to that problem don&#8217;t really exist. Yes, I can &#8220;roll my own&#8221; with duct tape and a bunch of shell scripts &#8211; but is this truly a system that nobody ever saw the need to create and share with the world?</p>

<p>In case it is shared, I&#8217;d really like to hear about it. If not, it&#8217;s probably ending up on my projects list sooner or later&#8230; And in case it does, here&#8217;s a set of links to get started.</p>

<h2>OSS packages</h2>

<p>Somewhat close to what I need, usually with lots of overkill in areas I don&#8217;t need:</p>

<ul>
<li><a href="http://www.cs.wisc.edu/condor/">Condor</a></li>
<li><a href="http://www.cs.wisc.edu/condor/">TORQUE</a> &#8211; this one looks closest to what I need, but again, is <em>huge</em></li>
<li><a href="http://mauischeduler.sourceforge.net/">Maui Scheduler</a> &#8211; a scheduling counterpart to TORQUE</li>
<li><a href="http://www.linuxjournal.com/article/4208">GNU Queue</a> &#8211; seems pretty abandoned</li>
<li><a href="http://www.drqueue.org/cwebsite/about_drqueue.php">DrQueue</a> &#8211; Mostly for scheduling render tasks, but can maybe be bent to my will</li>
</ul>

<h2>Discussions &amp; articles on the net:</h2>

<ul>
<li>A <a href="http://ask.slashdot.org/article.pl?sid=05/02/10/154200&amp;tid=185&amp;tid=4">slashdot article</a></li>
<li>Getting <a href="http://blog.joeygeiger.com/2009/02/25/rabbitmq-and-monit/">RabbitMQ on OSX</a></li>
<li>Jeremy Zawodny on <a href="http://jeremy.zawodny.com/blog/archives/010511.html">Open Source Queueing and Messaging Systems</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/06/the-dearth-of-batch-queueing-systems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting my source code</title>
		<link>http://www.codingadventures.com/2009/06/hosting-my-source-code/</link>
		<comments>http://www.codingadventures.com/2009/06/hosting-my-source-code/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 22:32:12 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[git]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=78</guid>
		<description><![CDATA[Over time, I&#8217;ve accumulated quite a few projects on my hard drive. And while I like having them there, I always feel it&#8217;s a very fragile place to keep them. Yes, I do back up &#8211; less often than I should. But even then, it&#8217;s just an earthquake away from being gone.

So ideally, I&#8217;d like [...]]]></description>
			<content:encoded><![CDATA[<p>Over time, I&#8217;ve accumulated quite a few projects on my hard drive. And while I like having them there, I always feel it&#8217;s a very fragile place to keep them. Yes, I do back up &#8211; less often than I should. But even then, it&#8217;s just an earthquake away from being gone.</p>

<p>So ideally, I&#8217;d like to have my code in an offsite repository, in addition to what I have locally. Putting my eggs into multiple baskets, so to speak.</p>

<p>The simplest solution would be to install GIT on my dreamhost account. (Shameless plug: If you sign up with them and use the promo code GROBY, you get $50 off your fees, and I&#8217;ll make $47 towards my hosting costs.) <a href="http://autopragmatic.com">Autopragmatic</a> has an excellent account on <a href="http://autopragmatic.com/2008/01/26/hosting-a-git-repository-on-dreamhost/">how to set up git on dreamhost</a>. That&#8217;s not quite what I want though. First of all, quite a few git repositories are my actual web sites &#8211; hosting them with your service provider seems to defeat the purpose.</p>

<p>The next option coming up is hosting my git repositories on S3. Unfortunately, the only options I am seeing involve using S3 as a file system &#8211; i.e. <a href="http://www.rsaccon.com/2007/10/mount-amazon-s3-on-your-mac.html">using s3fs on OSX</a>. Again, not a very appealing option to me &#8211; if I host my code in the cloud, I want to be able to get there from anywhere.</p>

<p>Next up on the cost scale: <a href="http://www.indefero.net/">InDefero</a>. It is an open source package that provides both git &amp; svn hosting, and adds bug tracking/code review on top. And on top of all that, they give you free hosting with 250MB storage. Downside? 6 months of inactivity, and they drop your account. It&#8217;s probably good enough for most people like me, who have a local repo + backup, only small projects, and want additional cloud hosting, just to feel secure.</p>

<p>It&#8217;s probably a not-so-good idea to rely on them if that code is your livelihood, though &#8211; you do want some level of contractual agreement there.</p>

<p>The next step up then would be either going with a hosted provider &#8211; there is a <a href="http://git.or.cz/gitwiki/GitHosting">GitHosting list on GitWiki</a>, or installing indefero on your own hosts. (The cost is roughly the same, since you will need a second hosting provider to gain any real benefit &#8211; it depends if you want somebody focused on source control systems only, or if you need a second hosting provider anyways)</p>

<p>And whatever you do &#8211; if it&#8217;s code that makes you money, make <em>sure</em> who you are going with. Losing source code is painful enough if it&#8217;s just a hobby project.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/06/hosting-my-source-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Automate mysql backup via crontab</title>
		<link>http://www.codingadventures.com/2009/05/66/</link>
		<comments>http://www.codingadventures.com/2009/05/66/#comments</comments>
		<pubDate>Wed, 13 May 2009 12:30:31 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=66</guid>
		<description><![CDATA[Since I really like my databases to be backed up, I wanted to make sure there&#8217;s at least a very rudimentary dump of my databases every night. (Note: While I host on Dreamhost, this should apply to other hosting services too)

Requirement  #2 &#8211; I don&#8217;t want to manage my backups. After a couple of [...]]]></description>
			<content:encoded><![CDATA[<p>Since I really like my databases to be backed up, I wanted to make sure there&#8217;s at least a very rudimentary dump of my databases every night. (Note: While I host on Dreamhost, this should apply to other hosting services too)</p>

<p>Requirement  #2 &#8211; I don&#8217;t want to manage my backups. After a couple of days, backups should automatically be deleted.</p>

<p>The easiest way to achieve all this is using crontab. Just add the following two lines</p>

<pre>
  0 3  *   *   *     mysqldump --defaults-extra-file=&lt;CONFIG PATH&gt;/backup.cnf -h &lt;DB HOST&gt; --comments -R --triggers --quote-names --allow-keywords --set-charset --quick --single-transaction --lock-tables &lt;DATABASE&gt; &gt; &lt;BACKUP PATH&gt;/database_$(date +%Y_%m_%d).sql
  0 4  *   *   *     find &lt;BACKUP PATH&gt; -name '*.sql' -and -mtime +7 | xargs rm
</pre>

<p>and create a configuration file called backup.cnf which looks roughly like this:</p>

<pre>
[client]
user = &lt;user name&gt;
password = &lt;password&gt;
</pre>

<p>(And obviously, adjust all paths and site names to be useful for <em>you</em>)</p>

<p>The point of the .cnf file is to not announce your password via the command line. (Which everybody can take a look at should they happen to be online when your backup is running)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/05/66/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging Applications for Django</title>
		<link>http://www.codingadventures.com/2009/05/blogging-applications-for-django/</link>
		<comments>http://www.codingadventures.com/2009/05/blogging-applications-for-django/#comments</comments>
		<pubDate>Mon, 11 May 2009 11:46:55 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=47</guid>
		<description><![CDATA[In my ongoing quest to build my web-based Django web site, the next step is creating a blog. The problem &#8211; there is no definitive blogging application for Django. That&#8217;s I guess true for any decent web framework &#8211; blogging is an application that&#8217;s simple enough that nobody bothers to go past what their own [...]]]></description>
			<content:encoded><![CDATA[<p>In my ongoing quest to build my web-based Django web site, the next step is creating a blog. The problem &#8211; there is no definitive blogging application for Django. That&#8217;s I guess true for any decent web framework &#8211; blogging is an application that&#8217;s simple enough that nobody bothers to go past what their own needs are.</p>

<p>There are a few decent starting points, for sure. If that&#8217;s what you&#8217;re after, here&#8217;s the list:</p>

<ul>
<li><p><a href="http://github.com/nathanborror/django-basic-apps/commits/master">django-basic-apps</a><br />
The canonic starting point for a lot of Django apps.  It takes care not only of blogs, but a lot of other fairly common things (movies, music, books, bookmarks, places, people,&#8230;) too. Seems to be maintained by a single person.</p></li>
<li><p><a href="http://code.google.com/p/djangotechblog/">Django Techblog</a><br />
Mostly worth mentioning for its integration of Microblogging. While it&#8217;s only a single person working at it, it looks like a fairly active application. There seem to be at least 10-15 check-ins per month.</p></li>
<li><p><a href="http://github.com/mightylemon/mightylemon/tree/master">MightyLemon</a><br />
Fairly active, multiple committers. Nothing special about it, as far as I can tell. (Unless you&#8217;re a huge Leah Culver fan)</p></li>
<li><p><a href="http://code.google.com/p/blogmaker/">BlogMaker</a><br />
Fairly large feature set, but very infrequent commits, even though the author only think it&#8217;s worthy of a 0.6. Definitely a good place to see how others solved a lot of blogging issues.</p></li>
<li><p><a href="http://code.google.com/p/blogmaker/">ByteFlow</a><br />
Large feature list, single committer (mostly).If you want a feature complete solution that requires minimal work, this would probably be the best choice.</p></li>
<li><p><a href="http://bazaar.launchpad.net/%7Ezeth0/soturi/trunk/files">Soturi</a><br />
Fairly minimal code, few changes, seems abandoned since December &#8216;08. Good project if you want to see a minimalist blog</p></li>
<li><p><a href="http://getbanjo.com/">Banjo</a><br />
The most curious case of all of them. Somebody put quite a bit of design effort into having a nice home for this, clearly intending to make this a good reference implementation &#8211; but then fell short of providing much useful content on the page. From the looks of the repository, it seems to be under more or less active development by at least one person.</p></li>
</ul>

<p>After thinking about all of this for a bit of time, I decided to roll my own &#8211; after all, the main purpose of my new blog is learning about Django, so I might as well do more than just download some code&#8230;</p>

<p>I&#8217;m still lazy enough to look for a decent starting point that takes care of a lot of grunt work &#8211; and that allows me to post fairly soon. (I really want to start writing, and not postpone it for another few months.)</p>

<p>As a result of all that, I decided to start based from django-basic-apps. It&#8217;s the canonic solution, it&#8217;s hosted on <a href="http://github.com">github</a> (my vcs host of choice), and it seems to be under active development. I can always borrow from the other ones, should the need arise&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/05/blogging-applications-for-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preloading your Django application &#8211; or, how to keep static data</title>
		<link>http://www.codingadventures.com/2009/05/preloading-your-django-application-or-how-to-keep-static-data/</link>
		<comments>http://www.codingadventures.com/2009/05/preloading-your-django-application-or-how-to-keep-static-data/#comments</comments>
		<pubDate>Tue, 05 May 2009 11:49:54 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=43</guid>
		<description><![CDATA[The first step in setting up my new online presence with Django is of course to just present a static home page. The goal is to be up and running as soon as possible, after all. Unfortunately, it&#8217;s a bit harder than just slapping your html and css files onto the web server when you&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>The first step in setting up my <a href="http://www.rachelblum.com">new online presence</a> with Django is of course to just present a static home page. The goal is to be up and running as soon as possible, after all. Unfortunately, it&#8217;s a bit harder than just slapping your html and css files onto the web server when you&#8217;re using a framework like Django.</p>

<p>In Django&#8217;s case, I need to install flatpages. That solves the problem of storing static pages, and lets me create them right via the admin interface. But here&#8217;s the rub: I want some of those pages preloaded when I deploy &#8211; especially during the initial experimental phase, I anticipate wiping out and reinstalling my application quite a few times.</p>

<p>Thankfully, there&#8217;s a solution to that too &#8211; <code>django-admin <a href="http://www.djangoproject.com/documentation/django-admin/#dumpdata-appname-appname">dumpdata</a>/<a href="http://www.djangoproject.com/documentation/django-admin/#loaddata-fixture-fixture">loaddata</a></code>. <code>dumpdata</code> lets you export data from the database into JSON files. I.e. to dump all your flatpages:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
django-admin.py dumpdata flatpages &gt; flatpages.json<br />
&nbsp;</div>

<p>And obviously, you reload via</p>

<div class="dean_ch" style="white-space: wrap;"><br />
django-admin.py dumpdata flatpages &gt; flatpages.json<br />
&nbsp;</div>

<p>This is almost all I need &#8211; I could certainly encode the re-loading of the data as another deployment step. But &#8211; here&#8217;s where being in a framework starts paying off &#8211; there&#8217;s a way to do this more easily. Just rename your dumped data to <code>initial_data.json</code>, and Django will load it into the database whenever you execute a <code>syncdb</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/05/preloading-your-django-application-or-how-to-keep-static-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting started with Django</title>
		<link>http://www.codingadventures.com/2009/05/getting-started-with-django/</link>
		<comments>http://www.codingadventures.com/2009/05/getting-started-with-django/#comments</comments>
		<pubDate>Mon, 04 May 2009 12:13:26 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=31</guid>
		<description><![CDATA[I&#8217;ve been going through quite a bit of changes in my life lately &#8211; and as a part of that, my home blog (not this one &#8211; the personal things) will be moving to http://www.rachelblum.com.

And since I felt like I need more experience with web frameworks in general, I&#8217;m not sticking with my trusty wordpress. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going through quite a bit of <a href="http://www.robertblum.com/articles/2009/04/12/ch-ch-ch-changes">changes</a> in my life lately &#8211; and as a part of that, my home blog (not this one &#8211; the personal things) will be moving to <a href="http://www.rachelblum.com">http://www.rachelblum.com.</a></p>

<p>And since I felt like I need more experience with web frameworks in general, I&#8217;m not sticking with my trusty wordpress. It does all the things I want it to do, but it was time to try something new: <a href="http://www.django.org">Django</a>.</p>

<p>It was surprisingly easy to get started &#8211; most of my troubles came from the facts that I&#8217;ve skipped steps in the tutorials here or there, and then got flabbergasted when things didn&#8217;t work. Well, it&#8217;s all sorted out so far, but there&#8217;s one nifty trick I&#8217;d really like to share. Django has all its settings in a settings.py file, and it needs to change depending where you deploy and what your backend database is. That doesn&#8217;t work well with the idea of version control &#8211; so I modified the settings so you can get settings per machine.</p>

<p>At the bottom of settings.py, add the following code:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">import</span> <span class="kw3">socket</span><br />
hostname = <span class="kw3">socket</span>.<span class="me1">gethostname</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">replace</span><span class="br0">&#40;</span><span class="st0">&#8216;.&#8217;</span>,<span class="st0">&#8216;_&#8217;</span><span class="br0">&#41;</span><br />
hostname = hostname.<span class="me1">replace</span><span class="br0">&#40;</span><span class="st0">&#8216;-&#8217;</span>,<span class="st0">&#8216;_&#8217;</span><span class="br0">&#41;</span>.<span class="me1">lower</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="kw1">exec</span> <span class="st0">&quot;from config.%s import *&quot;</span> % hostname &nbsp;<br />
&nbsp;</div>

<h4>Notes</h4>

<ol>
<li>I put all my configurations into a separate config module. I just like things clean &#8211; you can certainly keep them with the rest of your python.</li>
<li>I know that <code>exec</code> is evil, but I <em>really</em> couldn&#8217;t figure out how to do this with <code>__import__</code> instead. Any tips appreciated</li>
<li>The mangling of <code>gethostname()</code> via <code>replace()</code> gets rid of invalid characters that import can&#8217;t handle. Also, it&#8217;s only split over two lines so I don&#8217;t get ugly line breaks.</li>
</ol>

<h2>Another layer of indirection</h2>

<p>All those per-host files should only contain host-specific settings. With exactly one development and one production machine, that&#8217;s certainly not too much duplication. And yet, I split it up into production.py and development.py &#8211; again, just because it looks a little bit cleaner<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> (And I might get a new development machine at some point&#8230;)</p>

<p>So the config file for my local development machine right now only says</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">from</span> config.<span class="me1">development</span> <span class="kw1">import</span> *<br />
&nbsp;</div>

<p>I&#8217;ve been tempted to add a base.py for shared settings into the mix, but at some point, I probably should go back to developing as opposed to housekeeping.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p><a href="http://lethain.com/author/will-larson/">Will Larson</a> has a more elaborate <a href="http://lethain.com/entry/2008/nov/03/development-to-deployment-in-django/">explanation why to do this</a>, as well as an excellent description of his deployment pipeline.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/05/getting-started-with-django/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Lispy on OSX</title>
		<link>http://www.codingadventures.com/2009/01/getting-lispy-on-osx/</link>
		<comments>http://www.codingadventures.com/2009/01/getting-lispy-on-osx/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 02:25:24 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=24</guid>
		<description><![CDATA[I've finally decided to give that "Lisp" thing another try. So, first order of business, find a good set of tools. First stop: <a href="http://aquamacs.org/index.shtml">AquaMacs</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally decided to give that &#8220;Lisp&#8221; thing another try &#8211; my first one being back in about 1978 or so. So, first order of business, find a good set of tools. A lot of programmers are ranting and raving about the wonderfulness of Emacs, so I decided to give it a try. With Emacs and Lisp, you will be inevitably be pointed to SLIME as the development environment of choice.</p>

<p>First stop: <a href="http://aquamacs.org/index.shtml">AquaMacs</a>
More or less it&#8217;s Emacs, adopted for OSX. I installed it &#8211; it was as easy as Mac apps should be &#8211; but it turns out it already has a built-in version of SLIME. And most SLIME docs recommend you <em>always</em> use the latest CVS version.</p>

<p>So back to the drawing board. We have to build the real McCoy. You get it like this:</p>

<div class="dean_ch" style="white-space: wrap;">cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/emacs <span class="kw2">login</span></div>

<p>Use your e-mail address as password, wait a while till everything&#8217;s downloaded, and</p>

<div class="dean_ch" style="white-space: wrap;">./configure ; <span class="kw2">make</span>; <span class="kw2">sudo</span> <span class="kw2">make</span> <span class="kw2">install</span></div>

<p>If you&#8217;re not familiar with emacs, I&#8217;d recommend you at least do a quick run through the emacs tutorial. Fire up emacs, press Control-h followed by t, and follow the on-screen instructions.</p>

<p>Next up &#8211; we&#8217;re installing <a href="http://sbcl.sourceforge.net/getting.html">SBCL</a></p>

<div class="dean_ch" style="white-space: wrap;"><span class="re2">INSTALL_ROOT=</span>/usr/<span class="kw3">local</span> <span class="kw2">sudo</span> <span class="kw2">sh</span> <span class="kw2">install</span>.<span class="kw2">sh</span></div>

<p>Once that is done,</p>

<div class="dean_ch" style="white-space: wrap;">sbcl</div>

<p>, and it should bring up the SBCL prompt. Type</p>

<div class="dean_ch" style="white-space: wrap;"><span class="br0">&#40;</span>quit<span class="br0">&#41;</span></div>

<p>followed by enter to leave it again.</p>

<p>Now we&#8217;re ready to get <a href="http://common-lisp.net/project/slime/">SLIME</a></p>

<div class="dean_ch" style="white-space: wrap;">cvs -d :pserver:anonymous:anonymous@common-lisp.net:/project/slime/cvsroot <span class="kw2">co</span> slime</div>

<p>Finally, all you need is add a couple of lines to your .emacs</p>

<div class="dean_ch" style="white-space: wrap;"><span class="co1">;; slime</span><br />
<span class="br0">&#40;</span><span class="kw1">setq</span> lisp-sbcl &nbsp; &nbsp; <span class="st0">&quot;/usr/local/bin/sbcl&quot;</span><span class="br0">&#41;</span><br />
<span class="br0">&#40;</span>add-to-<span class="kw1">list</span> &#8216;Info-default-directory-<span class="kw1">list</span> <span class="st0">&quot;/Users/groby/usr/share/info&quot;</span><span class="br0">&#41;</span><br />
<span class="co1">;; by registering your implementations, you can choose one by</span><br />
<span class="co1">;; its &quot;short name&quot; when doing M&#8211; M-x slime</span><br />
<span class="br0">&#40;</span><span class="kw1">setq</span> slime-lisp-implementations<br />
&nbsp; &#8216;<span class="br0">&#40;</span><span class="br0">&#40;</span>sbcl &nbsp; <span class="br0">&#40;</span><span class="st0">&quot;//usr/local/bin/sbcl&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> &nbsp;<span class="co1">; default</span><br />
<span class="br0">&#40;</span><span class="kw1">setq</span> slime-edit-definition-fallback-<span class="kw1">function</span> &#8216;find-tag<span class="br0">&#41;</span><br />
<span class="br0">&#40;</span><span class="kw1">setq</span> slime-complete-symbol-<span class="kw1">function</span> &#8217;slime-fuzzy-complete-<span class="kw1">symbol</span><span class="br0">&#41;</span><br />
<span class="br0">&#40;</span>slime-setup <span class="br0">&#41;</span><br />
<span class="br0">&#40;</span>global-set-key <span class="st0">&quot;<span class="es0">\C</span>-cs&quot;</span> &#8217;slime-selector<span class="br0">&#41;</span><br />
&nbsp;</div>

<p>If you need more detailed instructions, go to <a href="http://www.david-steuber.com/Lisp/OSX/">http://www.david-steuber.com/Lisp/OSX/</a></p>

<p>The most recommended starting point for the language, at least according to Google: <a href="http://www.gigamonkeys.com/book/">Practical Common Lisp</a></p>

<p>My verdict so far &#8211; I can&#8217;t stand that environment. SLIME is fragile, and Emacs is a prehistoric editor. As for Practical Common Lisp, it&#8217;s a decent intro, but the code examples bored me to tears. I <em>really</em> don&#8217;t want to write yet another MP3 song database&#8230;</p>

<p>More research reveals that there is a rather overwhelming collection of possible starting points. One of the best collections of references to Lisp environments and Lisp books is a <a href="http://www.reddit.com/r/programming/comments/1a73t/fine_i_will_look_at_lisp_where_do_i_start">thread on reddit</a> &#8211; I really should&#8217;ve looked there sooner.</p>

<p>So the setup I ended up with for now? I stuck with SBCL, the editor is good old trusty <a href="http://macromates.com/">TextMate</a>, and for a starting set of problems to cut my teeth on, I went with <a href="http://projecteuler.net">Project Euler</a>. (PCL left me with a good enough grasp of Lisp that I could at least start on problem one&#8230;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2009/01/getting-lispy-on-osx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Cocoa &#8211; Book Recommendations</title>
		<link>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/</link>
		<comments>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 04:28:48 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[cocoa]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=23</guid>
		<description><![CDATA[These days, I get quite a few questions from my fellow co-workers about resources to start with Cocoa development. So here&#8217;s a quick list of books that I absolutely recommend:



Objective C in general: Programming ObjectiveC



Intro to Cocoa: Learning Cocoa with ObjectiveC



Getting your feet wet on the iPhone: iPhone Open Application Development




And of course, when it [...]]]></description>
			<content:encoded><![CDATA[<p>These days, I get quite a few questions from my fellow co-workers about resources to start with Cocoa development. So here&#8217;s a quick list of books that I absolutely recommend:</p>

<table>
<tr>
<td>Objective C in general: </td><td><a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FProgramming-Objective-C-Developers-Library-Stephen%2Fdp%2F0672325861%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1214336146%26sr%3D8-1&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Programming ObjectiveC</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></td>
</tr>

<tr>
<td>Intro to Cocoa:</td><td> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FLearning-Cocoa-Objective-C-Duncan-Davidson%2Fdp%2F0596003013%3Fie%3DUTF8%26s%3Dbooks%26qid%3D1215577433%26sr%3D1-1&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">Learning Cocoa with ObjectiveC</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></td>
</tr>

<tr>
<td>Getting your feet wet on the iPhone:</td><td> <a href="http://www.amazon.com/gp/redirect.html?ie=UTF8&#038;location=http%3A%2F%2Fwww.amazon.com%2FiPhone-Open-Application-Development-Applications%2Fdp%2F0596518552&#038;tag=robertblum-20&#038;linkCode=ur2&#038;camp=1789&#038;creative=9325">iPhone Open Application Development</a><img src="http://www.assoc-amazon.com/e/ir?t=robertblum-20&amp;l=ur2&amp;o=1" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
</td>
</tr>
</table>

<p>And of course, when it comes to web pages, there&#8217;s the invaluable <a href="http://www.cocoadev.com/">CocoaDev Wiki</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/07/learning-cocoa-book-recommendations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Threshold Filter in GLSL</title>
		<link>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/</link>
		<comments>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 07:31:13 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[core image]]></category>
		<category><![CDATA[glsl]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shader]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=22</guid>
		<description><![CDATA[I&#8217;ve been recently playing a little bit with GLSL/Core Image shaders. One of the earliest limitations I ran into was the fact that you cannot have conditional results. In other word, if you do an if/else test, the output of your shader cannot depend on it. (Not entirely sure why you&#8217;d want to use if/else [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been recently playing a little bit with GLSL/Core Image shaders. One of the earliest limitations I ran into was the fact that you <a href="http://developer.apple.com/documentation/GraphicsImaging/Conceptual/ImageUnitTutorial/Overview/chapter_3_section_4.html">cannot have conditional results</a>. In other word, if you do an if/else test, the output of your shader cannot depend on it. (Not entirely sure why you&#8217;d want to use if/else at all, then&#8230;)</p>

<p>That&#8217;s rather annoying. Thankfully, that&#8217;s a solved problem. Many CPUs prefer non-branching code, too, and there&#8217;s a long history of creating non-branching version of code that technically should branch. The trick here is &#8220;creative&#8221; use of math and/or bit-logic functions. As a simple example, let&#8217;s say I have a threshold shader &#8211; values below the minimum value should have a brightness of 0, and values higher than the max value should have a brightness of 1.</p>

<p><code>step()</code> function to the rescue: <code>step(a,b)</code> returns 0 if <code>a &lt; b</code>, <code>1 if a > b</code>. So to cut off the low range, we have</p>

<div class="dean_ch" style="white-space: wrap;">brightness = step<span class="br0">&#40;</span> low, brightness <span class="br0">&#41;</span> * brightness;</div>

<p>Very similarly, to check against the max value, we force brightness to be greater than 1 for pixels above the maximum threshold and then clamp to 1.0</p>

<div class="dean_ch" style="white-space: wrap;"><br />
&nbsp; brightness = brightness + step<span class="br0">&#40;</span> &nbsp;high, brightness <span class="br0">&#41;</span>;<br />
&nbsp; brightness = min<span class="br0">&#40;</span> <span class="nu0">1.0</span>, brightness <span class="br0">&#41;</span>;<br />
&nbsp;</div>

<p>That&#8217;s all there is to it. And in case you actually came for the filter code, here it is &#8211; with input sanitizing, nicer input values (midpoint/range), grayscale conversion, all the fun stuff.</p>

<div class="dean_ch" style="white-space: wrap;"><br />
kernel vec4 threshold<span class="br0">&#40;</span>sampler image, <span class="kw4">float</span> midPoint, <span class="kw4">float</span> range <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; vec4 pixel=unpremultiply<span class="br0">&#40;</span> sample<span class="br0">&#40;</span>image, samplerCoord<span class="br0">&#40;</span>image<span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;<br />
<br />
&nbsp; <span class="kw4">float</span> high = midPoint + range * <span class="nu0">0.5</span>;<br />
&nbsp; <span class="kw4">float</span> low = midPoint &#8211; range * <span class="nu0">0.5</span>;<br />
&nbsp; <br />
&nbsp; high = min<span class="br0">&#40;</span><span class="nu0">1.0</span>, high<span class="br0">&#41;</span>;<br />
&nbsp; low = max<span class="br0">&#40;</span><span class="nu0">0.0</span>, low<span class="br0">&#41;</span>;<br />
&nbsp; <br />
&nbsp; <span class="kw4">float</span> brightness = <span class="nu0">0.3</span> * pixel.<span class="me1">x</span> + <span class="nu0">0.59</span> * pixel.<span class="me1">y</span>+ <span class="nu0">0.11</span> *pixel.<span class="me1">z</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; brightness = step<span class="br0">&#40;</span> low, brightness <span class="br0">&#41;</span> * brightness;<br />
&nbsp; <br />
&nbsp; brightness = brightness + step<span class="br0">&#40;</span> &nbsp;high, brightness <span class="br0">&#41;</span>;<br />
&nbsp; brightness = min<span class="br0">&#40;</span> <span class="nu0">1.0</span>, brightness <span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <br />
&nbsp; pixel.<span class="me1">x</span> = pixel.<span class="me1">y</span> =pixel.<span class="me1">z</span> = brightness;<br />
&nbsp; <br />
&nbsp; <span class="kw1">return</span> premultiply<span class="br0">&#40;</span>pixel<span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<br />
&nbsp;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/06/threshold-filter-in-glsl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Standalone RubyCocoa Applications</title>
		<link>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/</link>
		<comments>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 17:11:00 +0000</pubDate>
		<dc:creator>Groby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.codingadventures.com/?p=16</guid>
		<description><![CDATA[RubyCocoa is one of the most fascinating tools on OSX. It makes it more than easy to rapidly prototype and try ideas with Cocoa. But unfortunately, out of the box, a RubyCocoa project seems to require an Objective-C shell to start it up. That means firing up XCode for every single prototype you&#8217;re playing with.

It [...]]]></description>
			<content:encoded><![CDATA[<p>RubyCocoa is one of the most fascinating tools on OSX. It makes it more than easy to rapidly prototype and try ideas with Cocoa. But unfortunately, out of the box, a RubyCocoa project seems to require an Objective-C shell to start it up. That means firing up XCode for every single prototype you&#8217;re playing with.</p>

<p>It only seems that way, though. A quick <a href="http://www.rubycocoa.com/mastering-cocoa-with-ruby/1">look behind the scenes</a> reveals that all that shell does is:</p>

<ul>
<li>start the ruby environment</li>
<li>&#8216;require&#8217; all included ruby scripts</li>
<li>and runs NSApplicationMain</li>
</ul>

<p>The first two, I can obviously do on my own. The third provides the main loop for all NSApplications. But you can&#8217;t simply call it from Ruby &#8211; it requires you to have an Info.plist. Again, too much baggage for quick &amp; dirty prototypes. The goal is to have <em>one</em> ruby file to play around in.</p>

<p>That one is a bit trickier to find out, but after digging around in Apple&#8217;s documentation, it turns out there is a decent explanation in the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html">overview for NSApplication</a></p>

<p>For future reference, this is what it does:</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw4">void</span> NSApplicationMain<span class="br0">&#40;</span><span class="kw4">int</span> argc, <span class="kw4">char</span> *argv<span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSApplication.html"><span class="kw6">NSApplication</span></a> sharedApplication<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSBundle.html"><span class="kw5">NSBundle</span></a> loadNibNamed:@<span class="st0">&quot;myMain&quot;</span> owner:NSApp<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#91;</span>NSApp run<span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span><br />
&nbsp;</div>

<p>Now we&#8217;re getting somewhere. This can actually be completely duplicated in Ruby. Since I might want to quit my application, I&#8217;ve thrown in a window that shuts down the application when closed.</p>

<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw3">require</span> <span class="st0">&#8216;OSX/cocoa&#8217;</span><br />
<br />
<span class="kw1">class</span> CloseDelegate &lt; <span class="re2">OSX::NSObject</span><br />
&nbsp; <span class="kw1">def</span> windowWillClose<span class="br0">&#40;</span> sender <span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="re2">OSX::NSApp</span>.<span class="me1">terminate_</span> sender<br />
&nbsp; <span class="kw1">end</span><br />
<span class="kw1">end</span><br />
<br />
<span class="co1"># Instantiate the shared App</span><br />
<span class="re2">OSX::NSApplication</span>.<span class="me1">sharedApplication</span><br />
<br />
window = <span class="re2">OSX::NSWindow</span>.<span class="me1">alloc</span><br />
window.<span class="me1">initWithContentRect_styleMask_backing_defer_</span><span class="br0">&#40;</span> <br />
&nbsp; <span class="re2">OSX::NSMakeRect</span><span class="br0">&#40;</span><span class="nu0">50</span>,<span class="nu0">50</span>,<span class="nu0">200</span>,<span class="nu0">400</span><span class="br0">&#41;</span>, <br />
&nbsp; <span class="re2">OSX::NSTitledWindowMask</span> <br />
&nbsp; &nbsp; + <span class="re2">OSX::NSClosableWindowMask</span>, <br />
&nbsp; <span class="re2">OSX::NSBackingStoreBuffered</span>, <span class="kw2">true</span><span class="br0">&#41;</span><br />
<br />
window.<span class="me1">setDelegate</span> CloseDelegate.<span class="me1">alloc</span>.<span class="me1">init</span><br />
window.<span class="me1">makeKeyAndOrderFront</span> <span class="kw2">nil</span><br />
<br />
<span class="co1"># run the main loop</span><br />
<span class="re2">OSX::NSApplication</span>.<span class="me1">sharedApplication</span>.<span class="me1">run</span><br />
<br />
&nbsp;</div>

<p>Or just download <a href="http://www.codingadventures.com/projects/standalone.rb">standalone.rb</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingadventures.com/2008/06/standalone-rubycocoa-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.987 seconds -->
