<?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>srsly &#187; Code</title>
	<atom:link href="http://srsly.me/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://srsly.me</link>
	<description></description>
	<lastBuildDate>Thu, 27 May 2010 02:37:36 +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>Batch Converting Files With FFmpeg and Ruby</title>
		<link>http://srsly.me/2009/11/29/batch-converting-files-with-ffmpeg-and-ruby/</link>
		<comments>http://srsly.me/2009/11/29/batch-converting-files-with-ffmpeg-and-ruby/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 00:33:04 +0000</pubDate>
		<dc:creator>Joseph Jaramillo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[dvd]]></category>
		<category><![CDATA[ffmpeg]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://srsly.me/?p=395</guid>
		<description><![CDATA[I recently needed to burn some video files (h.264 MKV) to DVD such that the disc would work in a standalone player.  After an hour googling for a set of commands to pass to ffmpeg to convert my files, I then started looking for batch scripts.  It occurred to me shortly thereafter that [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to burn some video files (h.264 MKV) to DVD such that the disc would work in a standalone player.  After an hour googling for a set of commands to pass to ffmpeg to convert my files, I then started looking for batch scripts.  It occurred to me shortly thereafter that Ruby could help.  I had found <a href="http://atomized.org/2005/03/converting-divxxvid-avi-to-dvd-with-ffmpeg/" target="_blank">a command</a> that worked beautifully with a single file, so all that was necessary was to automate it.</p>
<p>It only took one line to accomplish the task:</p>
<p><script src="http://gist.github.com/245152.js?file=ffmpeg-batch-mkv2dvd.rb"></script><noscript><code>Dir.glob("*.mkv").each{ |f| `ffmpeg -i "#{f}" -target ntsc-dvd -aspect 16:9 -sameq "#{f.gsub('mkv','mpg')}"` }</code></noscript></p>
<p>It&#8217;d be a cinch to generalize for input video format.</p>
]]></content:encoded>
			<wfw:commentRss>http://srsly.me/2009/11/29/batch-converting-files-with-ffmpeg-and-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>memcached on Mac OS X 10.5 Leopard</title>
		<link>http://srsly.me/2009/03/10/memcached-on-mac-os-x-10-5-leopard/</link>
		<comments>http://srsly.me/2009/03/10/memcached-on-mac-os-x-10-5-leopard/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 03:41:41 +0000</pubDate>
		<dc:creator>Joseph Jaramillo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[memcached]]></category>

		<guid isPermaLink="false">http://srsly.me/?p=140</guid>
		<description><![CDATA[I attempted to install memcached via MacPorts earlier today, and ran into a problem with the MD5 and SHA1 hashes.
$ sudo port install memcached
--&#62;  Fetching memcached
---&#62;  Attempting to fetch memcached-1.2.6.tar.gz from http://www.danga.com/memcached/dist/
---&#62;  Verifying checksum(s) for memcached
Error: Checksum (md5) mismatch for memcached-1.2.6.tar.gz
Error: Checksum (sha1) mismatch for memcached-1.2.6.tar.gz
Error: Target org.macports.checksum returned: Unable to verify [...]]]></description>
			<content:encoded><![CDATA[<p>I attempted to install <a href="http://www.danga.com/memcached/" target="_blank">memcached</a> via MacPorts earlier today, and ran into a problem with the MD5 and SHA1 hashes.</p>
<pre class="brush: plain">$ sudo port install memcached
--&gt;  Fetching memcached
---&gt;  Attempting to fetch memcached-1.2.6.tar.gz from http://www.danga.com/memcached/dist/
---&gt;  Verifying checksum(s) for memcached
Error: Checksum (md5) mismatch for memcached-1.2.6.tar.gz
Error: Checksum (sha1) mismatch for memcached-1.2.6.tar.gz
Error: Target org.macports.checksum returned: Unable to verify file checksums
Error: Status 1 encountered during processing.</pre>
<p>After pulling down the file directly from the memcached web site, I discovered that tar wouldn&#8217;t extract it.</p>
<pre class="brush: plain">$ tar zxvf memcached-1.2.6.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors</pre>
<p>No matter; we&#8217;ll do it the hard way.  These are the steps I followed to install memcached on my Mac.  The only assumptions I&#8217;m consciously making are that you use MacPorts and git.</p>
<p>1.  Install libevent through MacPorts:</p>
<pre class="brush: plain">$ sudo port install libevent</pre>
<p>2.  Clone the memcached git repository:</p>
<pre class="brush: plain">$ git clone http://consoleninja.net/code/memcached/memcached.git/</pre>
<p>3. Configure memcached:</p>
<pre class="brush: plain">$ cd memcached
$ ./autogen.sh
$ ./configure --prefix=/usr/local --with-libevent=/opt/local</pre>
<p>4.  Make and install:</p>
<pre class="brush: plain">$ make
$ sudo make install</pre>
<p>If everything went according to plan, you&#8217;re good to go.  Start it up:</p>
<pre class="brush: plain">$ memcached -vv</pre>
<p>That last line starts up a memcached server running on the default port 11211.  The -vv option tells memcached to use its most verbose output.  You should have seen output similar to the following:</p>
<pre class="brush: plain">slab class   1: chunk size     88 perslab 11915
slab class   2: chunk size    112 perslab  9362
slab class   3: chunk size    144 perslab  7281
slab class   4: chunk size    184 perslab  5698
slab class   5: chunk size    232 perslab  4519
slab class   6: chunk size    296 perslab  3542
slab class   7: chunk size    376 perslab  2788
slab class   8: chunk size    472 perslab  2221
slab class   9: chunk size    592 perslab  1771
slab class  10: chunk size    744 perslab  1409
slab class  11: chunk size    936 perslab  1120
slab class  12: chunk size   1176 perslab   891
slab class  13: chunk size   1472 perslab   712
slab class  14: chunk size   1840 perslab   569
slab class  15: chunk size   2304 perslab   455
slab class  16: chunk size   2880 perslab   364
slab class  17: chunk size   3600 perslab   291
slab class  18: chunk size   4504 perslab   232
slab class  19: chunk size   5632 perslab   186
slab class  20: chunk size   7040 perslab   148
slab class  21: chunk size   8800 perslab   119
slab class  22: chunk size  11000 perslab    95
slab class  23: chunk size  13752 perslab    76
slab class  24: chunk size  17192 perslab    60
slab class  25: chunk size  21496 perslab    48
slab class  26: chunk size  26872 perslab    39
slab class  27: chunk size  33592 perslab    31
slab class  28: chunk size  41992 perslab    24
slab class  29: chunk size  52496 perslab    19
slab class  30: chunk size  65624 perslab    15
slab class  31: chunk size  82032 perslab    12
slab class  32: chunk size 102544 perslab    10
slab class  33: chunk size 128184 perslab     8
slab class  34: chunk size 160232 perslab     6
slab class  35: chunk size 200296 perslab     5
slab class  36: chunk size 250376 perslab     4
slab class  37: chunk size 312976 perslab     3
slab class  38: chunk size 391224 perslab     2
slab class  39: chunk size 489032 perslab     2
&lt;4 server listening
&lt;5 server listening
&lt;6 send buffer was 9216, now 7456540
&lt;6 server listening (udp)</pre>
<p>We can easily test that it&#8217;s working.  Leave memcached running in the Terminal, and open a new tab.  Then telnet in like so:</p>
<pre class="brush: plain">$ telnet 127.0.0.1 11211</pre>
<p>If you see the following, you&#8217;re in:</p>
<pre class="brush: plain">Trying ::1...
Connected to localhost.
Escape character is &#039;^]&#039;.</pre>
<p>If we switch back to memcached, we see:</p>
<pre class="brush: plain">&lt;7 new client connection</pre>
<p>In the future, you can launch memcached with the -d option for it to run as a daemon.  If you&#8217;d like memcached to start up automatically, you can set up a launchd plist for the purpose.  The following is a slightly modified version of this <a href="http://gorn.ch/archive/2008/03/13/start-memcached-with-launchd.html" target="_blank">example</a>:</p>
<pre class="brush: xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;memcached&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/local/bin/memcached&lt;/string&gt;
        &lt;string&gt;-l&lt;/string&gt;
        &lt;string&gt;127.0.0.1&lt;/string&gt;
        &lt;string&gt;-u&lt;/string&gt;
        &lt;string&gt;nobody&lt;/string&gt;
        &lt;string&gt;-d&lt;/string&gt;
        &lt;string&gt;-m&lt;/string&gt;
        &lt;string&gt;64&lt;/string&gt;
        &lt;string&gt;-p&lt;/string&gt;
        &lt;string&gt;11211&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/dev/null&lt;/string&gt;
    &lt;key&gt;StandardErrorPath&lt;/key&gt;
    &lt;string&gt;/dev/null&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;</pre>
<p>This file is saved in ~/Library/LaunchAgents/memcached.plist, and will tell Leopard to launch memcached on startup.  It will run as a daemon listening to 127.0.0.1 on port 11211 with a maximum memory size of 64MB.  This is exactly the same as running the following command line:</p>
<pre class="brush: plain">$ memcached -l 127.0.0.1 -u nobody -d -m 64 -p 11211</pre>
]]></content:encoded>
			<wfw:commentRss>http://srsly.me/2009/03/10/memcached-on-mac-os-x-10-5-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My MacVim Setup</title>
		<link>http://srsly.me/2009/03/08/my-macvim-setup/</link>
		<comments>http://srsly.me/2009/03/08/my-macvim-setup/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 02:57:19 +0000</pubDate>
		<dc:creator>Joseph Jaramillo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[text editors]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://srsly.me/?p=111</guid>
		<description><![CDATA[I&#8217;ve long had an interest in Vim, but learning a new text editor is a major endeavor for any developer.  We spend the overwhelming majority of time working in text editors, and like anything else choosing the right tool is important.  After a certain amount of time the tool fades into the background, and using [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve long had an interest in <a title="Vim" href="http://www.vim.org/" target="_blank">Vim</a>, but learning a new text editor is a major endeavor for any developer.  We spend the overwhelming majority of time working in text editors, and like anything else choosing the right tool is important.  After a certain amount of time the tool fades into the background, and using it becomes completely second nature.  I moved away from the <a title="Eclipse" href="http://www.eclipse.org/" target="_blank">Eclipse</a> IDE to <a title="TextMate" href="http://macromates.com/" target="_blank">TextMate</a> when I got into Ruby, and it has seen me through many a project.  With the right bundles installed TextMate is a fantastic tool.</p>
<p>So why use Vim, or more specifically, <a title="MacVim" href="http://code.google.com/p/macvim/" target="_blank">MacVim</a>?  At this point, I still can&#8217;t say.  It&#8217;ll take some time after I&#8217;m used to its paradigm and have built up enough muscle memory for me to be able to say whether or not it&#8217;s better for me.  That being said, I knew that there were a few tools I&#8217;d absolutely need it to have for it to have a chance at competing with TextMate.  Thankfully, Vim has a robust plugin system and a huge user-generated library from which to choose.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-125" title="My MacVim Setup" src="http://srsly.me/wp-content/uploads/2009/03/vim-screenshot.png" alt="My MacVim Setup" width="450" height="314" /></p>
<p>I spent some time using TextMate, taking note of which of its facilities I used most often.  What emerged was something of a blueprint for what I&#8217;d need Vim to either replicate or replace.  The following plugins did the trick:</p>
<ol>
<li><a title="NERDTree" href="http://www.vim.org/scripts/script.php?script_id=1658" target="_blank">NERDTree</a> &#8211; A Project Drawer-like file browser<a href="http://www.vim.org/scripts/script.php?script_id=1658" target="_blank"><br />
</a></li>
<li><a title="FuzzyFinder" href="http://www.vim.org/scripts/script.php?script_id=1984" target="_blank">FuzzyFinder</a> &#8211; A fuzzy-search based file navigation mechanism<a href="http://www.vim.org/scripts/script.php?script_id=1984" target="_blank"><br />
</a></li>
<li><a title="FuzzyFinder TextMate" href="http://github.com/jamis/fuzzyfinder_textmate/tree/master" target="_blank">FuzzyFinder TextMate</a> (<a title="Origin FuzzyFinder TextMate Blog Post" href="http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim" target="_blank">Blog</a>) &#8211; Provides ⌘-T functionality via FuzzyFinder</li>
<li><a title="Rails plugin for Vim" href="http://www.vim.org/scripts/script.php?script_id=1567" target="_blank">Rails.vim</a> &#8211; The Vim equivalent of the Ruby on Rails TextMate bundle<a href="http://www.vim.org/scripts/script.php?script_id=1567" target="_blank"><br />
</a></li>
<li><a title="snippetsEmu" href="http://www.vim.org/scripts/script.php?script_id=1318" target="_blank">snippetsEmu</a> &#8211; Provides tab triggers and other nifty TextMate-like snippet functionality<a href="http://www.vim.org/scripts/script.php?script_id=1318" target="_blank"><br />
</a></li>
</ol>
<p>There&#8217;s clearly a pattern here.  At one point I stopped and asked myself why exactly I was trying to reimplement TextMate in Vim.  The reality is that these tools have a very strong connection with the way I work, and most of them aren&#8217;t particularly unique to TextMate.  The fuzzy-file-search mechanism is something that appears all over the place.  We use it all the time in tools like <a title="LaunchBar" href="http://obdev.at/launchbar" target="_blank">LaunchBar</a> and <a title="QuickSilver" href="http://code.google.com/p/blacktree-alchemy/" target="_blank">QuickSilver</a>.  Rails.vim brings Rails awareness to Vim; all good text editors support extensions like this.  The only thing up there that&#8217;s unique to TextMate is the tab-trigger snippets.  I&#8217;ve got no excuse for that one.  It&#8217;s a really great feature in TextMate, and I think all text editors should have it.</p>
<p>I had some difficulty getting FuzzyFinder TextMate working until I discovered that Jamis had stopped working on it.  It had fallen out of sync with FuzzyFinder, on which it depends.  Tracking down the latest version of FuzzyFinder that was known to work solved the problem.  It looks like there&#8217;s a <a title="sethbc's fuzzyfinder_textmate at master" href="http://github.com/sethbc/fuzzyfinder_textmate/tree/master" target="_blank">fork</a> on GitHub that&#8217;s been brought up to date, but I haven&#8217;t yet tested it.</p>
<p>My <a title="devjj's vim-config at master" href="http://github.com/devjj/vim-config/tree/master" target="_blank">configuration</a> is on GitHub.  If you find any mistakes or have any suggestions for improvement, please feel free to fork it and send a pull request.  I&#8217;m still a Vim noob, but I&#8217;m impressed so far.<a href="http://blog.infinitered.com/entries/show/8" target="_blank"><br />
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://srsly.me/2009/03/08/my-macvim-setup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Use the Right Tool for the Job</title>
		<link>http://srsly.me/2009/03/01/use-the-right-tool-for-the-job/</link>
		<comments>http://srsly.me/2009/03/01/use-the-right-tool-for-the-job/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 04:05:32 +0000</pubDate>
		<dc:creator>Joseph Jaramillo</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://srsly.me/?p=72</guid>
		<description><![CDATA[I had a rather rough week, and that means I have an urge to write.  I sat down to design this blog yesterday afternoon, and have worked pretty much nonstop to get it to where it is at this very moment.  Things are shaping up nicely.
Settling on a blog engine proved somewhat difficult.  The Rubyist [...]]]></description>
			<content:encoded><![CDATA[<p>I had a rather rough week, and that means I have an urge to write.  I sat down to design this blog yesterday afternoon, and have worked pretty much nonstop to get it to where it is at this very moment.  Things are shaping up nicely.</p>
<p>Settling on a blog engine proved somewhat difficult.  The Rubyist in me wanted to stick with a tool built in that language.  If it happened to be a Rails or Merb app, all the better.  The first part of the effort was spent installing Typo and Mephisto, and skinning both of them.  Having converted to <a href="#mce_temp_url#">Haml</a> for my Ruby templating needs, Mephisto&#8217;s use of Liquid was off-putting.  That isn&#8217;t a knock against Liquid so much as it means props for Hampton Catlin&#8217;s awesome work. The Mephisto admin was clean and efficient, but compared to WordPress it was clear which was more advanced.  Typo didn&#8217;t prove much better.</p>
<p>My needs for this blog were fairly simple, and WordPress has been doing just this sort of thing longer than just about anybody.  The tool is fast, elegant, easy to use, and well-maintained.  The only real knock I have for WordPress is having to deal with straight-up PHP templates for skinning.  This is probably exacerbated by the exceptionally poor indentation used in the default templates.  Haml markup is indentation-based, so outputted HTML is perfectly indented.  This makes debugging rendering issues easier.</p>
<p>That being said, this is a blog, and now that it&#8217;s skinned I won&#8217;t need to deal with many templates.  That makes it easy to settle back into the interface itself, which is outstanding.  WordPress just smacks of people sweating the details, and that&#8217;s great to see regardless of language.</p>
<p>There are times when the right tool for the job is in a language or on a platform that you don&#8217;t like.  That&#8217;s WordPress for me.  PHP isn&#8217;t my forté and it leaves a bitter taste in my mouth, but this tool is so good it absolutely puts to rest any argument that any one thing is fundamentally superior to another.  I&#8217;m a Ruby developer through and through, but as much as I love the tools and the language there simply isn&#8217;t a single Ruby blog application with this level of polish.  My needs for a blog weren&#8217;t terribly specific, and I didn&#8217;t need to plug into any backend systems.  The only thing that would have held me back is my own bias, and that would be silly.</p>
<p>If something better than WordPress happens to come along, and it happens to be written in Ruby, I&#8217;ll take a look.  Until that time, WordPress looks like it&#8217;s the right tool for the job.  That should&#8217;ve been a no-brainer.</p>
]]></content:encoded>
			<wfw:commentRss>http://srsly.me/2009/03/01/use-the-right-tool-for-the-job/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
