<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Codeography</title>
	<link href="http://codeography.com/atom.xml" rel="self"/>
	<link href="http://codeography.com/"/>
	<updated>2012-01-20T07:04:16-08:00</updated>
	<id>http://codeography.com/</id>
	<author>
		<name>Christopher Sexton</name>
		<email></email>
	</author>
	
	<entry>
		<title>Navigating the Command Line</title>
		<link href="http://codeography.com/2012/01/13/navigating-the-command-line.html"/>
		<updated>2012-01-13T00:00:00-08:00</updated>
		<id>http://codeography.com/2012/01/13/navigating-the-command-line</id>
		<content type="html">&lt;p&gt;When learning to love the command line, nothing made a bigger difference to me than when I discovered I could edit commands with out pressing and holding the arrow keys. That was just slow and awkward. There is a better way. Really you only need two or three little tricks and you will be in a whole new world of productivity.&lt;/p&gt;

&lt;p&gt;If you can only learn one thing, learn these two keyboard shortcuts:&lt;/p&gt;
&lt;style&gt;
  .key-image { margin-top: 10px; height: 60px; }
  table.keys { vertical-align:top; }
  table.keys h2 { margin-bottom: 0; }
  table.keys, td, th { vertical-align: top; }
  table.keys td.col1 { width:141px; }
&lt;/style&gt;&lt;table class='keys'&gt;
  &lt;tr&gt;
    &lt;td class='col1'&gt;&lt;img class='key-image' src='/images/c-a.png' align='left' /&gt;&lt;/td&gt;
    &lt;td class='col2'&gt;
      &lt;h2&gt;Jump to the beginning&lt;/h2&gt;
      Pressing &lt;code&gt;control-a&lt;/code&gt; will jump the cursor to the beginning of the line.
      &lt;br /&gt;
      Mnemonic: Control-&lt;em&gt;Awesome&lt;/em&gt; I can move back to the beginning with out holding the arrow key.
      &lt;br /&gt;
      Also I find I remember this because the A key is the furthest left key on the home row.
    &lt;/td&gt;
  &lt;/tr&gt;


  &lt;tr&gt;
    &lt;td class='col1'&gt;&lt;img class='key-image' src='/images/c-e.png' align='left' /&gt;&lt;/td&gt;
    &lt;td class='col2'&gt;
      &lt;h2&gt;Jump to the end&lt;/h2&gt;
      Pressing &lt;code&gt;control-e&lt;/code&gt; will jump the cursor to the end of the line.
      &lt;br /&gt;
      Mnemonic: Control-&lt;em&gt;End&lt;/em&gt;
    &lt;/td&gt;
  &lt;/tr&gt;

&lt;/table&gt;
&lt;p&gt;Now, take a few minutes to go give those a try. I&amp;#8217;ll wait.&lt;/p&gt;

&lt;p&gt;Want some more? Rad. But a little caution if you are just learning these things: just pick a couple and find ways to use them until they are second nature. Practice. If you think you are ready for more, here you go. I think these are the next most useful:&lt;/p&gt;
&lt;table class='keys'&gt;
  &lt;tr&gt;
    &lt;td class='col1'&gt;&lt;img class='key-image' src='/images/c-w.png' align='left' /&gt;&lt;/td&gt;
    &lt;td class='col2'&gt;
      &lt;h2&gt;Delete Back a Word&lt;/h2&gt;
      Pressing &lt;code&gt;control-w&lt;/code&gt; will delete the word before the cursor.
      &lt;br /&gt;
      Mnemonic: Control-&lt;em&gt;W&lt;/em&gt;hy did I type that &lt;em&gt;Word&lt;/em&gt;
    &lt;/td&gt;
  &lt;/tr&gt;


  &lt;tr&gt;
    &lt;td class='col1'&gt;&lt;img class='key-image' src='/images/c-k.png' align='left' /&gt;&lt;/td&gt;
    &lt;td class='col2'&gt;
      &lt;h2&gt;Delete to the End&lt;/h2&gt;
      Pressing &lt;code&gt;control-k&lt;/code&gt; will delete from the cursor to the end of the line
      &lt;br /&gt;
      Mnemonic: Control-&lt;em&gt;Kill&lt;/em&gt; to the end of the line
    &lt;/td&gt;
  &lt;/tr&gt;


  &lt;tr&gt;
    &lt;td&gt;&lt;img class='key-image' src='/images/c-u.png' align='left' /&gt;&lt;/td&gt;
    &lt;td&gt;
      &lt;h2&gt;Delete to the Beginning&lt;/h2&gt;
      Pressing &lt;code&gt;control-u&lt;/code&gt; will delete from the cursor to the beginning of the line
      &lt;br /&gt;
      Mnemonic: Control-&lt;em&gt;Uhh&lt;/em&gt; that wasn't right
    &lt;/td&gt;
  &lt;/tr&gt;

&lt;/table&gt;
&lt;p&gt;I think these are the most critical shortcuts to learn, and have made life on the command line damn nice.&lt;/p&gt;

&lt;h2 id='a_bit_about_input_modes'&gt;A Bit About Input Modes&lt;/h2&gt;

&lt;p&gt;Really I should end this post here, but am somehow compelled to mention this thing called input modes.&lt;/p&gt;

&lt;p&gt;There are two input modes that a command line will use: vi or emacs.&lt;/p&gt;

&lt;p&gt;The examples above assume you are using emacs mode for your shell. This is the default for bash and most other shells. If you are having problems with them you may need to set the input mode. In bash you can simply run &lt;code&gt;set -o emacs&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I can hear you asking &amp;#8220;But wait, you are a vim guy, why do you use emacs mode for your shell?&amp;#8221;&lt;/p&gt;

&lt;p&gt;Well, it wasn&amp;#8217;t an easy choice. I thought I would like vi mode on the command line. And I tried to use it. I wanted to want to. But in the end it was just never felt right.&lt;/p&gt;

&lt;p&gt;My reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It is the default on most systems. Nice to open a new term on a strange server and have things Just Work™.&lt;/li&gt;

&lt;li&gt;Anywhere libreadline is used these things will work. Basically this is the line editing library that most terminal based apps will use. This includes your shell, bash, irb, ipython, irc clients and the like.&lt;/li&gt;

&lt;li&gt;I use a Mac, and there is a decent overlap between the default keyboard shortcuts in Cocoa and emacs mode.&lt;/li&gt;

&lt;li&gt;On the command line I can quickly edit the command in vim by mashing &lt;code&gt;Control-X Control-E&lt;/code&gt; or running &lt;code&gt;fc&lt;/code&gt;.&lt;/li&gt;

&lt;li&gt;And probably the most critical reason is I have the &lt;a href='https://github.com/csexton/viceroy/blob/master/plugin/mappings.vim#L14'&gt;exact same keybindings&lt;/a&gt; in Vim&amp;#8217;s insert and command modes.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id='ignore_advice_from_blog_articles'&gt;Ignore Advice from Blog Articles&lt;/h2&gt;

&lt;p&gt;The only thing you should do is pick some tools and learn them. Don&amp;#8217;t worry about what some random blog article says. Don&amp;#8217;t worry about those kids on irc demanding you use zsh. Don&amp;#8217;t worry about editors &amp;#8211; learn something. It will all translate in some way, won&amp;#8217;t be wasted effort. Most important thing you can do as a developer is train how to use your tools.&lt;/p&gt;

&lt;h2 id='what_do_you_use'&gt;What do you use?&lt;/h2&gt;

&lt;p&gt;What command line tricks do you use to make your day happier?&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Making ARC and non-ARC files play nice together</title>
		<link href="http://codeography.com/2011/10/10/making-arc-and-non-arc-play-nice.html"/>
		<updated>2011-10-10T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/10/10/making-arc-and-non-arc-play-nice</id>
		<content type="html">&lt;p&gt;If you want to exclude a file from being compiled with ARC you can do so by setting a flag on the .m file:&lt;/p&gt;

&lt;p&gt;Click the Project -&amp;gt; Build Phases Tab -&amp;gt; Compile Sources Section -&amp;gt; Double Click on the file name&lt;/p&gt;

&lt;p&gt;Then add &lt;code&gt;-fno-objc-arc&lt;/code&gt; to the popup window.&lt;/p&gt;

&lt;p&gt;Likewise, if you want to include a file in ARC, you can use the &lt;code&gt;-fobjc-arc&lt;/code&gt; flag.&lt;/p&gt;
&lt;img src='/images/arc-compiler-flag.png' alt='Xcode Screen Shot' style='width: 100%;' /&gt;
&lt;p&gt;See the &lt;a href='http://clang.llvm.org/docs/AutomaticReferenceCounting.html'&gt;clang docs&lt;/a&gt; for more details.&lt;/p&gt;

&lt;p&gt;A helpful trick is to use the &lt;code&gt;__has_feature&lt;/code&gt; language extension to throw errors when this is not set properly.&lt;/p&gt;

&lt;p&gt;Enforce a file is ARC:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#if ! __has_feature(objc_arc)
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag
#endif&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The inverse:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#if __has_feature(objc_arc)
#error This file cannot be compiled with ARC. Either turn off ARC for the project or use -fno-objc-arc flag
#endif&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This was adapted from a &lt;a href='http://lists.apple.com/archives/objc-language/2011/Aug/msg00036.html'&gt;post by Greg Parker&lt;/a&gt; on the on the Objective-C mailing list. He goes on to point out the following:&lt;/p&gt;

&lt;p&gt;You should be careful with the interface to your shared code such that ARC and non-ARC clients can use it freely.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Conform to Cocoa&amp;#8217;s memory management conventions even though an all-ARC or no-ARC project would not require it&lt;/li&gt;

&lt;li&gt;Don&amp;#8217;t use object pointers inside C structs&lt;/li&gt;

&lt;li&gt;Avoid CF types&lt;/li&gt;
&lt;/ul&gt;</content>
	</entry>
	
	<entry>
		<title>Prevent Xcode from opening extra projects</title>
		<link href="http://codeography.com/2011/10/05/prevent-xcode-from-opening-extra-projects.html"/>
		<updated>2011-10-05T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/10/05/prevent-xcode-from-opening-extra-projects</id>
		<content type="html">&lt;p&gt;Insistent I don&amp;#8217;t want persistence.&lt;/p&gt;

&lt;p&gt;I&amp;#8217;ve been a little annoyed with Xcode on Lion. Every time I open a project it also opens the last project I was working on. This might be fine if I was only working on one project &amp;#8211; but recently I have been working on Captured in the evenings, and Zippy&amp;#8217;s iPhone app during the day. I don&amp;#8217;t want to open the project for Captured when I get to work in the morning. Plus it is particularly frustrating when one of those projects is a workspace, if you create a new project Xcode insists on adding it to the current workspace.&lt;/p&gt;

&lt;p&gt;The solution: fix my &lt;code&gt;xcode&lt;/code&gt; script, by passing in a user defaults flag.&lt;/p&gt;

&lt;p&gt;I have been using a helper function to load xcode from the command line for a while now, and really it is the primary way that I open a project. Maybe I am in minority for Cocoa developers, but I live on the command line &amp;#8211; so this is better for me.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env ruby
f = []
f.concat Dir[&amp;quot;*.xcworkspace&amp;quot;]
f.concat Dir[&amp;quot;*.xcodeproj&amp;quot;]

if f.length &amp;gt; 0
  puts &amp;quot;opening #{f.first}&amp;quot;
  `open -a /Developer/Applications/Xcode.app #{f.first} --args -ApplePersistenceIgnoreState YES`
  exit 0
end

puts &amp;quot;No Xcode projects found&amp;quot;
exit 1&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The trick is the &lt;code&gt;ApplePersistenceIgnoreState&lt;/code&gt; option passed in to Xcode, this overrides the NSUserDefault for the app persistence.&lt;/p&gt;

&lt;p&gt;If you want to use this, just create a file &lt;code&gt;xcode&lt;/code&gt; somewhere in your path and then set it to be executable &lt;code&gt;chmod +x xcode&lt;/code&gt;. Then opening project is as simple as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd path/to/proj
xcode&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Refreshing.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Project specific git author, without the gas pains</title>
		<link href="http://codeography.com/2011/08/05/project-specific-git-author.html"/>
		<updated>2011-08-05T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/08/05/project-specific-git-author</id>
		<content type="html">&lt;p&gt;I heard about a git-related project called GAS, the &lt;a href='https://github.com/walle/gas'&gt;Git Author Switcher&lt;/a&gt;, on that &lt;a href='http://ruby5.envylabs.com/'&gt;Ruby5&lt;/a&gt; podcast&amp;#8211;and initially I was intrigued. But once I thought about it, I think there is a better way to handle this. With just plain ole git.&lt;/p&gt;

&lt;p&gt;Why don&amp;#8217;t I like having GAS? Well, it changes the author globally &amp;#8211; and you have to remember to switch it up when changing projects. I would prefer to set it on a per project basis, then forget about it.&lt;/p&gt;

&lt;p&gt;So my setup is to put my personal user and email (i.e. the one I use on github) in the global config, which most anyone using git should have setup already:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git config --global user.name &amp;quot;Chris&amp;quot;
git config --global user.email &amp;quot;chris@personal.dev&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then in my work projects, I use a different email address, so I change it in that repo by running:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git config user.email &amp;quot;chris@work.dev&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Luckily, I don&amp;#8217;t use a different name at work, so there is no need to override that setting. Although I could if I really wanted to.&lt;/p&gt;

&lt;p&gt;If you have to to this frequently, I think a simple git alias is pretty nice for streamlining this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git config --global alias.workprofile &amp;#39;config user.email &amp;quot;chris@work.dev&amp;quot;&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then when you clone a new work project, just run &lt;code&gt;git workprofile&lt;/code&gt; and it will be configured to use that email.&lt;/p&gt;

&lt;p&gt;Admittedly, if you are using a shared machine or are pairing (or pairing on a shared machine), then GAS might be exactly what you need. Just use the right tool for the job.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Multiple Dropboxen on Mac the right way</title>
		<link href="http://codeography.com/2011/07/07/multiple-dropboxen-on-mac.html"/>
		<updated>2011-07-07T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/07/07/multiple-dropboxen-on-mac</id>
		<content type="html">&lt;p&gt;I really didn&amp;#8217;t like the way other people explained setting up multiple dropboxen on a mac, which involved creating multiple directories and files, incliuding, of all things, faux app bundles. This bugged me, so I made a new launchd.plist and drive it all from that one config file.&lt;/p&gt;

&lt;p&gt;First, create a file in &lt;code&gt;~/Library/LaunchAgents/com.dropbox.alt.plist&lt;/code&gt; with the following contents, updating the USERNAME for your username.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC &amp;quot;-//Apple//DTD PLIST 1.0//EN&amp;quot; &amp;quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&amp;quot;&amp;gt;
&amp;lt;plist version=&amp;quot;1.0&amp;quot;&amp;gt;
  &amp;lt;dict&amp;gt;
    &amp;lt;key&amp;gt;Label&amp;lt;/key&amp;gt;
    &amp;lt;string&amp;gt;com.dropbox.alt&amp;lt;/string&amp;gt;
    &amp;lt;key&amp;gt;LowPriorityIO&amp;lt;/key&amp;gt;
    &amp;lt;true/&amp;gt;
    &amp;lt;key&amp;gt;EnvironmentVariables&amp;lt;/key&amp;gt;
    &amp;lt;dict&amp;gt;
      &amp;lt;key&amp;gt;HOME&amp;lt;/key&amp;gt;
      &amp;lt;string&amp;gt;/Users/USERNAME/.dropbox-alt&amp;lt;/string&amp;gt;
    &amp;lt;/dict&amp;gt;
    &amp;lt;key&amp;gt;ProgramArguments&amp;lt;/key&amp;gt;
    &amp;lt;array&amp;gt;
      &amp;lt;string&amp;gt;/Applications/Dropbox.app/Contents/MacOS/Dropbox&amp;lt;/string&amp;gt;
    &amp;lt;/array&amp;gt;
    &amp;lt;key&amp;gt;RunAtLoad&amp;lt;/key&amp;gt;
    &amp;lt;true/&amp;gt;
  &amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Second, run the following commands:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;launchctl load ~/Library/LaunchAgents/com.dropbox.alt.plist
launchctl start com.dropbox.alt&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The Dropbox dialog will appear. On the &amp;#8220;Setup Type&amp;#8221; screen of their installer make sure you change the folder to a custom location that makes sense for you (otherwise it will put it in ~/.dropbox-alt/Dropbox).&lt;/p&gt;

&lt;p&gt;&lt;img src='/images/dropbox01.png' alt='Dropbox Installer' /&gt;&lt;/p&gt;

&lt;p&gt;Done. No faux app bundles. Everything is controled by launchd, just the way it should be.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Dynamic fixed width layout with CSS</title>
		<link href="http://codeography.com/2011/06/14/dynamic-fixed-width-layout-with-css.html"/>
		<updated>2011-06-14T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/06/14/dynamic-fixed-width-layout-with-css</id>
		<content type="html">&lt;img src='/images/dynamic-layout-sm.png' align='right' alt='iPhone and iPad' /&gt;
&lt;p&gt;Recently &lt;a href='http://cary.blog.greenfrylabs.com/'&gt;Cary&lt;/a&gt; and I have been trying to optimize our site for different devices and ran in to some issues. Particularly if we wanted to have a site that would work well on an iPhone it was comically large on the iPad. And the awesome iPad version was teeny-tiny on the phone. With more digging into the viewport meta tags there was no good way to select a tablet layout vs. a phone layout &amp;#8211; you just have the one viewport and that&amp;#8217;s it. The only decent way to determine which device you have is to set the viewport&amp;#8217;s width to be &lt;code&gt;device-width&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width&amp;quot; /&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But if you do that you are stuck at the native widths for the devices. You have the default 320px for portrait iPhone or 1024px for landscape iPad, and a number of other variations.&lt;/p&gt;

&lt;p&gt;That all well and good if you want to design specifically for those viewport sizes &amp;#8211; but if you want to set a custom viewport for the phone and for a tablet, which is what we wanted, then a little more trickery is involved. But the end result was really very slick and, stay with me here, maintainable.&lt;/p&gt;

&lt;p&gt;Something I was calling &amp;#8220;Dynamic, stepwise, fixed-with layout.&amp;#8221;&lt;/p&gt;

&lt;p&gt;To pull this off you need to things:&lt;/p&gt;

&lt;h3 id='set_the_viewport_for_your_device'&gt;Set the viewport for your device&lt;/h3&gt;

&lt;p&gt;Update the viewport via javascript in the &lt;code&gt;head&lt;/code&gt; of the HTML:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width&amp;quot; /&amp;gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;
  if (window.innerWidth &amp;lt; 500) {
    // Phone
    document.querySelector(&amp;quot;meta[name=viewport]&amp;quot;).setAttribute(&amp;#39;content&amp;#39;, &amp;#39;width=480&amp;#39;);
  }
  else if (window.innerWidth &amp;lt; 650) {
    // Tablet
    document.querySelector(&amp;quot;meta[name=viewport]&amp;quot;).setAttribute(&amp;#39;content&amp;#39;, &amp;#39;width=670&amp;#39;);
  }
&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This has the viewport default to &lt;code&gt;device-width&lt;/code&gt; which lets us grab the size of the window, and set it to our custom size.&lt;/p&gt;

&lt;p&gt;I put this JS directly in the header, and have it evaluate immediatly because I don&amp;#8217;t want the screen to &amp;#8216;jump&amp;#8217; around after it loads.&lt;/p&gt;

&lt;h3 id='add_custom_styles_for_that_viewport'&gt;Add custom styles for that viewport&lt;/h3&gt;

&lt;p&gt;Once I have that new viewport size I can use CSS media queries to style the page for the devices.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@media screen and (max-width: 500px) {
  /* Phone Styles */
}
@media screen and (max-width: 700px) {
  /* Tablet Styles */
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The really cool thing about this approach is you can dynamically set the width of your content to an arbitrary value based on the device size.&lt;/p&gt;

&lt;p&gt;Added bonus, as you resize the browser window on your computer you will also get the custom layouts. Which is particularly nice for testing.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href='#' onclick='window.open(&amp;apos;/examples/dynamic-layout.html&amp;apos;,&amp;apos;linkname&amp;apos;,&amp;apos;height=480, width=502,scrollbars=no&amp;apos;)'&gt;Example&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Zsh trick: restart pow with command completion</title>
		<link href="http://codeography.com/2011/05/10/zsh-trick-restart-pow-with-command-completion.html"/>
		<updated>2011-05-10T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/05/10/zsh-trick-restart-pow-with-command-completion</id>
		<content type="html">&lt;p&gt;Recently I started using the zero configuraiton web server &lt;a href='http://pow.cx/'&gt;pow&lt;/a&gt; from the good folks at 37signals and absolutly love it. I really like how restarting the server is as simple as touching &lt;code&gt;restart.txt&lt;/code&gt; to the &lt;code&gt;tmp&lt;/code&gt; directory. However I have been working on a feature that requires frequent restarts of the server and found it repetitive. Since I was being lazy about typing in the path to &lt;code&gt;restart.txt&lt;/code&gt; I decided to automate it a little. And add command completion.&lt;/p&gt;

&lt;p&gt;Got those with the following zsh script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;kapow(){
  touch ~/.pow/$1/tmp/restart.txt;
  if [ $? -eq 0 ]; then; echo &amp;quot;pow: restarting $1&amp;quot; ; fi
}
compctl -W ~/.pow -/ kapow&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This gives me a &lt;code&gt;kapow&lt;/code&gt; command that will restart the app for me.&lt;/p&gt;

&lt;p&gt;I also put it up in a &lt;a href='https://gist.github.com/965032'&gt;gist&lt;/a&gt;, if you would like to fork it and make changes.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Quickly navigate your projects in zsh, with tab completion</title>
		<link href="http://codeography.com/2011/05/01/quickly-navigate-your-projects-in-zsh-with-tab-completion.html"/>
		<updated>2011-05-01T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/05/01/quickly-navigate-your-projects-in-zsh-with-tab-completion</id>
		<content type="html">&lt;p&gt;I find my self having to frequently jump between projects in the terminal, or opening new tabs in Terminal and needing to navigate to the project I am working on. I know there are some other tricks for doing this, some of the optimized for certain cases (like a new tab in the current directory), but I found this to be the most useful for how I work.&lt;/p&gt;

&lt;p&gt;Since I keep all my projects in a directory called &lt;code&gt;~/src&lt;/code&gt; I created a function called &lt;code&gt;src&lt;/code&gt; that would get me there quickly, so instead of this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd ~/src/my-web-site&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I can do this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ src my-seb-site&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, that&amp;#8217;s nice and all, but with out tab completion I would never use it. Turns out that is stupid simple to solve with zsh&amp;#8217;s rad completion system. My final solution looks something like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;src(){cd ~/src/$1;}
compctl -W ~/src -/ src&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Just drop that into your &lt;code&gt;~/.zshrc&lt;/code&gt; file and you should be good to go. Feel free to replace &lt;code&gt;src&lt;/code&gt; with what ever you name your projects directory (Projects, source, awesome-stuff).&lt;/p&gt;

&lt;p&gt;If you have not enabled zsh&amp;#8217;s completion somewhere else in your configs, you may need to add the following before the compctl call:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;autoload -U compinit
compinit -i&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course, if that&amp;#8217;s the case, I recommend installing &lt;a href='https://github.com/robbyrussell/oh-my-zsh'&gt;Oh My Zsh&lt;/a&gt; and getting all sorts of goodness.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Keeping track of deploys: Make an about.txt with Capistrano</title>
		<link href="http://codeography.com/2011/04/27/keeping-track-of-deploys-make-an-about.txt-with-capistrano.html"/>
		<updated>2011-04-27T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/04/27/keeping-track-of-deploys-make-an-about.txt-with-capistrano</id>
		<content type="html">&lt;p&gt;I wrote this for an app couple years ago and needed it agian &amp;#8211; so I went and dug it up. I am certinan could be done in a more elegent way, but this works well and gives the information I needed about each deploy. Plus I know that both PM and QA folks understand how this works with very minimal guidence. Makes triaging issues go much smoother.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;namespace :deploy do
  desc &amp;quot;Create about and revision files.&amp;quot;
  task :after_update_code, :roles =&amp;gt; :app do
    run &amp;quot;echo \&amp;quot;Version Info\&amp;quot; &amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;============\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;Version: `cat #{release_path}/VERSION`\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;Deploy Date: `date`\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;cd #{release_path} &amp;amp;&amp;amp; echo \&amp;quot;Ref: `git rev-parse --short HEAD`\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;Branch: #{revision}\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;Installer Info: see /download/about.txt\&amp;quot; &amp;gt;&amp;gt; #{release_path}/public/about.txt&amp;quot;
    run &amp;quot;echo \&amp;quot;#{revision}\&amp;quot; &amp;gt; #{release_path}/public/revision.txt&amp;quot;
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can find the gist up on &lt;a href='https://gist.github.com/941035'&gt;github&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Basics of RubyGems Slides</title>
		<link href="http://codeography.com/2011/04/01/basics-of-rubygems-slides.html"/>
		<updated>2011-04-01T00:00:00-07:00</updated>
		<id>http://codeography.com/2011/04/01/basics-of-rubygems-slides</id>
		<content type="html">&lt;p&gt;My slides from RubyNation are now up on &lt;a href='http://basicsofrubygems.heroku.com'&gt;heroku&lt;/a&gt; and the examples are on &lt;a href='http://github.com/csexton'&gt;github&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Define Your Inner Foo</title>
		<link href="http://codeography.com/2011/03/11/define-your-inner-foo.html"/>
		<updated>2011-03-11T00:00:00-08:00</updated>
		<id>http://codeography.com/2011/03/11/define-your-inner-foo</id>
		<content type="html">&lt;p&gt;Recently attended a great talk by &lt;a href='http://paulbarry.com/'&gt;Paul Barry&lt;/a&gt; at the &lt;a href='http://www.meetup.com/dcruby/'&gt;DCRUG&lt;/a&gt;. During his talk, he wondered off into defining a method in a method.&lt;/p&gt;

&lt;p&gt;This was really cool.&lt;/p&gt;

&lt;p&gt;I took some time playing with this, and after showing a few colleagues, I had to write this up. I encourage you to fire up IRB and try it your self. This is probably not something you would actually want to do in a project, but once you know about it then you will be tempted to find a problem for this solution.&lt;/p&gt;

&lt;p&gt;define_your_inner_foo.rb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class DefineYourInnerFoo
  def foo
    def foo
      def foo
        &amp;quot;Zirbert&amp;quot;
      end
      &amp;quot;Zaz&amp;quot;
    end
    &amp;quot;Zing&amp;quot;
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;irb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; load &amp;#39;define_your_inner_foo.rb&amp;#39;
&amp;gt;&amp;gt; f = DefineYourInnerFoo.new
&amp;gt;&amp;gt; f.foo #=&amp;gt; &amp;#39;Zing&amp;#39;
&amp;gt;&amp;gt; f.foo #=&amp;gt; &amp;#39;Zaz&amp;#39;
&amp;gt;&amp;gt; f.foo #=&amp;gt; &amp;#39;Zirbert&amp;#39;
&amp;gt;&amp;gt; f.foo #=&amp;gt; &amp;#39;Zirbert&amp;#39;
&amp;gt;&amp;gt; g = DefineYourInnerFoo.new
&amp;gt;&amp;gt; g.foo #=&amp;gt; &amp;#39;Zirbert&amp;#39;
&amp;gt;&amp;gt; g.foo #=&amp;gt; &amp;#39;Zirbert&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A slightly more contrived example:&lt;/p&gt;

&lt;p&gt;animal.rb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Animal
  def speak
    &amp;quot;Hello, I am a Animal&amp;quot;
  end
  def be_dog
    def speak
      &amp;quot;Woof&amp;quot;
    end
  end
  def be_bird
    def speak
      &amp;quot;Tweet-a-leet&amp;quot;
    end
  end
  def be_whale
    def speak
      &amp;quot;HeeeeeeiiilllllllloooooooooOOOOOOooo....oooooOOOOoo&amp;quot;
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;irb:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; load &amp;#39;animal.rb&amp;#39; #=&amp;gt; true
&amp;gt;&amp;gt; a = Animal.new #=&amp;gt; #&amp;lt;Animal:0x00000101126900&amp;gt;
&amp;gt;&amp;gt; a.speak #=&amp;gt; &amp;quot;Hello, I am a Animal&amp;quot;
&amp;gt;&amp;gt; a.be_dog #=&amp;gt; nil
&amp;gt;&amp;gt; a.speak #=&amp;gt; &amp;quot;Woof&amp;quot;
&amp;gt;&amp;gt; a.be_bird #=&amp;gt; nil
&amp;gt;&amp;gt; a.speak #=&amp;gt; &amp;quot;Tweet-a-leet&amp;quot;
&amp;gt;&amp;gt; b = Animal.new #=&amp;gt; #&amp;lt;Animal:0x000001010eeeb0&amp;gt;
&amp;gt;&amp;gt; b.speak #=&amp;gt; &amp;quot;Tweet-a-leet&amp;quot;
&amp;gt;&amp;gt; b.be_whale #=&amp;gt; nil
&amp;gt;&amp;gt; a.speak #=&amp;gt; &amp;quot;HeeeeeeiiilllllllloooooooooOOOOOOooo....oooooOOOOoo&amp;quot;&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Focus on a test in Vim</title>
		<link href="http://codeography.com/2011/02/14/focus-on-a-test-in-vim.html"/>
		<updated>2011-02-14T00:00:00-08:00</updated>
		<id>http://codeography.com/2011/02/14/focus-on-a-test-in-vim</id>
		<content type="html">&lt;p&gt;I have found myself in the situation where I would have Vim running in one window, and a terminal open on the other monitor with my tests. And noticed I was constantly dancing across the keyboard &lt;code&gt;⌘-tab;⌃-p;↩;⌘-tab&lt;/code&gt; (switch windows to Terminal; previous command; enter; switch windows to Vim). Of course this muscle memory was broken when I switched to my browser in between. I wanted to automate this.&lt;/p&gt;

&lt;p&gt;I could use autotest, but our test suite is slow to start up and I wanted to focus on one test.&lt;/p&gt;

&lt;p&gt;I could run that test within Vim, but MacVim does not show the color escapes when running a command, plus it blocks my editing while I wait for the tests to run.&lt;/p&gt;

&lt;p&gt;I could use Vim in the terminal, but I like my ⌘ key mappings and colors.&lt;/p&gt;

&lt;p&gt;My solution:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run the command from Vim in the background and redirect the output to a file&lt;/li&gt;

&lt;li&gt;Tail the log in Terminal&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to do it:&lt;/p&gt;

&lt;p&gt;Run your test in Vim, the line I would use is something like this (just replace the command bit with the one you want to run):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map &amp;lt;D-r&amp;gt; :silent execute &amp;quot;!ruby test/unit/post_test.rb &amp;amp;&amp;gt; /tmp/vim.log &amp;amp;&amp;quot; &amp;lt;cr&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And tail the logs:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ tail -f /tmp/vim.log&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now when ever I press &lt;code&gt;⌘-r&lt;/code&gt; I can keep on tinkering with the code while the tests run on the other monitor.&lt;/p&gt;

&lt;p&gt;I don&amp;#8217;t keep that command in my &lt;code&gt;.vimrc&lt;/code&gt; file because I am constantly going back and changing the command &amp;#8211; this has become a macro that I change around as I am focusing on different parts of my code.&lt;/p&gt;

&lt;p&gt;Protip: use &lt;code&gt;q:&lt;/code&gt; to interactively edit and run past Vim commands.&lt;/p&gt;

&lt;p&gt;Beauty of this is it works on any command, in any language I am programming in.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Deploying from your current branch with Capistrano</title>
		<link href="http://codeography.com/2010/12/09/deploying-from-your-current-branch-with-capistrano.html"/>
		<updated>2010-12-09T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/12/09/deploying-from-your-current-branch-with-capistrano</id>
		<content type="html">&lt;p&gt;In some of the Rails projects I have worked on, I have found my self having to juggle multiple environments and often want to shuffle around which branch is deployed to which environment. I use Capistrano Multistage to handle all the different environments, but didn&amp;#8217;t want to have to edit the deploy configuration every time I wanted to deploy. So I came up with a way to deploy from whatever my current local branch. Assuming this branch is on the remote git server, Capistrano would deploy from there.&lt;/p&gt;

&lt;p&gt;In your &lt;code&gt;config/deploy.rb&lt;/code&gt; file, add&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Bonus! Colors are pretty!
def red(str)
  &amp;quot;\e[31m#{str}\e[0m&amp;quot;
end

# Figure out the name of the current local branch
def current_git_branch
  branch = `git symbolic-ref HEAD 2&amp;gt; /dev/null`.strip.gsub(/^refs\/heads\//, &amp;#39;&amp;#39;)
  puts &amp;quot;Deploying branch #{red branch}&amp;quot;
  branch
end

# Set the deploy branch to the current branch
set :branch, current_git_branch&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The really cool thing about this is how intuitive it is to use. Goes something like this:&lt;/p&gt;

&lt;p&gt;PM: Hey, can you deploy feature-x to staging! NOW! Me: K, &lt;code&gt;git checkout feature-x &amp;amp;&amp;amp; cap deploy staging&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That just feels natural.&lt;/p&gt;

&lt;p&gt;On other alternative was to setup a remote branch in git that matches each environment, and go a &lt;code&gt;git reset --hard&lt;/code&gt; when you want to change things around. But with as often as we were redeploying that seemed burdensome.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Most important configuration on a Mac</title>
		<link href="http://codeography.com/2010/12/02/remap-capslock-to-control-on-a-mac.html"/>
		<updated>2010-12-02T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/12/02/remap-capslock-to-control-on-a-mac</id>
		<content type="html">&lt;p&gt;One of the most important things you can do on a mac is remap caps lock to control. Sure, I am a little over zealous about this topic, but I really feel that this can make a huge diffrence to people who use modifier keys alot. And if you use a Mac properly one of the first things you should set out to learn are the keyboard shortcuts to perform you commmon tasks.&lt;/p&gt;

&lt;p&gt;&lt;img src='/media/remap-caps-1.png' alt='System Prefrences' /&gt;&lt;/p&gt;

&lt;p&gt;Open system prefrences and click on Keyboard.&lt;/p&gt;

&lt;p&gt;&lt;img src='/media/remap-caps-2.png' alt='Keyboard Prefrences' /&gt;&lt;/p&gt;

&lt;p&gt;Click on the &amp;#8216;Modifier Keys&amp;#8217; button.&lt;/p&gt;

&lt;p&gt;&lt;img src='/media/remap-caps-3.png' alt='Modifier Key Settings' /&gt;&lt;/p&gt;

&lt;p&gt;On the first dropdown, the one for Caps Lock&lt;/p&gt;

&lt;p&gt;&lt;img src='/media/remap-caps-4.png' alt='Modifier Options Dropdown' /&gt;&lt;/p&gt;

&lt;p&gt;Set it to be Control.&lt;/p&gt;

&lt;p&gt;Why am I so over enthusiastic about this? Mostly because I use to get wrist pain in my left hand and nosiced I was straining to contort my hand to press common keys like &amp;#60;Control&amp;#62;-A, which is got to beginning of line on OS-X (and in emacs/terminal/anywhere awesome). Suddenly this became easy and quick. Way better faster and easier on my wrist.&lt;/p&gt;

&lt;p&gt;Added bonus (as if I could pick just one added bonus): Launch Bar uses &amp;#60;Control&amp;#62;-J and &amp;#60;Control&amp;#62;-K to act as up and down. This alone is one producitivity hack that speeds up many common tasks for me.&lt;/p&gt;

&lt;p&gt;Give it a shot, make is muscle memory and you won&amp;#8217;t want to go back.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Conditionally Colorful Test Unit</title>
		<link href="http://codeography.com/2010/11/02/conditionally-colorful-test-unit.html"/>
		<updated>2010-11-02T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/11/02/conditionally-colorful-test-unit</id>
		<content type="html">&lt;p&gt;I like to use the redgreen gem to make my tests colorful, but hardly want to make this a hard requirement to work with the project, so I tend to add this one-liner to the top of test_helper.rb &amp;#8211; now I get red and green output but the other guys on the team don&amp;#8217;t have to deal with installing the gem.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;begin; require &amp;#39;redgreen&amp;#39;; rescue Exception=&amp;gt;e;end&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Zip for Distribution: The missing build step in Xcode</title>
		<link href="http://codeography.com/2010/09/25/the-missing-build-step-in-xcode.html"/>
		<updated>2010-09-25T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/09/25/the-missing-build-step-in-xcode</id>
		<content type="html">&lt;p&gt;I have worked on a couple teams that have submitted iPhone Apps to the iTunes store, however I had never gone through the process on my own until this week. Well, turns out you need to use Apple&amp;#8217;s &amp;#8220;Application Loader.app&amp;#8221; to submit your app. So I fired it up, and was unable to select my .app bundle. This confused me, and the documentation probably mentions how to do this, but I just took a swing in the dark and zipped the file. This worked.&lt;/p&gt;

&lt;p&gt;While right clicking on the file and selecting &amp;#8220;compress&amp;#8221; is pretty easy, I also had to rename my file to remove any spaces. Well this has become too many steps for any self respecting programmer. My solution is a custom post build phase:&lt;/p&gt;

&lt;p&gt;&lt;img src='/images/xcode-add-custom-build-phase.png' alt='Custom Build Phase Screenshot' /&gt;&lt;/p&gt;

&lt;p&gt;Then I add the following script (making sure the &lt;code&gt;shell&lt;/code&gt; is set to /bin/sh):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# We only want to build the zip file when we build for distribution
if [ &amp;quot;$CONFIGURATION&amp;quot; = &amp;quot;Distribution&amp;quot; ]
then
   # Create a short name with no spaces and remove the &amp;quot;.app&amp;quot; from the end
   SHORT_NAME=`echo &amp;quot;$EXECUTABLE_FOLDER_PATH&amp;quot; | sed &amp;#39;s/ //g&amp;#39; | sed &amp;#39;s/\.app$//g&amp;#39;`

   # Zip the file
   zip -u -1 &amp;quot;$TARGET_BUILD_DIR/$SHORT_NAME.zip&amp;quot; &amp;quot;$TARGET_BUILD_DIR/$EXECUTABLE_FOLDER_PATH&amp;quot;

   # Tell us what happened
   echo &amp;quot;Built distribution zip file: $TARGET_BUILD_DIR/$SHORT_NAME.zip&amp;quot;
fi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At this point I like to right click on the build step and rename it to something useful, something like &amp;#8220;Zip App Bundle for Distribution&amp;#8221;, but hey, that&amp;#8217;s me.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>How to make Vim a first class CSS editor</title>
		<link href="http://codeography.com/2010/08/02/how-to-make-vim-a-first-class-css-editor.html"/>
		<updated>2010-08-02T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/08/02/how-to-make-vim-a-first-class-css-editor</id>
		<content type="html">&lt;p&gt;I have always struggled with CSS in vim. Seems like it would be easy to implement compared to auto-complete in other filetypes.&lt;/p&gt;

&lt;p&gt;All I really wanted to have was some sort of reminder on what was valid properties and where to put the positional arguments when I am using the shorthand properties.&lt;/p&gt;

&lt;p&gt;Today I discovered the two things I needed to fix this. SnipMate and Omnicomplete&lt;/p&gt;

&lt;h2 id='snipmate'&gt;SnipMate&lt;/h2&gt;

&lt;p&gt;I forked the basic SnipMate and added some simple snippets for CSS. If you want to use it, then you can install from my GitHub repo directly&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone git://github.com/csexton/snipmate.vim.git
cd snipmate.vim
cp -R * ~/.vim&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or you can just grab the &lt;a href='http://github.com/csexton/snipmate.vim/blob/master/snippets/css.snippets'&gt;css.snippets&lt;/a&gt; file and add it to your .vim/snippets directly.&lt;/p&gt;

&lt;h2 id='omnicomplete'&gt;Omnicomplete&lt;/h2&gt;

&lt;p&gt;This is built in to Vim 7, I just didn&amp;#8217;t realize it worked for CSS. a simple &lt;code&gt;crtl-x ctrl-o&lt;/code&gt; and it should attempt to complete your word for you. Cool thing is that if you use it after a property before you even start to type you can invoke it to get a list of properties.&lt;/p&gt;

&lt;p&gt;If this does not work, should make sure that the omnifunc it set to use the CSS completer:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:set omnifunc=csscomplete#CompleteCSS&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='making_the_css_dance'&gt;Making the CSS Dance&lt;/h2&gt;

&lt;p&gt;Now that you have both of those installed you can do cool stuff like complete your property values&lt;/p&gt;

&lt;p&gt;&lt;img src='/images/vim-css-prop-value.png' alt='Vim CSS Property Value' /&gt;&lt;/p&gt;

&lt;p&gt;After typing &amp;#8220;border-style: &amp;#8221; I pressed type &lt;code&gt;ctrl-x ctrl-o&lt;/code&gt; and get a handy popup complete list.&lt;/p&gt;

&lt;p&gt;&lt;img src='/images/vim-css-snip.png' alt='Vim CSS Snipet' /&gt;&lt;/p&gt;

&lt;p&gt;This was generated by typing &amp;#8220;margin:&amp;#60;tab&amp;#62;&amp;#8221;. No longer have to go look up which order the parameters go in.&lt;/p&gt;

&lt;h2 id='sassy_update'&gt;Sassy Update&lt;/h2&gt;

&lt;p&gt;To get this trickery to work with scss files, add the following to your vimrc:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.scss             set ft=scss.css&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>PackageMaker could not copy unreadable files</title>
		<link href="http://codeography.com/2010/07/28/packagemaker-could-not-copy-unreadable-files.html"/>
		<updated>2010-07-28T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/07/28/packagemaker-could-not-copy-unreadable-files</id>
		<content type="html">&lt;p&gt;I was getting a bizarre error with Apple&amp;#8217;s PackageMaker&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% /Developer/usr/bin/packagemaker --filter &amp;quot;\.DS_Store&amp;quot; --root-volume-only --domain system --verbose --no-relocate -l &amp;quot;/&amp;quot; --target 10.5 --id com.codeography.program.pkg --resources build/Release/Package/resources --scripts build/Release/Package/scripts --title &amp;quot;Program Name 2.1.10&amp;quot; --version 2.1.10 --root build/Release/Package/root --out installer.pkg                                                                 
Preverifying root
  Preverifying root
  Checking bundle identifiers
  Checking package configuration
  Checking contents
  Loading contents
  Applying Recommended Permissions
  Checking for ZeroLink
Preverifying Program Name 2.1.10
  Preverifying Program Name 2.1.10
Building root
  Building root
  Copying Scripts
  Copying unreadable files to temporary location
    ERROR: Could not copy unreadable files.
  Renaming package files&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After hours of searching I found that I had a vim swap file that wasn&amp;#8217;t world readable. And when I change the owner of the files that I need to package to be root, my user no longer had read permissions. Finding this was pretty easy using the &lt;code&gt;find&lt;/code&gt; command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% find . \! -perm -444
installer/config/.Info.plist.swp&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Deleted that file and everything worked.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Don't need no json.vim, get json syntax highlighting for free</title>
		<link href="http://codeography.com/2010/07/13/json-syntax-highlighting-in-vim.html"/>
		<updated>2010-07-13T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/07/13/json-syntax-highlighting-in-vim</id>
		<content type="html">&lt;p&gt;Recently I needed to work with some .json files and notice vim didn&amp;#8217;t know how to highlight them. A little baffled I turned to google and discovered json.vim. Installed it, setup the autocommand to reconize .json files as json and was set.&lt;/p&gt;

&lt;p&gt;But being stingy about what plugins I load, it dawned on me &amp;#8211; vim supports JavaScript, why not just use that for highlighting my json files? doing so was stupid-easy. Just add this line to your .vimrc:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.json set ft=javascript&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Done and done. Got good-enough hihglighting and only added one line of vimscript.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>rvm and vim combined: tastes like awesome</title>
		<link href="http://codeography.com/2010/06/25/rvm-and-vim-tastes-like-awesome.html"/>
		<updated>2010-06-25T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/06/25/rvm-and-vim-tastes-like-awesome</id>
		<content type="html">&lt;p&gt;After a &lt;a href='http://twitter.com/bryanl/status/17013225815'&gt;tweet&lt;/a&gt; about vim status lines by non other than &lt;a href='http://smartic.us/'&gt;Bryan Lyles&lt;/a&gt; I set out to get git and rvm info in vim&amp;#8217;s status line. Well, git was easy since I was using Tim Pope&amp;#8217;s fugitive plugin:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set statusline+=%{fugitive#statusline()}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But had no such luck with rvm, so I decided to roll my own. And thus we have &lt;a href='http://github.com/csexton/rvm.vim'&gt;rvm.vim&lt;/a&gt;. Which will report the ruby interperter you are using, the version of that guy and the active gemset (if you have one). It does assume you start vim from the terminal, but what self respecting vim user dosen&amp;#8217;t live on the command line all day long?&lt;/p&gt;

&lt;p&gt;Installation is easy, just go back to the aforementioned command line and paste this in:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl http://github.com/csexton/rvm.vim/raw/master/plugin/rvm.vim &amp;gt; ~/.vim/plugin/rvm.vim&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or if you are one of the cool kids and use &lt;a href='http://github.com/tpope/vim-pathogen'&gt;pathogen&lt;/a&gt; you can just clone the repo into your bundle directory:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone http://github.com/csexton/rvm.vim.git ~/.vim/bundle&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And this will give you a similar status line trick to fugitive:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set statusline+=%{rvm#statusline()}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What good is this hotness with out a screen shot?&lt;/p&gt;

&lt;p&gt;&lt;img src='/images/vimrvm.png' alt='rvm statusline' /&gt;&lt;/p&gt;

&lt;p&gt;If you want your status line to look just like this, this is how to do it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set statusline=[%n]\ %&amp;lt;%.99f\ %h%w%m%r%y%{exists(&amp;#39;g:loaded_fugitive&amp;#39;)?fugitive#statusline():&amp;#39;&amp;#39;}%{exists(&amp;#39;g:loaded_rvm&amp;#39;)?rvm#statusline():&amp;#39;&amp;#39;}%=%-16(\ %l,%c-%v\ %)%P&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What&amp;#8217;s on your vim status line?&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Exclude bundler gems from Heroku deployment</title>
		<link href="http://codeography.com/2010/05/20/exclude-bundler-gems-from-heroku-deployment.html"/>
		<updated>2010-05-20T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/05/20/exclude-bundler-gems-from-heroku-deployment</id>
		<content type="html">&lt;p&gt;I had some gems that I only needed for development on my mac, and did not want them to be installed to my Heroku slug. I didn&amp;#8217;t want them installed because they would break the deployment.&lt;/p&gt;

&lt;p&gt;Everything was fine until I wanted to use autotest with my Rails 3 app that is hosted on Heroku. I got this error when I tried to deploy:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
   /usr/ruby1.9.1/bin/ruby extconf.rb
   extconf.rb:19:in `&amp;lt;main&amp;gt;&amp;#39;: Only Darwin (Mac OS X) systems are supported (RuntimeError)
   Gem files will remain installed in /disk1/tmp/12479_23567910067960/.bundle/gems/gems/autotest-fsevent-0.2.2 for inspection.&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As they call out in their &lt;a href='http://docs.heroku.com/bundler'&gt;documentation&lt;/a&gt;, &amp;#8220;Heroku does not specify any groups during bundle installation, so all gems from all groups will be bundled with your application.&amp;#8221; I needed to find a way to exclude some libraries from being installed.&lt;/p&gt;

&lt;p&gt;Based on a tip from the Heroku &lt;a href='http://groups.google.com/group/heroku/browse_frm/thread/2a533b210b400e69/c9d753e89758ed57?hl=en&amp;amp;lnk=gst&amp;amp;'&gt;mailing list&lt;/a&gt; I found that the following worked:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem &amp;quot;autotest-fsevent&amp;quot; if RUBY_PLATFORM =~ /darwin/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But if I was going to exclude one gem, I figured I could exclude all my development gems, so I wound up doing this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if RUBY_PLATFORM =~ /darwin/
  group :test do
    gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;&amp;gt;= 2.0.0.beta.8&amp;quot;
    gem &amp;#39;factory_girl&amp;#39;, :git =&amp;gt; &amp;#39;git://github.com/thoughtbot/factory_girl.git&amp;#39;, :branch =&amp;gt; &amp;#39;rails3&amp;#39;
    gem &amp;#39;autotest-rails&amp;#39;
    gem &amp;#39;autotest&amp;#39;
    gem &amp;#39;autotest-fsevent&amp;#39;
    gem &amp;#39;autotest-growl&amp;#39;
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So I made that change, and deployment was still failing. I removed my Gemfile.lock and everything worked.&lt;/p&gt;

&lt;p&gt;This presents a complication, which according to &lt;a href='http://yehudakatz.com/2010/04/'&gt;Yehuda&lt;/a&gt;, &amp;#8220;because gems no longer live in your application, we needed a way to snapshot the list of all versions of all gems used at a particular time, to ensure consistent versions across machines and across deployments.&amp;#8221;&lt;/p&gt;

&lt;p&gt;To work around this I am specifying exact versions of the gems in my Gemfile.&lt;/p&gt;

&lt;p&gt;Of course if Heroku added support for &lt;code&gt;bundle install --without test&lt;/code&gt;, everything would &lt;em&gt;work just as it should&lt;/em&gt;&amp;#8482;.&lt;/p&gt;

&lt;p&gt;Added Bonus: My compiled slug size went from 19.6MB to 5.1MB.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Truncating strings in css</title>
		<link href="http://codeography.com/2010/05/19/truncating-strings-in-css.html"/>
		<updated>2010-05-19T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/05/19/truncating-strings-in-css</id>
		<content type="html">&lt;p&gt;Filed under &amp;#8220;Stupid CSS Tricks&amp;#8221;&lt;/p&gt;

&lt;p&gt;I had no idea you could insert an ellipises into html with css, and combined with overflow and white-space directives you can very politely clip a string.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;row_title {
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So instead of this:&lt;/p&gt;
&lt;div style='margin: 1em;width:30em; border:thin dotted red; overflow: hidden; white-space: nowrap;'&gt;
I saw the best minds of my generation Destroyed by madness, starving, hysterical
&lt;/div&gt;
&lt;p&gt;Or this:&lt;/p&gt;
&lt;div style='margin: 1em;width:30em; border:thin dotted red; white-space: nowrap;'&gt;
I saw the best minds of my generation Destroyed by madness, starving, hysterical
&lt;/div&gt;
&lt;p&gt;You get this sexxy beast:&lt;/p&gt;
&lt;div style='margin: 1em;width:30em; border:thin dotted red; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;'&gt;
I saw the best minds of my generation Destroyed by madness, starving, hysterical
&lt;/div&gt;</content>
	</entry>
	
	<entry>
		<title>Using factory_girl and Rspec with Rails 3</title>
		<link href="http://codeography.com/2010/04/30/using-factory_girl-and-rspec-with-rails-3.html"/>
		<updated>2010-04-30T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/04/30/using-factory_girl-and-rspec-with-rails-3</id>
		<content type="html">&lt;p&gt;&lt;strong&gt;Edit&lt;/strong&gt;: As Wes pointed out, the problems I was having were related to using the beta&amp;#8217;s of Rails, Rspec and Factory Girl. These are all resolved now, and the only trick is to make sure you use the &lt;a href='https://github.com/thoughtbot/factory_girl_rails'&gt;Factory Girl Rails&lt;/a&gt; gem. Luckily that is as easy as dropping&amp;#8230;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem &amp;#39;factory_girl_rails&amp;#39;` &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&amp;#8230;in to your Gemfile. Thanks Wes.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Just like anything in Rails 3, start by editing my Gemfile to include Rspec and Factory Girl:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;group :test do
  gem &amp;quot;rspec-rails&amp;quot;, &amp;quot;&amp;gt;= 2.0.0.beta.8&amp;quot;
  gem &amp;#39;factory_girl&amp;#39;, :git =&amp;gt; &amp;#39;git://github.com/thoughtbot/factory_girl.git&amp;#39;, :branch =&amp;gt; &amp;#39;rails3&amp;#39;
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then following the factory_girl documentation I created a new user factory in &lt;code&gt;spec/factories&lt;/code&gt; but got hit with an unexpected error while factory_girl was running her &lt;code&gt;find_definitions&lt;/code&gt; step:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/spec/factories/users.rb:1: uninitialized constant User (NameError)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The solution was simple. I noticed in the generated spec_helper Rspec was loading everything nested under &lt;code&gt;spec/support&lt;/code&gt;. So I simply moved my factories directory to &lt;code&gt;spec/support/factories&lt;/code&gt; and I saw the sweet red dots of failing tests.&lt;/p&gt;

&lt;p&gt;Time to go make them specs pass.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Fix Snow Leopard's ruby line editor with homebrew's readline</title>
		<link href="http://codeography.com/2010/03/29/fix-snow-leopard-ruby-with-homebrew-readline.html"/>
		<updated>2010-03-29T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/03/29/fix-snow-leopard-ruby-with-homebrew-readline</id>
		<content type="html">&lt;p&gt;This is just a very slight adoption of &lt;a href='http://www.jorgebernal.info/development/fixing-snow-leopard-ruby-readline'&gt;Jorge Bernal&amp;#8217;s awesome post&lt;/a&gt;, the only real difference is I use Homebrew to install readline.&lt;/p&gt;

&lt;p&gt;First setup &lt;a href='http://github.com/mxcl/homebrew/'&gt;homebrew&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then install readline:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;brew install readline&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Wasn&amp;#8217;t that nice?&lt;/p&gt;

&lt;p&gt;Now, onto fixing Snow Leopard&amp;#8217;s Ruby:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -O http://www.opensource.apple.com/tarballs/ruby/ruby-75.tar.gz
tar xvf ruby-75.tar.gz
cd ruby-75/ext/readline/
ruby extconf.rb
make&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you get an error Jorge Bernal suggests telling gcc to use the readline in /usr/local&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;make readline.o CFLAGS=&amp;#39;-I/usr/local/include -DHAVE_RL_USERNAME_COMPLETION_FUNCTION&amp;#39;
cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o readline.bundle readline.o -L/usr/local/lib -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64 -lruby -lreadline -lncurses -lpthread -ldl&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You might want to check that bundle with &lt;code&gt;otool&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;otool -L readline.bundle&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When I run that I see the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;readline.bundle:
   /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
   /usr/lib/libedit.2.dylib (compatibility version 2.0.0, current version 2.11.0)
   /usr/lib/libncurses.5.4.dylib (compatibility version 5.4.0, current version 5.4.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.0.0)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which happens to be slightly different from Jorge&amp;#8217;s, but everything seems to work for me.&lt;/p&gt;

&lt;p&gt;Move the existing file out of the way, and replace it with our shiny new bundle:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mv /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/1.8/universal-darwin10.0/readline.bundle /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/1.8/universal-darwin10.0/readline.bundle.libedit
cp readline.bundle /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/1.8/universal-darwin10.0/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This was&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Simple Capistrano email notifier for rails</title>
		<link href="http://codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails.html"/>
		<updated>2010-03-24T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/03/24/simple-capistrano-email-notifier-for-rails</id>
		<content type="html">&lt;p&gt;I needed to send out emails every time I deployed a rails app, and wanted to use the libraries that were already included with rails &amp;#8211; e.g. ActionMailer.&lt;/p&gt;

&lt;p&gt;My solution was based on some ideas from &lt;a href='http://github.com/pboling/capistrano_mailer'&gt;capistrano-mailer&lt;/a&gt; and &lt;a href='http://pastie.org/146264'&gt;Mislav Marohnić&lt;/a&gt; example, but I felt both were overkill for what I need, so here is my very simple, very customizable solution.&lt;/p&gt;

&lt;p&gt;Create a file &lt;code&gt;config/deploy/notifier.rb&lt;/code&gt; with the following contents:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$:.unshift File.dirname(__FILE__) + &amp;#39;/../../vendor/rails/actionmailer/lib&amp;#39;
require File.dirname(__FILE__) + &amp;#39;/../../vendor/rails/actionmailer/lib/actionmailer.rb&amp;#39;

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = &amp;quot;utf-8&amp;quot;
ActionMailer::Base.smtp_settings = {
  :address        =&amp;gt; &amp;quot;mail.example.com&amp;quot;,
  :port           =&amp;gt; 25,
  :domain         =&amp;gt; &amp;#39;example.com&amp;#39;,
  :perform_deliveries =&amp;gt; true,
  :user_name      =&amp;gt; &amp;#39;user&amp;#39;,
  :password       =&amp;gt; &amp;#39;secret&amp;#39;,
  :authentication =&amp;gt; :login }

class Notifier &amp;lt; ActionMailer::Base
  def deploy_notification(cap_vars)
    now = Time.now
    recipients cap_vars.notify_emails
    from     &amp;quot;App Deployments &amp;lt;app_deployments@example.com&amp;gt;&amp;quot;
    subject  &amp;quot;Deployed to #{cap_vars.host}&amp;quot;

    body &amp;lt;&amp;lt;-MSG
      Performed a deploy operation on #{now.strftime(&amp;quot;%m/%d/%Y&amp;quot;)} at #{now.strftime(&amp;quot;%I:%M %p&amp;quot;)} to #{cap_vars.host}

      Deployed to: https://#{cap_vars.host}
    MSG
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which is stupid easy to customize, if you&amp;#8217;d like to include the multistage info in the email body just edit the MSG and add &lt;code&gt;#{cap_vars.stage}&lt;/code&gt; or any &lt;a href='http://labs.peritor.com/webistrano/wiki/ConfigurationParameter'&gt;other variable&lt;/a&gt; that was set in the cap file.&lt;/p&gt;

&lt;p&gt;Now to get it hooked into your cap file. Simply edit &lt;code&gt;config/deploy.rb&lt;/code&gt; and add the following&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;require &amp;#39;config/deploy/notifier.rb&amp;#39;

# Setup the emails, and after deploy hook

set :notify_emails, [&amp;quot;ampere@example.com&amp;quot;, &amp;quot;henry@example.com]
after &amp;quot;deploy&amp;quot;, &amp;quot;deploy:notify&amp;quot;

# Create the task to send the notification

namespace :deploy do
  desc &amp;quot;Email notifier&amp;quot;
  task :notify
    Notifier.deliver_deploy_notification(self)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is not really rails specific, but if I were using Sinatra I would probably not use ActionMailer &amp;#8211; something like &lt;a href='http://github.com/benprew/pony'&gt;Pony&lt;/a&gt; would be a little prettier &amp;#8211; but the Capistrano configuration would work just fine.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Howto: Mirror Git to Subversion</title>
		<link href="http://codeography.com/2010/03/17/howto-mirror-git-to-subversion.html"/>
		<updated>2010-03-17T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/03/17/howto-mirror-git-to-subversion</id>
		<content type="html">&lt;p&gt;I recently had to setup read only Subversion mirrors for a few Git repositories, and quickly notice the was no consensus on how to do this. Not really happy with the other solutions I found I decided to roll my own using the tools that git already provides. And some cron. Sweet, sweet cron.&lt;/p&gt;

&lt;p&gt;A couple of assumptions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/var/svn&lt;/code&gt; - The location of your subversion repositories&lt;/li&gt;

&lt;li&gt;&lt;code&gt;/home/git/repositories&lt;/code&gt; - the Location of your git repositories&lt;/li&gt;

&lt;li&gt;&lt;code&gt;/home/git/svn&lt;/code&gt; - location of a work repo, actually performs the pull from the origin, merges, and dcommits to subversion.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You could easily move these elsewhere if you want, nothing special about their location.&lt;/p&gt;

&lt;h1 id='creating_the_mirror'&gt;Creating the Mirror&lt;/h1&gt;

&lt;p&gt;Lets say we have a project, called Ampere, and we want to setup a mirror.&lt;/p&gt;

&lt;p&gt;You have two situations here. Either you are starting with a Subversion repository that you want to move to git, and maintain as a read only mirror. Or you want to create a new Subversion mirror from an existing Git repository.&lt;/p&gt;

&lt;h2 id='option_1_create_a_git_repo_from_an_existing_svn_repository'&gt;Option 1: Create a git repo from an existing svn repository&lt;/h2&gt;

&lt;p&gt;How I exported all of ampere from Subversion and add it to Git, then created a Subversion mirror.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mkdir /home/git/svn
cd /home/git/svn
git svn clone file:///var/svn/ampere/web -T trunk -b branches -t tags ampere
git remote add origin git@example.com:ampere.git
git push origin master&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='option_2_import_git_repository_into_a_new_subversion_repository'&gt;Option 2: Import git repository into a new subversion repository&lt;/h2&gt;

&lt;p&gt;With a little help from &lt;a href='http://www.kerrybuckley.org/2009/10/06/maintaining-a-read-only-svn-mirror-of-a-git-repository/'&gt;Kerry Buckley&amp;#8217;s Guide&lt;/a&gt; I did the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mkdir /home/git/svn
cd /home/git/svn
git clone /home/git/repositories/ampere.git
cd ampere/
vim .git/config&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add the following content to that file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[svn-remote &amp;quot;svn&amp;quot;]
    url = https://example.com/svn/ampere/trunk/
    fetch = :refs/remotes/git-svn&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then merge the master into the new branch:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git svn fetch svn
git checkout -b svn git-svn
git merge master
git svn dcommit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then rebase that branch to the master, and you can dcommit from the master to svn&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout master
git rebase svn
git branch -d svn
git svn dcommit&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='make_subversion_readonly'&gt;Make Subversion read-only&lt;/h1&gt;

&lt;p&gt;Made a pre-commit hook that would prevent updating the trunk:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /var/svn/ampere/hooks
vim pre-commit&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Created the file with these contents&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/sh

REPOS=&amp;quot;$1&amp;quot;
TXN=&amp;quot;$2&amp;quot;

SVNLOOK=/usr/bin/svnlook

# Allow the git user
$SVNLOOK author -t &amp;quot;$TXN&amp;quot; &amp;quot;$REPOS&amp;quot; | /bin/grep &amp;quot;git&amp;quot; &amp;amp;&amp;amp; exit 0

# Committing to trunk is not allowed
$SVNLOOK changed -t &amp;quot;$TXN&amp;quot; &amp;quot;$REPOS&amp;quot; | /bin/grep &amp;quot;^U\W.*ampere\/trunk\/&amp;quot; &amp;amp;&amp;amp; /bin/echo &amp;quot;Error: ampere/trunk is read-only&amp;quot; 1&amp;gt;&amp;amp;2 &amp;amp;&amp;amp; exit 1

# All checks passed, so allow the commit.
exit 0&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then made that file executable:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;chmod +x pre-commit&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='merging_into_the_mirror'&gt;Merging into the mirror&lt;/h1&gt;

&lt;p&gt;In the repository you want to mirror, set the following to force all the merges to be the files from the origin server.&lt;/p&gt;

&lt;p&gt;I do this with a copy-merge strategy, this is done with a &lt;a href='http://stackoverflow.com/questions/1910444/git-merge-s-theirs-needed-but-i-know-it-doesnt-exist/1911370#1911370'&gt;custom merge driver&lt;/a&gt;. Since this is done on the work repository I just set it globally.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /home/git/svn/ampere
git config merge.copy-merge.name   &amp;#39;Copy Merge&amp;#39;
git config merge.copy-merge.driver &amp;#39;mv %B %A&amp;#39;
git config merge.default copy-merge&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='add_a_cron_job'&gt;Add a cron job&lt;/h1&gt;

&lt;p&gt;I figured checking for changes once an hour would be plenty:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;30 * * * * /usr/bin/ruby /home/git/svn/mirror.rb ampere &amp;gt;&amp;gt;/home/git/log/mirror-ampere.log 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Running git-daemon on Ubuntu</title>
		<link href="http://codeography.com/2010/03/15/running-git-daemon-on-ubuntu.html"/>
		<updated>2010-03-15T00:00:00-07:00</updated>
		<id>http://codeography.com/2010/03/15/running-git-daemon-on-ubuntu</id>
		<content type="html">&lt;p&gt;I needed a simple init script for running git daemon under ubuntu 9.10, and after a little searching and tweaking I wound up with the following.&lt;/p&gt;

&lt;p&gt;Create a /etc/init.d/git-daemon:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/sh
test -f /usr/bin/git || exit 0
. /lib/lsb/init-functions
GITDAEMON_OPTIONS=&amp;quot;daemon --reuseaddr --verbose --base-path=/home/git/repositories/ --detach&amp;quot;
case &amp;quot;$1&amp;quot; in
    start)  log_daemon_msg &amp;quot;Starting git-daemon&amp;quot;
    start-stop-daemon --start -c git:git --quiet --background \
    --exec /usr/bin/git -- ${GITDAEMON_OPTIONS}
    log_end_msg $?
    ;;
    stop)   log_daemon_msg &amp;quot;Stopping git-daemon&amp;quot;
    start-stop-daemon --stop --quiet --name git-daemon
    log_end_msg $?
    ;;
    *)      log_action_msg &amp;quot;Usage: /etc/init.d/git-daemon {start|stop}&amp;quot;
    exit 2
    ;;
esac
exit 0&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you can install and start it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo update-rc.d git-daemon defaults
sudo /etc/init.d/git-deamon start&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>RVM info in your prompt</title>
		<link href="http://codeography.com/2010/03/10/rvm-info-in-your-prompt.html"/>
		<updated>2010-03-10T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/03/10/rvm-info-in-your-prompt</id>
		<content type="html">&lt;p&gt;Having jumped on the &lt;a href='http://rvm.beginrescueend.com/'&gt;RVM&lt;/a&gt; bandwagon, I noticed I was constantly typing &lt;code&gt;rvm info&lt;/code&gt; to see what I was using in any particular instance of the terminal. Which is when I decided I would like to add that info to my prompt &amp;#8211; and since I use zsh the RPROMPT seemed like a great place to put this.&lt;/p&gt;

&lt;p&gt;&lt;img src='/media/rvm-zsh-rprompt.png' alt='RPROMPT with RVM info' /&gt;&lt;/p&gt;

&lt;p&gt;I wrote a little function to gather the current ruby version, and it will only show the prompt when RVM is installed and you are using a RVM installed ruby. I still have the system instaled ruby as the default, and didn&amp;#8217;t want this information to show up when I was using that.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function rvm_ruby_prompt {
  if (declare -f rvm &amp;gt; /dev/null) {
      if [[ -x $MY_RUBY_HOME ]]
      then ruby -v | sed &amp;#39;s/\([^(]*\).*/\1/&amp;#39;
      fi
  }
}
# Rubies are red, and my rprompt is too
RPROMPT=&amp;#39;%{$fg[red]%}$(rvm_ruby_prompt)%{$reset_color%}%&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Fun fact: &amp;#8220;RPROMPT&amp;#8221; stands for Ruby Prompt.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Alias a Class in Ruby</title>
		<link href="http://codeography.com/2010/03/01/alias-a-class-in-ruby.html"/>
		<updated>2010-03-01T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/03/01/alias-a-class-in-ruby</id>
		<content type="html">&lt;p&gt;I had a collegue looking for a way to alias a class in Ruby. Which I thought was a pretty interseting problem.&lt;/p&gt;

&lt;p&gt;My first attempt was using &lt;code&gt;eval&lt;/code&gt;, which really felt to clever:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Daddy; def speak() puts &amp;quot;No!&amp;quot; end; end
%w{Leah Lars}.each {|k| eval &amp;quot;class #{k} &amp;lt; Daddy; end&amp;quot;}
Leah.new.speak
Lars.new.speak&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then it dawned on me, everything is an object, even classes. So could it be this simple?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Daddy; def speak() puts &amp;quot;No!&amp;quot; end; end
Leah = Daddy
Lars = Daddy
Leah.new.speak
Lars.new.speak&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It actually worked. Yes it is one line longer. But it is extremly readable and does not use &lt;code&gt;evil&lt;/code&gt;&lt;em&gt;^H^H^H&lt;/em&gt;&lt;code&gt;eval&lt;/code&gt;&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Making Vim play nice with Jekyll's YAML Front Matter</title>
		<link href="http://codeography.com/2010/02/20/making-vim-play-nice-with-jekylls-yaml-front-matter.html"/>
		<updated>2010-02-20T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/02/20/making-vim-play-nice-with-jekylls-yaml-front-matter</id>
		<content type="html">&lt;p&gt;&lt;img src='/media/vim-jekyll-yaml-ugly.png' alt='vim-jekyll-yaml-ugly' /&gt;&lt;/p&gt;

&lt;p&gt;This just looks bad.&lt;/p&gt;

&lt;p&gt;I had a little Vim script adventure tonight. I wanted to make the highlighting of the yaml front matter work as it should for Jekyll.&lt;/p&gt;

&lt;p&gt;First thing I got hung up on was figuring out how to match multiline regex&amp;#8217;s. Which is when I found out about the &lt;code&gt;\_&lt;/code&gt; escape that Vim has, which adds an end of line to the character class it is adjacent to. Now could use the following search to select the yaml:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/^---\_.{-}---$/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which would also find other &lt;code&gt;---&lt;/code&gt; markers in the document, which was no good.&lt;/p&gt;

&lt;p&gt;More vimdocs and I finally came across &lt;code&gt;\%^&lt;/code&gt; which conveniently matches start-of-file. Progress!&lt;/p&gt;

&lt;p&gt;Once I plug that in, and go look at a few of the built Vim syntax scripts, I discover that I can put them in one handy &lt;code&gt;syntax match&lt;/code&gt; command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syntax match Comment /\%^---\_.\{-}---$/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I discover I can do the same thing with &lt;code&gt;syntax region&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syntax region Comment start=/\%^---$/ end=/^---$/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And even enable spell checking of my title by tacking on the contains param:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;syntax match Comment /\%^---\_.\{-}---$/ contains=@Spell&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But now that I figured out how to highlight the text that I care about, I need to figure out which file types use that syntax.&lt;/p&gt;

&lt;p&gt;Just apply it to all the markdown files:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead *.markdown syntax match Comment /\%^---\_.\{-}---$/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My first take, and it didn&amp;#8217;t seem like the best solution. Plus if the markdown file is not in a jekyll blog I don&amp;#8217;t want it to highlight the &lt;code&gt;---&lt;/code&gt;&amp;#8217;s (since it is probably not yaml)&lt;/p&gt;

&lt;p&gt;I try to get tricky, look at the path and if it looks like a jekyll blog I invoke it, and try include the textile file type.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;autocmd BufNewFile,BufRead */_posts/*.textile,*/_posts/*.markdown syntax match Comment /\%^---\_.\{-}---$/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Damn, Jekyll allows you to put yaml at the top of any templates, layouts or any other text file you have &amp;#8211; and I want those files to work.&lt;/p&gt;

&lt;p&gt;Then it dawned on me, I have the jekyll_path defined in my plugin, I just need a way to use that variable in the file pattern. Seems like the only way to do that is construct the command in a string and exec the bad boy. Which lead me to my final solution:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;execute &amp;quot;autocmd BufNewFile,BufRead &amp;quot; . g:jekyll_path . &amp;quot;/* syn match jekyllYamlFrontmatter /\\%^---\\_.\\{-}---$/ contains=@Spell&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src='/media/vim-jekyll-yaml-pretty.png' alt='vim-jekyll-yaml-pretty' /&gt;&lt;/p&gt;

&lt;p&gt;Much Better.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Convert ugly HTML links to pretty Markdown links</title>
		<link href="http://codeography.com/2010/02/20/convert-ugly-html-links-to-pretty-markdown-links.html"/>
		<updated>2010-02-20T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/02/20/convert-ugly-html-links-to-pretty-markdown-links</id>
		<content type="html">&lt;p&gt;Recently I have been converting a large number of old blog posts to &lt;a href='http://daringfireball.net/projects/markdown/'&gt;markdown&lt;/a&gt;, and have been writing a bunch of little one off scripts to handle this. One of the things I needed to do was convert a bunch of oddly formatted HTML links to their shiny clean markdown equivalent.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/env ruby
# Convert HTML links to Markdown links
ARGF.each do |line|
    puts line.gsub /&amp;lt;a [^h]*href=[&amp;quot;&amp;#39;]([^&amp;quot;&amp;#39;]*)[&amp;quot;&amp;#39;][^&amp;gt;]*&amp;gt;([^&amp;lt;]*)&amp;lt;\/a&amp;gt;/, &amp;quot;[\\2](\\1)&amp;quot;
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My script follows the standard unix convention, and reads from standard in or a file, and outputs to standard out. To use it you could do something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ruby html_links_to_markdown.rb &amp;lt;file.html&amp;gt; &amp;gt; file.markdown&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I should note, there are a few minor caveats. It will not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;replace multi line links&lt;/li&gt;

&lt;li&gt;replace links with nested tags. e.g. images &lt;code&gt;&amp;lt;a href=&amp;quot;#&amp;quot;&amp;gt;&amp;lt;imr src=&amp;quot;fail.png&amp;quot; /&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;match any links that have an attribute that starts with &amp;#8216;h&amp;#8217; before href. I don&amp;#8217;t think this is a very high use case. e.g.: &lt;code&gt;&amp;lt;a height=&amp;quot;4&amp;quot; href=&amp;quot;#&amp;quot;&amp;gt;fail&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those cases should just result in the original &lt;em&gt;ugly&lt;/em&gt; links remaining in the document, which can be manually fixed. I thought it was helpful, and handled many of the badly formatted &amp;#62;a&amp;#60; tags that haunted my old posts.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Couple of vim tips</title>
		<link href="http://codeography.com/2010/02/16/couple-of-vim-tips.html"/>
		<updated>2010-02-16T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/02/16/couple-of-vim-tips</id>
		<content type="html">&lt;p&gt;When in command mode, you can grab the word that is under the cursor. Makes search and replace for those long function names painless.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;C-r C-w&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The other little trick I didn&amp;#8217;t know about until I accitently brought it up was the command history. This subtle little thing makes a huge diffrence. You can use normal vim movement keys to edit the commands, and when you are done just hit &lt;pre class='markdown-html-error' style='border: solid 3px red; background-color: pink'&gt;REXML could not parse this XML/HTML: 
&amp;lt;enter&amp;gt; on the line and it will execute it.&lt;/pre&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;q:&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course you can do the same thing with search.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;q/&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Getting irb with readline support on Mac</title>
		<link href="http://codeography.com/2010/02/01/getting-irb-with-readline-support-on-mac.html"/>
		<updated>2010-02-01T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/02/01/getting-irb-with-readline-support-on-mac</id>
		<content type="html">&lt;p&gt;I tend to install unix software on the mac the old school way by grabbing the tarball and building it. Well that was fun an all until I discovered that irb didn&amp;#8217;t like to honor backspace. Turns out I needed to build and install readline.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -O ftp://ftp.cwru.edu/pub/bash/readline-6.1.tar.gz
curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p248.tar.gz
tar -zxvf readline-6.1.tar.gz
cd readline-6.1
./configure
make
sudo make install
cd ..
tar -zxvf ruby-1.8.7-p248.tar.gz
cd ruby-1.8.7-p248
./configure --with-readline-dir=/usr/local --enable-pthread
make
sudo make install
sudo make install-doc
ruby --version
# woohoo!&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Blogging with Vim</title>
		<link href="http://codeography.com/2010/01/12/blogging-with-vim.html"/>
		<updated>2010-01-12T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/01/12/blogging-with-vim</id>
		<content type="html">&lt;p&gt;I was inspired by &lt;a href='http://metajack.im/2009/01/02/manage-jekyll-from-emacs/'&gt;Jack Moffitt&lt;/a&gt;, and his Jekyll glue for Emacs.&lt;/p&gt;

&lt;p&gt;Not willing to let Emacs win this one, I busted out a &lt;code&gt;:h script&lt;/code&gt; and dove into the bizarre world of vim script. And unlike other forays into wacky programming languages, this actually resulted in something that I find useful.&lt;/p&gt;

&lt;p&gt;Basically I have two functions, a way to list all the posts in my jekyll blog and a way to make a new post.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:JekyllPost&lt;/code&gt; Create a new post, which will create a new buffer populated with a basic template. This does not actually write the file, so if you are like me you can start a post, change your mine and &lt;code&gt;:q!&lt;/code&gt; and have no regrets.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:JekyllList&lt;/code&gt; List the posts, opens the vim file system browser in the posts directory. Which lets you quickly search and open any of you previous entries.&lt;/p&gt;

&lt;p&gt;If you use git to store you Jekyll blog (and who doesn&amp;#8217;t?), you can use the following:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:JekyllCommit&lt;/code&gt; Adds and commits all the modified posts in your jekyll blog.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;:JekyllPublish&lt;/code&gt; Pushes the changes to the remote origin.&lt;/p&gt;

&lt;p&gt;I also made a couple of short cuts that save those precious few keystrokes:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;jn  :JekyllPost&amp;lt;CR&amp;gt;
map &amp;lt;Leader&amp;gt;jl  :JekyllList&amp;lt;CR&amp;gt;
map &amp;lt;Leader&amp;gt;jc  :JekyllCommit&amp;lt;CR&amp;gt;
map &amp;lt;Leader&amp;gt;jp  :JekyllPublish&amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can grab a copy over on &lt;a href='http://github.com/csexton/jekyll.vim'&gt;github&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Top 10 Mac apps for non-programmers</title>
		<link href="http://codeography.com/2010/01/05/top-10-mac-apps-for-non-programmers.html"/>
		<updated>2010-01-05T00:00:00-08:00</updated>
		<id>http://codeography.com/2010/01/05/top-10-mac-apps-for-non-programmers</id>
		<content type="html">&lt;p&gt;Recently a project manager friend of mine asked what he should get for his shiney new mack book pro, and I came up with the following list. Turns out it was 10 items long. So I was obligated by the internets to turn it into a blog post.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href='http://adium.im/'&gt;Adium&lt;/a&gt; for chat (for when you don&amp;#8217;t care about video)&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://www.obdev.at/products/launchbar/index.html'&gt;LaunchBar&lt;/a&gt; commercial, for starting apps/switching/everything. TOTALLY worth the money. If you only buy one program for your mac buy this one. If you cant cough up the euros at least use &lt;a href='http://www.blacktree.com/'&gt;QuickSilver&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://www.atebits.com/tweetie-mac/'&gt;Tweetie for twitter&lt;/a&gt; best twitter client, just use the free version.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://www.microsoft.com/mac/products/remote-desktop/default.mspx'&gt;Mac RDC client&lt;/a&gt; For those who need to remote into windows machines, but this does it.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://skitch.com/'&gt;Skitch&lt;/a&gt; is screen capture and markup on steroids. Alghough I am biased to &lt;a href='http://github.com/csexton/captured'&gt;Captured&lt;/a&gt;, which is for programmers, so it does not fit the criteria.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://cyberduck.ch/'&gt;Cyberduck&lt;/a&gt; who doesn&amp;#8217;t need an ftp client?&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://agilewebsolutions.com/products/1Password'&gt;1Password&lt;/a&gt; commercial, but by far the best password manager/form filler out there.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://dropbox.com'&gt;Dropbox&lt;/a&gt; simple sync between computers, does great job with &lt;a href='http://lifehacker.com/5063176/how-to-use-dropbox-as-the-ultimate-password-syncer'&gt;1Password&amp;#8217;s keychain&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://www.omnigroup.com/applications/OmniGraffle/'&gt;OmniGraffle&lt;/a&gt; commercial, but has a knack of making visio look tard-tastic.&lt;/p&gt;
&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;&lt;a href='http://www.omnigroup.com/omnifocus'&gt;OmniFocus&lt;/a&gt; commercial, but it is a fantastic GTD program. the WebDAV sync lets me keep my todo list up-to-date on multiple devices.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;</content>
	</entry>
	
	<entry>
		<title>Open Xcode Project from the Command line</title>
		<link href="http://codeography.com/2009/10/28/open-xcode-project-from-the-command-line.html"/>
		<updated>2009-10-28T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/10/28/open-xcode-project-from-the-command-line</id>
		<content type="html">&lt;p&gt;When I start to work on a programmign project I am conditioned to open terminal and change to that directory. And when working in xcode I used to run &lt;code&gt;open MyBigLongProjectName.xcodeproj&lt;/code&gt;, but have to deal with the fact that I normally have other files in that directory that start with MyBigLongProjectName&amp;#8211;making tab compleation annoying. The solution to this was to make an xcode alias:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias xcode=&amp;quot;open *.xcodeproj&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I can switch from terminal to xcode and back with out breaking my pace.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Creating custom ohai plugins</title>
		<link href="http://codeography.com/2009/10/21/creating-custom-ohai-plugins.html"/>
		<updated>2009-10-21T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/10/21/creating-custom-ohai-plugins</id>
		<content type="html">&lt;p&gt;After spending a while googling for how to make a ohai plugin I was forced to Read The Source (tm). So I thought I would put to gether a quick ohai plugin howto.&lt;/p&gt;

&lt;p&gt;&lt;img src='http://www.codeography.com/media/creating-custom-ohai-plugins.jpg' alt='Ohai, Izs your new plugin' /&gt;&lt;/p&gt;

&lt;h1 id='install_ohai'&gt;Install ohai&lt;/h1&gt;

&lt;p&gt;You will need the ohai gem installed to use it, so an easy way to do this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem source -a http://gems.opscode.com/
sudo gem install ohai&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='create_a_simple_plugin'&gt;Create a simple plugin&lt;/h1&gt;

&lt;p&gt;Ohai plugins use a ruby DSL. The following is about as simple as it gets:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;provides &amp;quot;orly&amp;quot;
orly &amp;quot;yeah, rly.&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now that part I found tricky, loading it.&lt;/p&gt;

&lt;p&gt;Create a &amp;#8220;plugins&amp;#8221; folder and put the above code in the &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/plugins/orly.rb'&gt;plugins/orly.rb&lt;/a&gt; file.&lt;/p&gt;

&lt;p&gt;Now to fire up irb (I am assuming you are in the directory that contains the &amp;#8220;plugins&amp;#8221; folder, if not adjust your path):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; require &amp;#39;ohai&amp;#39;
&amp;gt;&amp;gt; Ohai::Config[:plugin_path] &amp;lt;&amp;lt; &amp;#39;./plugins&amp;#39;
&amp;gt;&amp;gt; o = Ohai::System.new
&amp;gt;&amp;gt; o.all_plugins
&amp;gt;&amp;gt; o.orly #=&amp;gt; &amp;quot;yea, rly&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The entire script can be found in &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/orly.rb'&gt;orly.rb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you run &lt;code&gt;o.orly&lt;/code&gt; and get &lt;code&gt;nil&lt;/code&gt; the chances are the plugin path is probably incorrect. I battled with this for hours banging my head against the wall. Turns out I just forgot the &amp;#8216;s&amp;#8217; on the end of &amp;#8216;./plugins&amp;#8217;&lt;/p&gt;

&lt;h1 id='using_a_mash'&gt;Using a Mash&lt;/h1&gt;

&lt;p&gt;Most of the information we want to lookup would be nested in some way, and ohai tends to do this by storing the data in a Mash. This can be done by creating a new mash and setting the attribute to it.&lt;/p&gt;

&lt;p&gt;In &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/plugins/canhaz.rb'&gt;plugins/canhas.rb&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;provides &amp;quot;canhas&amp;quot;
canhas Mash.new
canhas[:burger] = &amp;quot;want&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='extending_an_existing_plugin'&gt;Extending an existing plugin&lt;/h1&gt;

&lt;p&gt;Ohai makes it very easy to extend a current plugin with new information. Simply require the plugin you want to extend and extend away. In this example we want to add LOLCODE to languages.&lt;/p&gt;

&lt;p&gt;In &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/plugins/lolcode.rb'&gt;plugins/lolcode.rb&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;provides &amp;quot;languages/lolcode&amp;quot;
require_plugin &amp;quot;languages&amp;quot;
languages[:lolcode] = Mash.new
languages[:lolcode][:version] = &amp;quot;TEH VERSHIONS&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id='working_with_different_platforms'&gt;Working with Different Platforms&lt;/h1&gt;

&lt;p&gt;One of the main reasons for using ohai is to gather information regardless of the operating system, luckily this is made easy by optionally loading recipes based on the platform. With that platform specific calls abstracted away you can keep your code DRY.&lt;/p&gt;

&lt;p&gt;The builtin plugins that come with ohai use the following trick to load platform specific code. It works by creating a base cross-platform plugin that loads the platform specific plugin from a subdirectory.&lt;/p&gt;

&lt;p&gt;In &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/plugins/lolcode.rb'&gt;plugins/lolcode.rb&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;provides &amp;quot;languages/lolcode&amp;quot;
require_plugin &amp;quot;languages&amp;quot;
require_plugin &amp;quot;#{os}::lolcode&amp;quot;

languages[:lolcode] = Mash.new unless languages[:lolcode]
languages[:lolcode][:version] = &amp;quot;TEH VERSHIONS&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In &lt;a href='http://github.com/csexton/ohai-plugin-howto/blob/master/plugins/darwin/lolcode.rb'&gt;plugins/darwin/lolcode.rb&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;provides &amp;quot;languages/lolcode&amp;quot;
require_plugin &amp;quot;languages&amp;quot;
languages[:lolcode] = Mash.new unless languages[:lolcode]
languages[:lolcode][:platform] = &amp;quot;MACKERS&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Checkout ohai&amp;#8217;s &lt;a href='http://github.com/opscode/ohai/blob/master/lib/ohai/plugins/os.rb'&gt;os.rb&lt;/a&gt; for the list of platform names.&lt;/p&gt;

&lt;p&gt;All of these examples can be found in the &lt;a href='http://github.com/csexton/ohai-plugin-howto/'&gt;ohai-plugin-howto github repo&lt;/a&gt;, you should be able to clone that and run the ruby scripts in the repo&amp;#8217;s root directory.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Install git man pages the easy way</title>
		<link href="http://codeography.com/2009/09/15/install-git-man-pages-the-easy-way.html"/>
		<updated>2009-09-15T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/09/15/install-git-man-pages-the-easy-way</id>
		<content type="html">&lt;p&gt;There seems to be a few ways to install the git man pages, but these seems to involve some wacky tricks with a copy of the git repo checked out. I wanted to make sure I had the man pages for my exact version of git and just wanted them in place so I could do &lt;code&gt;git help command&lt;/code&gt; and see some pretty helps.&lt;/p&gt;

&lt;p&gt;First, figure out your version number. Mine was 1.6.4.2&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git --version&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then download the tarball for that version and unzip to your manpage dir:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -O &amp;quot;http://git-core.googlecode.com/files/git-manpages-1.7.7.4.tar.gz&amp;quot;
sudo tar xjv -C /usr/local/share/man -f git-manpages-1.7.7.4.tar.gz&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you really don&amp;#8217;t want to think, cut-n-paste the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd /tmp
curl -O &amp;quot;http://git-core.googlecode.com/files/git-manpages-`git --version | awk &amp;#39;{print $3}&amp;#39;`.tar.gz&amp;quot;
sudo mkdir -p /usr/local/share/man
sudo tar xjv -C /usr/local/share/man -f git-manpages-`git --version | awk &amp;#39;{print $3}&amp;#39;`.tar.bz2&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>The terminal says Grr</title>
		<link href="http://codeography.com/2009/09/11/the-terminal-says-grr.html"/>
		<updated>2009-09-11T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/09/11/the-terminal-says-grr</id>
		<content type="html">&lt;p&gt;I have been building a few things that take a while to compile *cough*&lt;a href='http://llvm.org/'&gt;llvm&lt;/a&gt;*cough* and started using &lt;a href='http://growl.info/'&gt;growl&lt;/a&gt; to let me know to stop reading hacker news and go back to doing something useful.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ make ; growlnotify -m &amp;quot;All done!&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then it dawned on me, I should make some aliases. I made two: Yay, for when things were happy to finish. Boo for when I didn&amp;#8217;t want something to stop.&lt;/p&gt;

&lt;p&gt;I put this in my .bash_login:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias yay=&amp;quot;growlnotify -m Yay!&amp;quot;
alias boo=&amp;quot;growlnotify -m Boo!&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now when I run make I can just do a &lt;code&gt;make ; yay&lt;/code&gt; and it will cheer when it is done. Likewise if I am running one of my deamons that is not supposed to stop running (aka crash) I will do a &lt;code&gt;server ; boo&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s like decorating the homely terminal with some pretty golden growl messages. Suddenly everything is pretty!&lt;/p&gt;

&lt;p&gt;This assumes you have growlnotify installed, which can be found on the growl install disk image.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Automating Apple's PackageMaker</title>
		<link href="http://codeography.com/2009/09/04/automating-apple-s-packagemaker.html"/>
		<updated>2009-09-04T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/09/04/automating-apple-s-packagemaker</id>
		<content type="html">&lt;p&gt;This article should have a sub title:&lt;/p&gt;

&lt;p&gt;Automating Apple&amp;#8217;s PackageMaker: A wonderful way to punish the well intensioned developer.&lt;/p&gt;

&lt;p&gt;It seems like PackageMaker is very much an incomplete and buggy tool. I know we are suposed to use drag-n-drop installs, but sometimes that just isn&amp;#8217;t a good option. Like if you were creating a system daemon.&lt;/p&gt;

&lt;p&gt;Even trying to use the option documented in the usage message fail:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ Flat\ Package\ Editor --extract /tmp/fpm -f test.pkg
Extraction not supported from the command line yet.&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Granded that is the Flat Package Editor, but as you can see it is just part of PackageMaker, and seemed to have an option I needed &amp;#8211; only it is not implemented.&lt;/p&gt;

&lt;p&gt;Initially I wanted to make a ruby library to automate creating the pmdoc contents xml files, and possibly some generator scripts. This seemed like it would be straight forward, but I kept running into gotchas.&lt;/p&gt;

&lt;p&gt;Amoung my list of complaints when trying to work with a pmdoc:&lt;/p&gt;

&lt;p&gt;The relocatable checkbox (and occationally the require reboot option) magically get selected when editing other properties. I notced this every time I would alter the path to the bundle. If I changed &amp;#8220;Release&amp;#8221; to &amp;#8220;Debug&amp;#8221; all the other properties would be altered. This got old.&lt;/p&gt;

&lt;p&gt;Can&amp;#8217;t relaiably track changes in version control, because just opening the package in PackageMaker changes every line in every file contained in the pmdoc bundle.&lt;/p&gt;

&lt;p&gt;While you can mark certian paths as relitive, not all of them could be. So you are forced to use absolute paths in some places. If you use a relitive one PackageMaker will crash when trying to build.&lt;/p&gt;

&lt;p&gt;This just seemed like a rat hole I would be stuck in, so I abandoned this in favor of a straight command line build.&lt;/p&gt;

&lt;p&gt;This means you have to create the root directory, copy all the files into a directory structure that you want for the target and bundle it up. You can specify the recources and scripts directory for the bundle that get included. In theory if you put the right files with the right names in the right place in these directories then they will get use appropratly. This does not always seem to be true.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;I have a scripts folder with a postinstall script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Scripts/postinstall&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and I include that on the command line&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;packagemaker --scripts ./scripts/ ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It will get run after the install. Yay!&lt;/p&gt;

&lt;p&gt;BUT, if I want a background image I should just have to put the file in the right place&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Resources/background.png&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And include that resources in the command&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;packagemaker --resources ./scripts/ ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But no dice. If I want the background image to show up I have to un-xar the pkg file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;xar -xf &amp;lt;path_to_pkg&amp;gt; -C &amp;lt;work_dir&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Edit the Distribution file&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;background file=&amp;#39;background.png&amp;#39; alignment=&amp;#39;bottomleft&amp;#39; scaling=&amp;#39;none&amp;#39;/&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Re-xar the file&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd &amp;lt;work_dir&amp;gt;
xar -cf my_installer.pkg .&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Currently I have given up on any custom modifacations (like background images), and can do this a a few steps.&lt;/p&gt;

&lt;p&gt;Clean up, create the root and populate it with the approprate files&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;find ./scripts/ -name &amp;#39;*.DS_Store&amp;#39; -type f -delete
find ./resources/ -name &amp;#39;*.DS_Store&amp;#39; -type f -delete
rm -rf &amp;lt;package_path&amp;gt;
mkdir -p &amp;lt;package_root_path&amp;gt;
cp -R build/&amp;lt;build_dir&amp;gt;/MyApp.app &amp;lt;package_root_path&amp;gt;
cp -R build/&amp;lt;build_dir&amp;gt;/MySecondApp.app &amp;lt;package_root_path&amp;gt;
cp any/requred/files &amp;lt;package_root_path&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Change the permission to what they should be on the target:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo chown -R root:admin &amp;lt;package_root_path&amp;gt;
sudo chmod -R g+w &amp;lt;package_root_path&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Run the package maker build on the command line:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/Developer/usr/bin/packagemaker \
--title &amp;quot;My Installer&amp;quot; \
--version 1.0 \
--filter &amp;quot;\.DS_Store&amp;quot; \
--resources ./resources/ \
--scripts ./scripts/ \
--root-volume-only \
--domain system \
--verbose \
--no-relocate \
-l &amp;quot;/Library/Application Settings/MyApp&amp;quot; \
--target 10.5 \
--id com.example.my_installer.pkg \
--root &amp;lt;package_root_path&amp;gt; \
--out &amp;lt;my_installer.pkg&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will put everything that was in the package_root_path into &amp;#8220;/Library/Application Settings/MyApp&amp;#8221; on the target. I was doing this because all my files needed to be in that directory. If you need multiple locations through out the drive you can always set -l to &amp;#8221;/&amp;#8221;, and create the directory tree of the target under your package_root_path.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;If you wanted to do that the directory tree would look something like this:

package_root_path/
                 /Applicatons/
                             /MyApp.app
                 /Library/
                         /MyApp&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Detecting native ruby gems with the wrong archetecture</title>
		<link href="http://codeography.com/2009/06/19/detecting-native-ruby-gems-with-the-wrong-archetecture.html"/>
		<updated>2009-06-19T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/06/19/detecting-native-ruby-gems-with-the-wrong-archetecture</id>
		<content type="html">&lt;p&gt;Having recently upgraded to Snow Leopard I have found myself going between my ruby projects and running the tests only to find that the gems I have installed are not 64 bit binaries. Since I am running the ruby that shipped with 10.6 I am running as 64 bit and I would get some nasty wrong archetecture errors. Well I wanted to find a way to go figure out all the gems that did not have &lt;code&gt;x86_64&lt;/code&gt; binary libraries.&lt;/p&gt;

&lt;p&gt;Here is the ruby script I came up with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Gem::all_load_paths.each do |p| 
  Dir[&amp;quot;#{p}/../ext/*.bundle&amp;quot;].each do |f|
    s = `file #{f}`
    if (!s.include? &amp;quot;for architecture x86_64&amp;quot;)
      puts s
    end
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Nice thing about this is it uses &lt;code&gt;all_load_paths&lt;/code&gt; to find where the gems are located, so if you have them installed im multiple places (like &lt;code&gt;/Library/Ruby/Gems/&lt;/code&gt; and &lt;code&gt;~/.gems&lt;/code&gt;) it should find them.&lt;/p&gt;

&lt;p&gt;Now if you find gems that are not supported it is normally pretty easy to fix. Here is what I did to fix nokogiri:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Copy the gem to temp
cp -r /Library/Ruby/Gems/1.8/gems/nokogiri-1.3.1/ /tmp/nokogiri
cd /tmp/ext/nokogiri
# Add our archetecture 
sed &amp;quot;s/i386/i386 \-arch x86_64/&amp;quot; Makefile &amp;gt; Makefile
make clean
make 
# Replace the old binary
sudo cp nokogiri.bundle /Library/Ruby/Gems/1.8/gems/nokogiri-1.3.1/lib/nokogiri/nokogiri.bundle&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Nice syntax highlighting in Xcode</title>
		<link href="http://codeography.com/2009/06/09/nice-syntax-highlighting-in-xcode.html"/>
		<updated>2009-06-09T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/06/09/nice-syntax-highlighting-in-xcode</id>
		<content type="html">&lt;p&gt;I am a big fan of vibrant ink color scheme, and have spent more than a little time so that I can have similar colors when I am looking at code outside of textmate. I have my version of the scheme in Vim, Visual Studio, Trac and now Xcode.&lt;/p&gt;
&lt;img src='/media/ristoink_xcode.png' /&gt;
&lt;p&gt;I couldn&amp;#8217;t find anyway to export the color schemes in the Xcode properties so I went poking around. Turns out it is exactly where you would expect it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;~/Library/Application Support/Xcode/Color Themes&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It has a simple xml plist file, perfect for version control. So I copied it to my dotfiles git repository and symlinked it. So if you want my latest color scheme head over to github and take a look. Or you could just &lt;a href='http://github.com/csexton/dotfiles/raw/master/xcode/RistoInk.xccolortheme'&gt;download it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To install it just drop it into the library directory above.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Vim Tip - VimGrep and QuickList</title>
		<link href="http://codeography.com/2009/06/05/vim-tip-vimgrep-and-quicklist.html"/>
		<updated>2009-06-05T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/06/05/vim-tip-vimgrep-and-quicklist</id>
		<content type="html">&lt;p&gt;I have known about the vimgrep command for a while, but it was always a little awkward. Well that has all changed now that I know about the QuickFix window.&lt;/p&gt;

&lt;p&gt;Take a gem project, I want to search through all the ruby files:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:vimgrep my_method **/*.rb&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which jumps to the first one. But (unbeknownst to me) it also populates the quick list. You can bring up this fancy window with a &lt;code&gt;:cw&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then you can simply navigate to the line you want to look at and hit &lt;code&gt;enter&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Suh-weet.&lt;/p&gt;

&lt;p&gt;But it gets better. Often I want to look for a couple of keywords. I can keep adding to the quick list by using &lt;code&gt;vimgrepadd&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:vimgrep your_method **/*.rb&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then you end up with the results of both in your quick list window, which is a simple &lt;code&gt;C-w C-w&lt;/code&gt; away.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Working with binary data in irb</title>
		<link href="http://codeography.com/2009/06/03/working-with-binary-data-in-irb.html"/>
		<updated>2009-06-03T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/06/03/working-with-binary-data-in-irb</id>
		<content type="html">&lt;p&gt;Since I have been workign on a ruby port of a windows program that has a binary format, I find myself having to examine the memory contents in Visual Studio and try to reproduce the same output in ruby. Well, maybe it is years of pratice, but I find it much easier to read the hex output than the octal that ruby uses. This is something I normally want when working in IRB or as fixture data in my tests. So to make this a little easier I extended Integer and String. I wound up dumping this code into my .irbrc file so I could easily cut-n-paste the memory from windows.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Integer
  def to_binary_s
    bits = self.to_s(2)
    prepend = (8 - bits.length % 8)
    bits = (&amp;#39;0&amp;#39; * prepend) + bits
    return [bits].pack(&amp;#39;B*&amp;#39;)
  end
end
class String
  def read_hex_s
    self.gsub(&amp;quot; &amp;quot;, &amp;quot;&amp;quot;).hex.to_binary_s
  end
  def to_hex_s
    self.unpack(&amp;quot;H*&amp;quot;)[0]
  end
end&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Setting up cgit under Ubuntu</title>
		<link href="http://codeography.com/2009/05/30/setting-up-cgit-under-ubuntu.html"/>
		<updated>2009-05-30T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/30/setting-up-cgit-under-ubuntu</id>
		<content type="html">&lt;p&gt;I tried gitweb and wasted most of a day trying to get apache to stop escaping &amp;#8221;;&amp;#8221; with &amp;#8220;%3&amp;#8221;, took a hack at a few of the php based git browsers &amp;#8211; no luck. That was until I came accross cgit.&lt;/p&gt;

&lt;p&gt;First setup the prereques. I had most of what I needed but was missing libcurl, so I ran the following command to add that. I am sure you will need a few other like git-core and build-essentials. sudo apt-get install libcurl4-openssl-dev&lt;/p&gt;

&lt;h2 id='building_cgit'&gt;Building cgit&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;git clone git://github.com/metajack/cgit.git
cd cgit/
git submodule init
git submodule update
make&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I skip the make install step because I put the binary in a seprate cgi-bin directory anyway.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo cp ./cgit /usr/lib/cgi-bin/cgit.cgi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course if you use a different location for your cgi-bin you will want to put that in the above command&lt;/p&gt;

&lt;p&gt;If /var/www/htdocs/ is your docroot (which mine is) you will want to move the css and png files there:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cp ./cgit.css /var/www/htdocs/
cp ./cgit.png /var/www/htdocs/git-logo.png # the default logo&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='configure_cgit'&gt;Configure cgit&lt;/h2&gt;

&lt;p&gt;Create a file at /etc/cgit and add the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;virtual-root=/git/
enable-index-links=1
enable-log-filecount=1
enable-log-linecount=1
snapshots=tar.gz tar.bz zip

# List of repositories
repo.url=red_baron
repo.path=/home/git/repositories/red_baron.git
repo.desc=Ace of the skies
repo.owner=Reb Baron

repo.group=project1
repo.url=sub1
repo.path=/home/git/repositories/sub1.git
repo.desc=Sub1 of Project1
repo.owner=Joe Cool

repo.url=sub1
repo.path=/home/git/repositories/sub1.git
repo.desc=Sub2 of Project1
repo.owner=Snoopy&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='configure_apache'&gt;Configure Apache&lt;/h2&gt;

&lt;p&gt;Add the following under your virtual host tag:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;   # Add the cgi-bin if you don&amp;#39;t have one already
   ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
   # Add the trailing slash
   RewriteRule ^/git$ /git/ [R]
   # Pretty urls
   RewriteRule ^/git/(.*)$ /cgi-bin/cgit.cgi/$1 [PT]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At this point you should be able to restart apache and browse to your git repos at http://hostname/git&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Speedy Bash Prompt: Git and Subversion Integration</title>
		<link href="http://codeography.com/2009/05/26/speedy-bash-prompt-git-and-subversion-integration.html"/>
		<updated>2009-05-26T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/26/speedy-bash-prompt-git-and-subversion-integration</id>
		<content type="html">&lt;p&gt;I had tried using a &lt;a href='http://www.entropy.ch/blog/Developer/2009/03/30/Git-and-SVN-Status-in-the-Bash-Prompt.html'&gt;number&lt;/a&gt; of &lt;a href='http://ciaranm.wordpress.com/2008/07/16/git-and-subversion-information-in-the-bash-prompt/'&gt;other&lt;/a&gt; bash scripts to display git and svn info in the prompt, but things had become pretty sluggish. Sure things would cache after the first time I cd&amp;#8217;d into the directory, but often I was stuck waiting while that first try happened. I couldn&amp;#8217;t take it any more. I wanted some info still in the prompt, but I didn&amp;#8217;t need that much, so I trimmed things down.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;scm_ps1() {
    local s=
    if [[ -d &amp;quot;.svn&amp;quot; ]] ; then
        s=\(svn:$(svn info | sed -n -e &amp;#39;/^Revision: \([0-9]*\).*$/s//\1/p&amp;#39; )\)
    else
        s=$(__git_ps1 &amp;quot;(git:%s)&amp;quot;)
    fi
    echo -n &amp;quot;$s&amp;quot;
}
export PS1=&amp;quot;\[\033[00;32m\]\u\[\033[00;32m\]@\[\033[00;32m\]\h:\[\033[01;34m\]\w \[\033[31m\]\$(scm_ps1)\[\033[00m\]$\[\033[00m\] &amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This requires you have the git bash compleation script installed for the &lt;code&gt;__git_ps1&lt;/code&gt; command. Which I have on OS X from MacPorts (if you used the +bash_compleation option) and from Apt on Ubuntu.&lt;/p&gt;

&lt;p&gt;You will need to source these in your .bash_login.&lt;/p&gt;

&lt;p&gt;For all the bashy compleations:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Just for git:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if [ -f /opt/local/etc/bash_completion.d/git ]; then
. /opt/local/etc/bash_completion.d/git
fi&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If interested check out the home/bash_login script in my &lt;a href='http://github.com/csexton/dotfiles/tree/'&gt;dotfiles project&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Pure Ruby CRC-32/ADCCP (CRC-32/PKZIP)</title>
		<link href="http://codeography.com/2009/05/22/pure-ruby-crc32-adccp-pkzip.html"/>
		<updated>2009-05-22T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/22/pure-ruby-crc32-adccp-pkzip</id>
		<content type="html">&lt;p&gt;I ported what I beleive is the CRC-32/ADCCP (a.k.a CRC-32/PKZIP) to ruby. I had been doing communication with a server that required a CRC signature be calculated and sent along with the data only to discover that Zlib.crc32 would not work.&lt;/p&gt;

&lt;p&gt;Luckily the folks who made the pure Ruby port of Zlib, Zliby, provided a good starting point with their crc32 implementation.&lt;/p&gt;

&lt;p&gt;After a fair amount of head scratching and saying of bad words here is what I came up with. Seems to work just fine for my communication.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def self.crc32adccp(string, crc=0)
  raise RangeError.new if (crc &amp;gt; 2**128 - 1)
  string.each_byte do |byte|
    temp1 = (crc &amp;gt;&amp;gt; 8) &amp;amp; 0x00FFFFFF
    temp2 = crc_table[(crc ^ byte) &amp;amp; 0xff];
    crc = temp1 ^ temp2
  end
  crc
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you don&amp;#8217;t want to include the crc table in your code you can prefix the crc_table with &amp;#8220;Zlib.&amp;#8221; and require &amp;#8216;zlib&amp;#8217; but if you are like me and would prefer to have uglier code with less dependencies you can include the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;def self.crc_table
  [ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d]
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here&amp;#8217;s a rspec to see how to use it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;it &amp;quot;should create a valid crc&amp;quot; do 
  # I gathered this string and crc from the server directly to serve 
  # as fixture data
  data = &amp;quot;\001\000\000\000\000\340\001\000\000&amp;quot;
  crc32adccp(data).should eql 3234217804
end&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Working with FILETIME in Ruby</title>
		<link href="http://codeography.com/2009/05/20/working-with-filetime-in-ruby.html"/>
		<updated>2009-05-20T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/20/working-with-filetime-in-ruby</id>
		<content type="html">&lt;p&gt;Recently I have had to deal with the windows FILETIME struct in ruby.&lt;/p&gt;

&lt;p&gt;MSDN defines this guy as &amp;#8220;a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC).&amp;#8221;&lt;/p&gt;

&lt;p&gt;Well, the easy thing to do is add a method to the Time class that can convert to the format:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class Time
  # Convert the time to the FILETIME format, a 64-bit value representing the
  # number of 100-nanosecond intervals since January 1, 1601 (UTC).
  def wtime
    self.to_i * 10000000 + 116444736000000000
  end

  # Create a time object from the FILETIME format, a 64-bit value representing
  # the number of 100-nanosecond intervals since January 1, 1601 (UTC).
  def self.from_wtime(wtime)
    Time.at((wtime - 116444736000000000) / 10000000)
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I can do fancy things like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;some_bindata_struct.time = Time.now.wtime&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>ssh-keyput</title>
		<link href="http://codeography.com/2009/05/19/ssh-keyput.html"/>
		<updated>2009-05-19T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/19/ssh-keyput</id>
		<content type="html">&lt;p&gt;That&amp;#8217;s pronounced &amp;#8220;shush-kaput&amp;#8221;&lt;/p&gt;

&lt;p&gt;If there is one thing I like it is setting up ssh to use my public key so that I don&amp;#8217;t have to type a password when login to a server. This wasn&amp;#8217;t too hard, but since OSX does not have ssh-copy-id by default I would have to pull up the instructions every time to make sure I remembered the file names and permissions just right.&lt;/p&gt;

&lt;p&gt;So last night I made a ruby gem to remember how to do it for me, ssh-keyput&lt;/p&gt;

&lt;p&gt;Now all I&amp;#8217;s got to do to copy my public key is:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ssh-keyput chris@server.com&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To install all you need is a simple gem install:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install csexton-ssh-keyput -s http://gems.github.com&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It is nothing but a glorified wrapper for a few shell commands, but it is much easier to remember&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Working with binary data in Ruby</title>
		<link href="http://codeography.com/2009/05/02/working-with-binary-data-in-ruby.html"/>
		<updated>2009-05-02T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/05/02/working-with-binary-data-in-ruby</id>
		<content type="html">&lt;p&gt;Recently I found my self having to work with binary data in Ruby, but have found myself confused and frustrated by a few things. Luckily this during recent experiment I discovers a few tricks that really help me.&lt;/p&gt;

&lt;h2 id='view_binary_data_in_hex'&gt;View binary data in hex&lt;/h2&gt;

&lt;p&gt;When working in the Visual Studio debugger I prefer to view memory in hex, so I found it awkward to compare with the decimal escapes that Ruby uses.&lt;/p&gt;

&lt;p&gt;But String#unpack has the H format. Since the documentation described it as &amp;#8220;extract hex nibbles from each character&amp;#8221; I didn&amp;#8217;t expect it to do what I wanted, but it does. For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; &amp;quot;\322\204\371\225Q&amp;quot;.unpack(&amp;quot;H*&amp;quot;)
=&amp;gt; [&amp;quot;d284f99551&amp;quot;]&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='parsing_data_into_structs'&gt;Parsing data into structs&lt;/h2&gt;

&lt;p&gt;While you &lt;em&gt;can&lt;/em&gt; do this with String#unpack and Array#pack, that frankly blows. Luckily I came across Dion Mendel&amp;#8217;s awesome &lt;a href='http://bindata.rubyforge.org/'&gt;binutils gem&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Where I was able to take this C struct:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;struct ServerData
{
    WORD	 StructSize;     
    DWORD    ErrorCode;
    char	 ErrorMsg[100];  
    char	 ServerIPAddr[16];
    WORD	 ServerPort;     
    BYTE	 Reserved[100];  
    digest	 Signature;      
};&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And rewrite it in ruby:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class ServerData &amp;lt; BinData::Record
  uint16le :struct_size, :value =&amp;gt; lambda { num_bytes }
  uint32le :error_code
  string :error_msg, :length =&amp;gt; 100
  string :server_ip_addr, :length =&amp;gt; 16
  uint16le :server_port
  string :reserved, :length =&amp;gt; 100
  string :signature, :length =&amp;gt; 16
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The only hard part in the process was figuring out what datatypes to use for the windows types. Here are a few I had to use:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;WORD -&amp;gt; uint16le&lt;/li&gt;

&lt;li&gt;DWORD -&amp;gt; uint32le&lt;/li&gt;

&lt;li&gt;char&lt;span&gt;n&lt;/span&gt; -&amp;gt; string (with length &amp;#8216;n&amp;#8217;)&lt;/li&gt;

&lt;li&gt;BYTE&lt;span&gt;n&lt;/span&gt; -&amp;gt; Binary data (with length &amp;#8216;n&amp;#8217;)&lt;/li&gt;

&lt;li&gt;INT -&amp;gt; int32le&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As I was working my way thought the string I found it helpful to test the parsing one element at a time and make sure that is working. I would comment out all the elements but the first and try&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class LittleExample &amp;lt; BinData::Record
  uint16le :word_var
end

&amp;gt;&amp;gt; a = LittleExample.new
&amp;gt;&amp;gt; a.read( &amp;quot;\370\000\364\001\000\000&amp;quot;)
=&amp;gt; {&amp;quot;word_var&amp;quot;=&amp;gt;248}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One slick feature of BinData::Record is the ability to set default values. You can see in the ServerData example above I need to report the size of the struct, and since there are not dynamic length elements I can simply call the num_bytes method on the record:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class LengthData &amp;lt; BinData::Record
 uint16le :struct_size, :value =&amp;gt; lambda { num_bytes }
end

&amp;gt;&amp;gt; len = LengthData.new
=&amp;gt; {&amp;quot;struct_size&amp;quot;=&amp;gt;2}&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Browse vim command history</title>
		<link href="http://codeography.com/2009/04/16/browse-vim-command-history.html"/>
		<updated>2009-04-16T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/16/browse-vim-command-history</id>
		<content type="html">&lt;p&gt;This had happened accidentily a few times, and everytime I thought the feature was really cool but could not figure out how to bring it up.&lt;/p&gt;

&lt;p&gt;Well I finaly got it. In command mode enter &amp;#60;C-f&amp;#62; and you will get a fancy history.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Update the locate DB on OS X</title>
		<link href="http://codeography.com/2009/04/14/update-the-locate-db-on-os-x.html"/>
		<updated>2009-04-14T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/14/update-the-locate-db-on-os-x</id>
		<content type="html">&lt;p&gt;Turns out OS X does not have an &lt;code&gt;updatedb&lt;/code&gt; command like linux has, so I was stumped on how to update the locate database.&lt;/p&gt;

&lt;p&gt;After a little digging I found the command we needed:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo /usr/libexec/locate.updatedb&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It is a little paranoid about revealing file names, but it is happy to index everything for you.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Development environment for OS X</title>
		<link href="http://codeography.com/2009/04/13/development-environment-for-os-x.html"/>
		<updated>2009-04-13T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/13/development-environment-for-os-x</id>
		<content type="html">&lt;p&gt;I recently blew away all my developer tools, /usr/local and /opt (mac ports), and wanted to start with a clean install of my development tools. The following is my configuration for Ruby, Rails, iPhone and C++ development:&lt;/p&gt;

&lt;p&gt;Cleanup was done by removing the developer tools with the include perl script:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo /Developer/Library/uninstall-devtools --mode=all&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then I deleted /opt, which nuked all of the old macports I had installed.&lt;/p&gt;

&lt;p&gt;Then I cleaned out everything I thought I could from /usr/local/. I was mostly interested in removing the include, share, and lib folders from there. Just to be safe I didn&amp;#8217;t delete them outright, rather I moved them to a &amp;#8216;deleteme&amp;#8217; directory while I made sure I could get everything working again.&lt;/p&gt;

&lt;p&gt;Once cleanup was done, it was onto the reinstall.&lt;/p&gt;

&lt;p&gt;Install the developer tools, I grabbed the latest by downloading the iPhone SDK from the &lt;a href='http://developer.apple.com/iphone/'&gt;ADC&lt;/a&gt;&lt;/p&gt;

&lt;h2 id='install_macports'&gt;Install MacPorts&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;sudo port -v selfupdate&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='install_the_ports'&gt;Install the ports&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;sudo port install subversion +bash_completion git-core +bash_completion+doc+gitweb+svn ruby rb-rubygems rb-rake curl xercesc boost log4cpp cppunit mysql +server &lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='install_the_gems'&gt;Install the gems&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install rails &lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Resolve .local domains in Ubuntu</title>
		<link href="http://codeography.com/2009/04/11/resolve-.local-domains-in-ubuntu.html"/>
		<updated>2009-04-11T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/11/resolve-.local-domains-in-ubuntu</id>
		<content type="html">&lt;p&gt;Recently had a problem where i couldn&amp;#8217;t resolve any of our internal &amp;#8220;.local&amp;#8221; domain names. The weird thing was I could add a dns search to resolve.conf and resolve it by pinging the host name, but anytime I tried to use the fdqn it would fail&lt;/p&gt;

&lt;p&gt;Turns out the problem is the avahi-daemon. This can be disabled by editing&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/etc/defaults/avahi-daemon&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and changing the AVAHI_DAEMON_START to 0.&lt;/p&gt;

&lt;p&gt;Then you can remove the rc scripts with the following command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo update-rc.d -f avahi-daemon remove&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Installing Git on OS X with the fancy stuff</title>
		<link href="http://codeography.com/2009/04/11/installing-git-on-os-x-with-the-fancy-stuff.html"/>
		<updated>2009-04-11T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/11/installing-git-on-os-x-with-the-fancy-stuff</id>
		<content type="html">&lt;p&gt;To install git with macports use the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo port install git-core +doc+svn+bash_completion+gitweb&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Create a new post in Jekyll</title>
		<link href="http://codeography.com/2009/04/11/create-a-new-post-in-jekyll.html"/>
		<updated>2009-04-11T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/04/11/create-a-new-post-in-jekyll</id>
		<content type="html">&lt;p&gt;Worst thing about Jekyll is making a blog post by hand, so I wanted a clever way to automate it. I started with modifying jekyll it self to have a &amp;#8211;post option, but that didn&amp;#8217;t feel like the right place to put things. I am currently using a rake task that I borrowed from Dr. Nic&amp;#8217;s &lt;a href='http://github.com/drnic/jekyll_generator/tree/master'&gt;jekyll-generator&lt;/a&gt;, the extended it a little bit. The biggest improvement is looking for the EDITOR variable and loading the new post in that editor for quick editing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;desc &amp;quot;Creates a new _posts file using TITLE=&amp;#39;the title&amp;#39; and today&amp;#39;s date. JEKYLL_EXT=markdown by default&amp;quot;
task :post do
  ext = ENV[&amp;#39;JEKYLL_EXT&amp;#39;] || &amp;quot;markdown&amp;quot;
  unless title = ENV[&amp;#39;TITLE&amp;#39;]
	puts &amp;quot;USAGE: rake post TITLE=&amp;#39;the post title&amp;#39;&amp;quot;
	exit(1)
  end
  post_title = &amp;quot;#{Date.today.to_s(:db)}-#{title.downcase.gsub(/[^\w]+/, &amp;#39;-&amp;#39;)}&amp;quot;
  post_file = File.dirname(__FILE__) + &amp;quot;/_posts/#{post_title}.#{ext}&amp;quot;
  File.open(post_file, &amp;quot;w&amp;quot;) do |f|
	f &amp;lt;&amp;lt; &amp;lt;&amp;lt;-EOS.gsub(/^    /, &amp;#39;&amp;#39;)
	---
	layout: post
	title: #{title}
	---
	
	EOS
  end
  if (ENV[&amp;#39;EDITOR&amp;#39;])
	system (&amp;quot;#{ENV[&amp;#39;EDITOR&amp;#39;]} #{post_file}&amp;quot;) 
  end
end&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Getting Started with Jekyll</title>
		<link href="http://codeography.com/2009/03/30/getting-started-with-jekyll.html"/>
		<updated>2009-03-30T00:00:00-07:00</updated>
		<id>http://codeography.com/2009/03/30/getting-started-with-jekyll</id>
		<content type="html">&lt;p&gt;Install jekyll&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ sudo gem install mojombo-jekyll -s http://gems.github.com/ -s http://gems.rubyforge.org/&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Setup a site&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mkdir site
$ cd site&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make the base layout&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mkdir _layouts&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a file called base.html in site/_layouts:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt;
&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;{ {; page.title }}&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;div class=&amp;quot;container&amp;quot;&amp;gt;  
            { { content }}
        &amp;lt;/div&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make an about page:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mkdir about&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Create a file called index.html in site/about:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;---
layout: base
---
&amp;lt;h1&amp;gt;Getting started with Jekyll&amp;lt;/h1&amp;gt;

&amp;lt;p&amp;gt;I am not afraid of the command line&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now you should be able to run jekyll from your site directory&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;jekyll&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If that works, try running the built in server and take a look&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;jekyll --server&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And browse to &lt;a href='http://localhost:4000/about'&gt;http://localhost:4000/about&lt;/a&gt;&lt;/p&gt;

&lt;h2 id='add_some_style'&gt;Add some style&lt;/h2&gt;

&lt;p&gt;Well that&amp;#8217;s not very pretty, but shows that it works. Lets add some style. I like to use &lt;a href='http://blueprintcss.org/'&gt;Blueprint CSS&lt;/a&gt;, so I will add that. Feel free to use your own stylesheets, but this will give you a good starting point. You can download them from their website, or use the following wget&amp;#8217;s to just get up and running quick:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mkdir stylesheets
cd stylesheets
wget http://blueprintcss.org/blueprint/screen.css
wget http://blueprintcss.org/blueprint/print.css
wget http://blueprintcss.org/blueprint/ie.css 
cd ..&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='add_some_syntax_highlighting'&gt;Add some syntax highlighting&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;sudo port install py-pygments
cd stylesheets
wget http://tom.preston-werner.com/css/syntax.css&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id='add_a_feed'&gt;Add a feed&lt;/h2&gt;

&lt;p&gt;In the root of your site folder, create an &amp;#8216;atom.xml&amp;#8217; file with the following:&lt;/p&gt;
&lt;pre&gt;
---
layout: nil
---
&amp;#60;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&amp;#60;feed xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;

  &amp;#60;title&gt;Codeography&amp;#60;/title&gt;
  &amp;#60;link href=&quot;http://codeography.com/atom.xml&quot; rel=&quot;self&quot;/&gt;
  &amp;#60;link href=&quot;http://codeography.com/&quot;/&gt;
  &amp;#60;updated&gt;&amp;#123;&amp;#123;site.time | date_to_xmlschema }}&amp;#60;/updated&gt;
  &amp;#60;id&gt;http://codeography.com/&amp;#60;/id&gt;
  &amp;#60;author&gt;
    &amp;#60;name&gt;Christopher Sexton&amp;#60;/name&gt;
    &amp;#60;email&gt;&amp;#60;/email&gt;
  &amp;#60;/author&gt;
  &amp;#123;% for post in site.posts %}
  &amp;#60;entry&gt;
    &amp;#60;title&gt;&amp;#123;&amp;#123; post.title }}&amp;#60;/title&gt;
    &amp;#60;link href=&quot;http://codeography.com&quot;/&gt;
    &amp;#60;updated&gt;&amp;#123;&amp;#123;post.date | date_to_xmlschema }}&amp;#60;/updated&gt;
    &amp;#60;id&gt;http://codeography.com&amp;#123;&amp;#123; post.id }}&amp;#60;/id&gt;
    &amp;#60;content type=&quot;html&quot;&gt;{&amp;#123; post.content | xml_escape }}&amp;#60;/content&gt;
  &amp;#60;/entry&gt;
  &amp;#123;% endfor %}
&amp;#60;/feed&gt;
&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>shush-kaput</title>
		<link href="http://codeography.com/2009/01/24/shush-kaput.html"/>
		<updated>2009-01-24T00:00:00-08:00</updated>
		<id>http://codeography.com/2009/01/24/shush-kaput</id>
		<content type="html">&lt;p&gt;If there is one thing I like it is setting up ssh to use my public key so that I don&amp;#8217;t have to type a password when login to a server. This wasn&amp;#8217;t too hard, but since OSX does not have ssh-copy-id by default I would have to pull up &lt;a href='http://www.webficient.com/2007/11/16/mac-and-ssh-keys'&gt;the instructions&lt;/a&gt; every time to make sure I remembered the file names and permissions just right.&lt;/p&gt;

&lt;p&gt;So last night I made a ruby gem to remember how to do it for me, &lt;a href='http://github.com/csexton/ssh-keyput/'&gt;ssh-keyput&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now all I&amp;#8217;s got to do to copy my public key is:&lt;/p&gt;

&lt;p&gt;$ ssh-keyput chris@server.com&lt;/p&gt;

&lt;p&gt;To install all you need is a simple gem install:&lt;/p&gt;

&lt;p&gt;$ gem install csexton-ssh-keyput -s http://gems.github.com&lt;/p&gt;

&lt;p&gt;It is nothign bu a gloafied wrapper for a few shell commands, but it is much easier to remember&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Programming for fun?</title>
		<link href="http://codeography.com/2008/10/02/programming-for-fun.html"/>
		<updated>2008-10-02T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/10/02/programming-for-fun</id>
		<content type="html">&lt;p&gt;I&amp;#8217;ve been working on the cookbook application for the wife and couple interesting things.&lt;/p&gt;

&lt;p&gt;I use Dreamhost, and while they rock in alot of ways they won&amp;#8217;t let me have any long running processes. I wanted to add full text search to my cookbook (because if you can&amp;#8217;t find the recipe you want, what good is a cookbook) and I couldn&amp;#8217;t use the likes of Sphinx or Ferret. But if I changed my DB to MySQL (which dreamhost does provide) I can use the built in fulltext search. It is a little hackish, and MySQL specific but it works and is plenty fast for my needs.&lt;/p&gt;

&lt;p&gt;I had to do two things:&lt;/p&gt;

&lt;p&gt;1) Add a FULLTEXT index to my migration&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;  def self.up
    ...
    execute &amp;#39;ALTER TABLE recipes ENGINE = MyISAM&amp;#39;
    execute &amp;#39;CREATE FULLTEXT INDEX ft_idx_recipes ON recipes(title,ingredients,directions)&amp;#39;
  end

  def self.down
    execute &amp;#39;ALTER TABLE recipes DROP INDEX ft_idx_recipes&amp;#39;
    execute &amp;#39;ALTER TABLE recipes ENGINE = InnoDB&amp;#39;
    drop_table :recipes
  end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;2) In my recipes controller in the search action I have the following line&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; @recipes = Recipe.find_by_sql(&amp;quot;SELECT \* FROM recipes WHERE MATCH (title, ingredients, directions) AGAINST (&amp;#39;#{query.gsub(/&amp;#39;/, &amp;quot;&amp;#39;&amp;#39;&amp;quot;)}&amp;#39;);&amp;quot;)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The gsub bit is to sanitize the sql. Pretty simple really, and if I ever want to replace it all I need to do is modify the controller.&lt;/p&gt;

&lt;p&gt;I found out today that the Bort guys added OpenID support to the project. Which would normally involve some obscure svn/patch hijinks to deal with, but thanks to git I can just grab their changes (I did fork &lt;a href='http://github.com/csexton/cookbook/tree/master'&gt;my project&lt;/a&gt; from theirs to start with).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; git branch openid # incase I screw things up
 git checkout openid # use the new branch
 git pull git://github.com/fudgestudios/bort.git master
 # Fix any conflicts and merge back to master&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, did everyone know you can put alias in the .gitconfig file? Well, you never told me.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; [alias]
   co = checkout
   ci = commit
   st = status&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Instiki 0.13 Installation on Dreamhost with Passenger</title>
		<link href="http://codeography.com/2008/09/21/instiki-0.13-installation-on-dreamhost-with-passenger.html"/>
		<updated>2008-09-21T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/09/21/instiki-0.13-installation-on-dreamhost-with-passenger</id>
		<content type="html">&lt;p&gt;Running Instiki on Dreamhost has gotten much easier since they have added Passenger (mod_rails).&lt;/p&gt;

&lt;p&gt;Create a new fully hosted domain on dreamhost. Something like wiki.domain.com.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check the “Ruby on Rails Passenger (mod_rails)” box.&lt;/li&gt;

&lt;li&gt;In the Specify your web directory enter “wiki.yourdomain.com/instiki/public”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This &lt;strong&gt;will create&lt;/strong&gt; the wiki.domain.com folder in the user’s home directory. Login to your shell account and do the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd wiki.yourdomain.com
svn checkout svn://rubyforge.org/var/svn/instiki/instiki/trunk/ instiki
cd instiki
rake db:migrate RAILS_ENV=production&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Open wiki.yourdomain.com in your browser and set up the wiki.&lt;/p&gt;
&lt;a href='http://www.wiki.fuzzymonk.com/wiki/published/HomePage'&gt;Chuckle&lt;/a&gt;</content>
	</entry>
	
	<entry>
		<title>Using sqlite as a production DB</title>
		<link href="http://codeography.com/2008/09/20/using-sqlite-as-a-production-db.html"/>
		<updated>2008-09-20T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/09/20/using-sqlite-as-a-production-db</id>
		<content type="html">&lt;p&gt;I wanted to use sqlite3 as my production DB for a &lt;a href='http://github.com/csexton/cookbook/tree/master'&gt;little web app&lt;/a&gt; that I am working on.  Wasn&amp;#8217;t sure exactly what was going to be needed, but turns out if you add the following to your cap recipie you are all set. Shiny!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;task :after_update_code do
  run &amp;quot;ln -s #{deploy_to}/#{shared_dir}/db/production.sqlite3 #{current_release}/db/production.sqlite3&amp;quot;
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You might notice I am using bort as the starting point for cookbook. They really have done everything I need, in the way I need. Since I am using it with Dreamhost (read: Passenger) and git I really didn&amp;#8217;t need to undo ANYTHING.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Building Visual Studio Projects with Rake</title>
		<link href="http://codeography.com/2008/09/20/building-visual-studio-projects-with-rake.html"/>
		<updated>2008-09-20T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/09/20/building-visual-studio-projects-with-rake</id>
		<content type="html">&lt;p&gt;We are building a Rails applicaiton that has a C++ client developed under windows, and needed a nice way to script things.  Since the web side of the project was in rails it seemed natural to use rake to build the C++ stuff.  Pretty simple, but in order for the devenv to get loaded we had to load some of the envorment varables up for rake. Once that was done everyting has been easy.&lt;/p&gt;

&lt;p&gt;My Rakefile:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Visual Studio 2008 Environment Settings:
ENV[&amp;quot;VSINSTALLDIR&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0&amp;#39;
ENV[&amp;quot;VCINSTALLDIR&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0\VC&amp;#39;
ENV[&amp;quot;DevEnvDir&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE&amp;#39;
ENV[&amp;quot;PATH&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN;C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools;C:\WINDOWS\Microsoft.NET\Framework\v3.5;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\VC\VCPackages;&amp;#39; + ENV[&amp;quot;PATH&amp;quot;]
ENV[&amp;quot;INCLUDE&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\INCLUDE;C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE;C:\Program Files\boost\boost_1_35_0&amp;#39;
ENV[&amp;quot;LIB&amp;quot;] = &amp;#39;C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\boost\boost_1_35_0\lib&amp;#39;
ENV[&amp;quot;LIBPATH&amp;quot;] = &amp;#39;C:\WINDOWS\Microsoft.NET\Framework\v3.5;C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727;C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB;C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB&amp;#39;

# WiX Environment Settings
WIX_PATH=&amp;quot;\&amp;quot;C:/Program Files/Windows Installer XML v3/bin\&amp;quot;&amp;quot;
CANDLE= WIX_PATH + &amp;quot;candle&amp;quot;
LIGHT = WIX_PATH + &amp;quot;light&amp;quot;
desc &amp;quot;Build the project in release&amp;quot;
task &amp;#39;release&amp;#39; do
  system &amp;#39;VCBuild path/to/project.vcproj  Release /rebuild /nologo&amp;#39;
end
task :default =&amp;gt; [:release]&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Git on OS X</title>
		<link href="http://codeography.com/2008/07/13/git-on-os-x.html"/>
		<updated>2008-07-13T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/07/13/git-on-os-x</id>
		<content type="html">&lt;p&gt;I&amp;#8217;ve been tinkering with git, and git-svn. Starting to figure out how to cope, and am hopeful that the real coolness of distributed systems will become apparent soon.&lt;/p&gt;

&lt;p&gt;The real trick, was finally getting it to install with the options I had hoped for: svn integration, command completion and a custom bash prompt.&lt;/p&gt;

&lt;p&gt;First, to install it via Mac Ports (other articles I read had either &amp;#8220;+svn&amp;#8221; or &amp;#8220;+ bash_completion&amp;#8221;, but not both)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo port install git-core +bash_completion +svn +doc&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Set up &lt;a href='http://unboundimagination.com/Current-Git-Branch-in-Bash-Prompt'&gt;Arya Asemanfar's&lt;/a&gt; bash prompt and add git command completion.&lt;/p&gt;

&lt;p&gt;I added the following to .bash_login&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Command Completion
source /opt/local/etc/bash_completion.d/git
# Custom Prompt
parse_git_branch() {
  git branch 2&amp;gt; /dev/null | sed -e &amp;#39;/^[^\*]/d&amp;#39; -e &amp;#39;s/\* \(.\*\)/(git::\1)/&amp;#39;
}
parse_svn_branch() {
  parse_svn_url | sed -e &amp;#39;s#^&amp;#39;&amp;quot;$(parse_svn_repository_root)&amp;quot;&amp;#39;##g&amp;#39; | awk -F / &amp;#39;{print &amp;quot;(svn::&amp;quot;$1 &amp;quot;/&amp;quot; $2 &amp;quot;)&amp;quot;}&amp;#39;
}
parse_svn_url() {
  svn info 2&amp;gt;/dev/null | grep -e &amp;#39;^URL\*&amp;#39; | sed -e &amp;#39;s#^URL: \*\(.\*\)#\1#g &amp;#39;
}
parse_svn_repository_root() {
  svn info 2&amp;gt;/dev/null | grep -e &amp;#39;^Repository Root:\*&amp;#39; | sed -e &amp;#39;s#^Repository Root: \*\(.\*\)#\1\/#g &amp;#39;
}
export PS1=&amp;quot;\[\033[00m\]\u@\h:\[\033[01;34m\]\w \[\033[31m\]\$(parse_git_branch)\$(parse_svn_branch)\[\033[00m\]$\[\033[00m\] &amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Once you get to that point, I recommend heading over to &lt;a href='http://www.intridea.com/2008/6/18/going-rogue-with-git-svn-on-os-x'&gt;Intridea's&lt;/a&gt; Getting Rogue with git-svn, it has been a great help for me.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>CBT Error</title>
		<link href="http://codeography.com/2008/07/13/cbt-error.html"/>
		<updated>2008-07-13T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/07/13/cbt-error</id>
		<content type="html">&lt;p&gt;I was trying to complete some of the mandentory online training required by my company and got the following error on their website:&lt;/p&gt;
&lt;img class='picture' src='http://photos.fuzzymonk.com/blog/image/595/CBT-Windows-Error.jpg' /&gt;
&lt;p&gt;Best part is they support IE, Firefox under windows and Navigator under Linux. Not really sure why Safari and Firefox on OS X wouldn&amp;#8217;t work for them.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Javascript Code Prettifier</title>
		<link href="http://codeography.com/2008/06/13/javascript-code-prettifier.html"/>
		<updated>2008-06-13T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/06/13/javascript-code-prettifier</id>
		<content type="html">&lt;p&gt;I really liked the idea of the &lt;a href='http://google-code-prettify.googlecode.com/svn/trunk/README.html'&gt;Javascript Code Prettifier&lt;/a&gt;, and I really like my &lt;a href='http://www.fuzzymonk.com/svn/settings/vim/vimfiles/colors/ristoink.vim'&gt;personal color scheme&lt;/a&gt;, so I wanted to combine them. I thought it was turned out pretty neat, espcially since it only took about 20 min of tinkering to get everything sorted out, so I wanted to contribute back to the author &amp;#8211; but he provides no simple way to do that, so I will tell you about it. You who are prolly only coming here for the pics of Leah (see previous post).&lt;/p&gt;

&lt;p&gt;Here is my color scheme for JS Prettifier:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.str { color: #66FF00; }
.kwd { color: #AAAAAA; }
.com { color: #AA66FF; }
.typ { color: #DDE93D; }
.lit { color: #339999; }
.pun { color: #AAAAAA; }
.pln { color: #FFFFFF; }
.tag { color: #AAFFFF; }
.atn { color: #FF6600; }
.atv { color: #66FF00; }
.dec { color: #FF6600; }
pre.prettyprint { padding: 2px; border: 1px solid #888; background-color: #000000;}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The only other change is, I wanted the tags surrounding the code to be &amp;#60;pre class=&amp;#8221;code&amp;#8221;&amp;#62; instead of &amp;#60;pre class=&amp;#8221;prettyprint&amp;#8221;&amp;#62;, because I just type raw html and that would be shorter and easier to remember (at least for me).&lt;/p&gt;

&lt;p&gt;You can see those files directly:&lt;/p&gt;

&lt;ul&gt;
&lt;li /&gt;

&lt;li /&gt;
&lt;/ul&gt;

&lt;p&gt;Check out some fun ruby code (and it&amp;#8217;s whitespace independence):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;hash = { :water =&amp;gt; &amp;#39;wet&amp;#39;, :fire =&amp;gt; &amp;#39;hot&amp;#39; }
puts hash[:fire] # Prints:  hot
hash.each_pair do |key, value| # Or:  hash.each do |key, value|
       puts &amp;quot;#{key} is #{value}&amp;quot;
end
# Prints:  water is wet
#          fire is hot
hash.delete :water # Deletes :water =&amp;gt; &amp;#39;wet&amp;#39;
hash.delete_if {|k,value| value==&amp;#39;hot&amp;#39;} # Deletes :fire =&amp;gt; &amp;#39;hot&amp;#39;&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Dynamic Cheese Grater</title>
		<link href="http://codeography.com/2008/06/10/dynamic-cheese-grater.html"/>
		<updated>2008-06-10T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/06/10/dynamic-cheese-grater</id>
		<content type="html">&lt;p&gt;I decided I&amp;#8217;d like to access my home computer from work, specifically I wanted to be able to ssh into the machine. I used to do this by setting up a dynamic host name and just leaving my computer on all day long, but that hardly seemed like the best way to deal with it. More specifically, I didn&amp;#8217;t really want to pay for the electricity of running that thing all day long. So I decided to look into what I needed to do to get Wake-on-LAN to work with my Power Mac and FiOS modem.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First was to go back to Dyndns.com and get a hostname for my compy. I like the &amp;#8220;homeip.net&amp;#8221; ones, cause, it is in my home. &lt;/li&gt;

&lt;li&gt;Configure my router to port forward ssh (tcp on port 22) &lt;/li&gt;

&lt;li&gt;And wake-on-lan (udp on port 9) to my desktop.&lt;/li&gt;

&lt;li&gt;Configure OS X to allow ssh (System Prefrences - Sharing - Check &amp;#8220;Remote Login&amp;#8221;) &lt;/li&gt;

&lt;li&gt;And to allow wake-on-lan (System Prefrences - Energy Saver - Show Details - Check &amp;#8220;Wake for Ethernet&amp;#8230;&amp;#8221;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now I just needed a way to wake it up. First I played with &lt;a href='http://www.dslreports.com/wakeup'&gt;this web page&lt;/a&gt;, which worked, but required me to type in my Desktop&amp;#8217;s MAC address every time. Uncool. Then I found a little perl script that could do it, sorta. At that point I realized this was a job for ruby. And lo and behold I found K. Kodama &lt;a href='http://www.math.kobe-u.ac.jp/~kodama/tips-WakeOnLAN.html'&gt;WOL Class&lt;/a&gt;, which did nearly exactly what I wanted. I took that and hacked it up so my settings were all hard coded, added a she-bang, made it executable and linked to it from somewhere in my path. Now I can simply type &amp;#8220;wakebold&amp;#8221; and it will wake up my desktop at home (whom have affectionally named &amp;#8220;bold&amp;#8221;).&lt;/p&gt;

&lt;p&gt;My changes were really easy:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Configure the IP and MAC address for the computer you want here:

SETTINGS = { :mac_addr =&amp;gt; &amp;quot;00:00:00:00:00:00&amp;quot;, :host_name =&amp;gt; &amp;quot;example.homeip.net&amp;quot;}

if $0 == __FILE__
  wol=WakeOnLan.new
  wol.wake(SETTINGS[:mac_addr], &amp;quot;255.255.255.255&amp;quot;, SETTINGS[:host_name])
  wol.close
  puts &amp;quot;Waking up #{SETTINGS[:host_name]}&amp;quot;
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My hacked version can be found in my &lt;a href='http://www.fuzzymonk.com/svn/wakeywakey'&gt;svn repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To do all this, you can do the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;svn co http://www.fuzzymonk.com/svn/wakeywakey
chmod +x wakeywakey/wakey.rb
ln -s wakeywakey/wakey.rb /usr/local/bin/wakebold # or elsewhere in your path&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>The next post will be better.</title>
		<link href="http://codeography.com/2008/06/01/the-next-post-will-be-better.html"/>
		<updated>2008-06-01T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/06/01/the-next-post-will-be-better</id>
		<content type="html">&lt;p&gt;I&amp;#8217;ve been out in Oregon at RailsConf. As you might have noticed from twitter, I&amp;#8217;ve been here three days now. The Conference has been outstanding, and the people here make up one of the coolest communities I have ever been exposed too. The problem with the first few days out here was the happening going on back home. Three things really sucked the joy out of this otherwise awesome geektopia, a client at work who thinks fire alarms are the proper way to do business, getting my credit card number stolen, and the programming contest at work.&lt;/p&gt;

&lt;p&gt;Lets touch on these in reverse order. The contest was optional, but I have a teammate who worked very hard and I was not about to leave him hanging. Unfortunately I was out of town (here, in OR) when they were presenting the projects in the office. To handle this I created a screen cast. Which is not the quickest or easiest thing in the world to do. I quickly got a copy of QuickTime Pro and iShowU and threw something together. A few tries through and I was pretty happy. Figured one more try and I&amp;#8217;d be set. But nothing worked that time, it was 4 AM my time, and I had a decent run. So I uploaded it and crashed. It was just time to be done with that.&lt;/p&gt;

&lt;p&gt;It sucks to get your CC stolen. If the thief reads my blog: I canceled the account. And you are a mean jerk.&lt;/p&gt;

&lt;p&gt;The fire alarm as a development methodology is really starting to wear me out. I had been running strong with with the &amp;#8220;my project, my baby&amp;#8221; feeling, but as I have been reminded it isn&amp;#8217;t. Which really removes the desire to meet the&amp;#8211;artificial&amp;#8211;deadlines at all cost. I still want to succeed, but it is hard when the people who are helping you don&amp;#8217;t help. Sorta like the curly haired helper, but not cute nor do they give out hugs so happily.&lt;/p&gt;

&lt;p&gt;I am just burnt out on the project, and need something fresh. Or a vacation. Or a few weeks paternity leave.&lt;/p&gt;

&lt;p&gt;OK, a much happier post on the way, stay tuned.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Bash + Rake +</title>
		<link href="http://codeography.com/2008/03/23/bash-rake.html"/>
		<updated>2008-03-23T00:00:00-07:00</updated>
		<id>http://codeography.com/2008/03/23/bash-rake</id>
		<content type="html">&lt;p&gt;i wanted tab completion for rake tasks with bash on OS X, so&amp;#8230;&lt;/p&gt;

&lt;p&gt;I Installed the gem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install rake-command-completion&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then I added this to .bash_login (or .bashrc)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;complete -C /usr/local/bin/command_completion_for_rake -o default rake&lt;/code&gt;&lt;/pre&gt;</content>
	</entry>
	
	<entry>
		<title>Added a Trac-Hack</title>
		<link href="http://codeography.com/2008/03/07/added-a-trac-hack.html"/>
		<updated>2008-03-07T00:00:00-08:00</updated>
		<id>http://codeography.com/2008/03/07/added-a-trac-hack</id>
		<content type="html">&lt;img class='picture' src='http://photos.fuzzymonk.com/blog/image/595/RistoInk1-766603.png' border='0' /&gt;
&lt;p&gt;I heart trac, and I also heart VibrantInk, as well as my VibrantInk-based color scheme for Vim and Visual Studio.&lt;/p&gt;

&lt;p&gt;Earlier this week I spent a little time making a few tweaks to the css of Trac, and was able to get the code browser to show up in my beloved color scheme. After walking around all proud of my self, but everyone I told was more or less utterly unimpressed. So I decided to do the selfless thing and brag about it to the Trac community. Thus the &lt;a href='http://trac-hacks.org/wiki/VibrantInkCodeTheme'&gt;VibrantInkCodeTheme&lt;/a&gt; was born.&lt;/p&gt;

&lt;p&gt;My visual studio scheme is form John Lam&amp;#8217;s settings with a few minor tweaks&lt;/p&gt;

&lt;p&gt;My vim scheme is based the VividChalk theme by Tim Pope. I&amp;#8217;ve done a fair amount of work on this one, making it work under gVim, Windows CMD, gnome-terminal and the Mac Terminal. The tri-platform thing was a bit of a pain. Every time i got it just right under two of the three, it would break on the third. Seriously, you&amp;#8217;d think in the year 2008 we could get at least 256 colors in *all* the terminals.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Focused rails tests in vim!</title>
		<link href="http://codeography.com/2008/02/12/focused-rails-tests-in-vim.html"/>
		<updated>2008-02-12T00:00:00-08:00</updated>
		<id>http://codeography.com/2008/02/12/focused-rails-tests-in-vim</id>
		<content type="html">&lt;p&gt;&lt;a href='http://rails.vim.tpope.net/'&gt;Rails.vim&lt;/a&gt; allows you to run focused tests (ala TextMate) buy placing the cursor in the method and running :Rake.&lt;/p&gt;

&lt;p&gt;This is teh coolness.&lt;/p&gt;</content>
	</entry>
	
	<entry>
		<title>Vim on Vista</title>
		<link href="http://codeography.com/2007/11/22/vim-on-vista.html"/>
		<updated>2007-11-22T00:00:00-08:00</updated>
		<id>http://codeography.com/2007/11/22/vim-on-vista</id>
		<content type="html">&lt;p&gt;Ok, so I wasted a good part of thanksgiving day trying to get vim workign again on vista. I am not sure what happened, but it went nuts. It may have been the recent windows updates or the face that I in stalled .NET 3.5, but it was unusable. None of the plugins/syntax highlighting/menus that I have grown to love. So here is what I did:&lt;/p&gt;

&lt;p&gt;Vim on Vista&lt;/p&gt;

&lt;p&gt;Installed gvim71-2.exe to C:\vim (&lt;a href='http://hasno.info/2007/5/18/windows-vim-7-1-2'&gt;from here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Copy the folling files into C:\vim\vim71\&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iconv.dll (&lt;a href='http://sourceforge.net/projects/gettext'&gt;from here&lt;/a&gt; You can find the dll file in the bin directory of the &amp;#8220;libiconv-win32&amp;#8221; archive.)&lt;/li&gt;

&lt;li&gt;libintl.dll (&lt;a href='http://sourceforge.net/projects/gettext'&gt;from here&lt;/a&gt; Get &amp;#8220;intl.dll&amp;#8221; from the bin directory in the gettext-win32 archive and store it as &amp;#8220;libintl.dll&amp;#8221; in the same directory as gvim.exe, overwriting the file that may already be there.)&lt;/li&gt;

&lt;li&gt;gvimext.dll (&lt;a href='http://www.vim.org/scripts/script.php?script_id=1720'&gt;from here&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the thing that stuck me for hours, if you had previously installed vim&lt;/p&gt;

&lt;p&gt;to the recommended location of C:\Program Files you won&amp;#8217;t be able to associate&lt;/p&gt;

&lt;p&gt;files with the new location until you edit the registry. Go to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;HKEY_CLASSES_ROOT\Applications\gvim.exe&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Make sure the edit\command and open\command Keys have the following default value:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;C:\vim\vim71\gvim.exe &amp;quot;%1&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you want the &amp;#8220;Edit with vim&amp;#8221; in windows explorer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run C:\vim\vim71\install.exe&lt;/li&gt;

&lt;li&gt;Choose no when asked if you want to uninstall, then enter &amp;#8220;d 14&amp;#8221;If you get a gvim not in your path error with the &amp;#8220;Edit with vim&amp;#8221; shell ext, make sure you don&amp;#8217;t have gvim.exe set to run as Administrator, as that will break it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don&amp;#8217;t want to run around and get those files, you can download them &lt;a href='http://www.blogger.com/files/vimvista.zip'&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, I added my suite of vim files &lt;a href='http://www.blogger.com/files/vimfiles.zip'&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
	</entry>
	
</feed>


