<?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>2010-07-28T07:49:38-07:00</updated>
	<id>http://codeography.com/</id>
	<author>
		<name>Christopher Sexton</name>
		<email></email>
	</author>
	
	<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;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://kernel.org/pub/software/scm/git/git-manpages-1.6.4.2.tar.bz2&amp;quot;
sudo tar xjv -C /usr/local/share/man -f git-manpages-1.6.4.2.tar.bz2&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://kernel.org/pub/software/scm/git/git-manpages-`git --version | awk &amp;#39;{print $3}&amp;#39;`.tar.bz2&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 will create 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>

