<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Patrick Crosby's Internet Presents</title>
 
 <link href="http://blog.patrickcrosby.com" />
 <updated>2009-11-03T13:43:51-05:00</updated>
 <id>http://blog.patrickcrosby.com</id>
 <author>
   <name>Patrick Crosby</name>
 </author>

 
 <link rel="self" href="http://feeds.feedburner.com/patrickcrosby" type="application/atom+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">patrickcrosby</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry>
   <title>Create new git repository with gitosis</title>
   <link href="http://blog.patrickcrosby.com/2009/11/03/gitosis-new-repository.html" />
   <updated>2009-11-03T00:00:00-05:00</updated>
   <id>http://blog.patrickcrosby.com/2009/11/03/gitosis-new-repository</id>
   <content type="html">&lt;p&gt;Assuming gitosis already set up and working&amp;#8230;&lt;/p&gt;

&lt;p&gt;Edit &lt;code&gt;gitosis-admin/gitosis.conf&lt;/code&gt; and add the new repository.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[group company]
members = jackblack
writable = examproj&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Commit this and push it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git commit -a -m &amp;quot;added examproj&amp;quot;
git push&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In a local repository (you&amp;#8217;ve already called &lt;code&gt;git init&lt;/code&gt; and done your initial commit), push the repository to the server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git remote add origin git@code.example.com:examproj.git
git push origin master:refs/heads/master&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then pull it to where you want it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;cd ~/git
git pull git@code.example.com:examproj.git&lt;/code&gt;&lt;/pre&gt;</content>
 </entry>
 
 <entry>
   <title>git tags</title>
   <link href="http://blog.patrickcrosby.com/2009/11/03/git-tags.html" />
   <updated>2009-11-03T00:00:00-05:00</updated>
   <id>http://blog.patrickcrosby.com/2009/11/03/git-tags</id>
   <content type="html">&lt;p&gt;Some notes on how to use tags in git:&lt;/p&gt;

&lt;p&gt;You should always use the &lt;code&gt;-a&lt;/code&gt; switch (or sign it). &lt;a href='http://www.rockstarprogrammer.org/post/2008/oct/16/git-tag-does-wrong-thing-default/'&gt;Explanation here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To tag and the push to remote:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git tag -a v1.0.0 -m &amp;quot;version 1.0!!!&amp;quot;
git push --tags&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then, in the future, to get the code at the tag point and do stuff with it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout -b fromtag1.0 v1.0.0
&amp;lt;do some stuff&amp;gt;
git commit ...&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then back in the master, you can merge that branch back in:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git checkout master
git merge fromtag1.0
git push&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s enough for now&amp;#8230;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Max OS X Animated GIF Editor Champion -- Pixen</title>
   <link href="http://blog.patrickcrosby.com/2009/10/30/mac-os-x-animated-gif-editor-pixen.html" />
   <updated>2009-10-30T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/10/30/mac-os-x-animated-gif-editor-pixen</id>
   <content type="html">&lt;p&gt;I needed to edit an animated gif on Mac OS X today&amp;#8230;tried Acorn, but it doesn&amp;#8217;t seem to support them. Tried Gimp, but it was unusable&amp;#8230;could be user error, but every tool I selected would not stay selected and I couldn&amp;#8217;t paste between documents.&lt;/p&gt;

&lt;p&gt;Then I downloaded &lt;a href='http://opensword.org/Pixen/'&gt;Pixen&lt;/a&gt; and despite it crashing the first time I tried saving the GIF, it worked great. And it&amp;#8217;s free.&lt;/p&gt;

&lt;p&gt;One note: if you use multiple layers in the frames, you need to merge them into one layer for the output to be correct.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Authlogic, Passenger, and cookie_store Sessions Don't Mix</title>
   <link href="http://blog.patrickcrosby.com/2009/10/29/authlogic-and-cookie-session-store-dont-mix.html" />
   <updated>2009-10-29T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/10/29/authlogic-and-cookie-session-store-dont-mix</id>
   <content type="html">&lt;p&gt;There seems to be a problem with Authlogic, Passenger, and &lt;code&gt;cookie_store&lt;/code&gt; sessions. You can read some details &lt;a href='http://github.com/binarylogic/authlogic/commit/495e95e5a2f724e6f1e339c4871168c6c5e6a7ca'&gt;on this github commit&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A lot of the commenters keep saying that it gets fixed for them with newer versions of rails/passenger, but I&amp;#8217;m having trouble with the rails 2.3.4, passenger 2.2.5, and authlogic 2.1.2 (all the latest versions as of this post). It was working fine at some point&amp;#8230;&lt;/p&gt;

&lt;p&gt;The fix? Use the old &lt;code&gt;:active_record_store&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Add the following to &lt;code&gt;config/environment.rb&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;config.action_controller.session_store = :active_record_store&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then run&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;rake db:sessions:create&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For PostgreSQL, I changed the migration it generates to the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class CreateSessions &amp;lt; ActiveRecord::Migration
  def self.up
    create_table :sessions do |t|
      t.text :session_id, :null =&amp;gt; false
      t.text :data
      t.timestamps
    end

    add_index :sessions, :session_id
    add_index :sessions, :updated_at
  end

  def self.down
    drop_table :sessions
  end
end   &lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(column type for &lt;code&gt;:session_id&lt;/code&gt; changed from &lt;code&gt;string&lt;/code&gt; to &lt;code&gt;text&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;I imagine that &lt;code&gt;:mem_cache_store&lt;/code&gt; would fix it as well&amp;#8230;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails to_xml with procs</title>
   <link href="http://blog.patrickcrosby.com/2009/10/15/rails-to-xml-with-procs.html" />
   <updated>2009-10-15T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/10/15/rails-to-xml-with-procs</id>
   <content type="html">&lt;p&gt;Ever wanted to add something to the xml representation of an ActiveRecord object that wasn&amp;#8217;t a method or an include? You can with procs.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;respond_to do |format|
  format.xml do
    proc = Proc.new { |options| options[:builder].tag!(&amp;#39;saved&amp;#39;, current_user.saved?(@page)) }
    render :xml =&amp;gt; @page.to_xml(:include =&amp;gt; [:user], :procs =&amp;gt; [proc])
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And now this will spit out:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;
&amp;lt;page&amp;gt;
  &amp;lt;content&amp;gt;So here&amp;#39;s line 1&amp;lt;/content&amp;gt;
  &amp;lt;created-at type=&amp;quot;datetime&amp;quot;&amp;gt;2009-10-15T16:50:57Z&amp;lt;/created-at&amp;gt;
  &amp;lt;dictionary-id type=&amp;quot;integer&amp;quot;&amp;gt;1&amp;lt;/dictionary-id&amp;gt;
  &amp;lt;saved&amp;gt;false&amp;lt;/saved&amp;gt;
&amp;lt;/page&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this case, the model doesn&amp;#8217;t know anything about the user and I wanted to keep it that way, but the XML api call needs to include the saved state.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Vim Objective-C Colon Indentation</title>
   <link href="http://blog.patrickcrosby.com/2009/10/02/vim-objective-c-colon-lineup.html" />
   <updated>2009-10-02T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/10/02/vim-objective-c-colon-lineup</id>
   <content type="html">&lt;p&gt;Vim&amp;#8217;s objective-c mode has an annoying indentation issue. It tries to line colons up on subsequent lines, like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[self performSelectorOnMainThread:@selector(finishLoad) 
                       withObject:nil 
                    waitUntilDone:NO];&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s nice, but it has an annoying bug that makes it try to align the colons with a previous line that is unrelated:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if ([someVariable isEqualToString:@&amp;quot;blah&amp;quot;]) {
[self performSelectorOnMainThread:@selector(finishLoad) 
                       withObject:nil 
                    waitUntilDone:NO];
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This all takes place in &lt;code&gt;indent/objc.vim&lt;/code&gt; (full path on a MacPorts installation is &lt;code&gt;/opt/local/share/vim/vim72/indent/objc.vim&lt;/code&gt;, for MacVim it is &lt;code&gt;/Applications/MacVim.app/Contents/Resources/vim/runtime/indent/objc.vim&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;There is probably a way to fix this in a &lt;code&gt;.vimrc&lt;/code&gt; file, but I just edited &lt;code&gt;objc.vim&lt;/code&gt;. At the bottom of the file is a function &lt;code&gt;GetObjCIndent&lt;/code&gt;. Change the second &lt;code&gt;if&lt;/code&gt; statement to match the following:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function GetObjCIndent()
    let theIndent = cindent(v:lnum)

    let prev_line = getline(v:lnum - 1)
    let cur_line = getline(v:lnum)
        
    if prev_line !~# &amp;quot;:&amp;quot; || cur_line !~# &amp;quot;:&amp;quot;
        return theIndent
    endif
     
    if prev_line !~# &amp;quot;;&amp;quot; &amp;amp;&amp;amp; prev_line !~# &amp;quot;{&amp;quot;
        let prev_colon_pos = s:GetWidth(prev_line, &amp;quot;:&amp;quot;)
        let delta = s:GetWidth(cur_line, &amp;quot;:&amp;quot;) - s:LeadingWhiteSpace(cur_line)
        let theIndent = prev_colon_pos - delta
    endif
        
    return theIndent
endfunction&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are some refinements that could be made to fix it for more cases, but this one fixes the one that was driving me crazy.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Vim ack plugin with MacVim and MacPorts</title>
   <link href="http://blog.patrickcrosby.com/2009/10/01/vim-ack-plugin-with-macvim.html" />
   <updated>2009-10-01T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/10/01/vim-ack-plugin-with-macvim</id>
   <content type="html">&lt;p&gt;The &lt;a href='http://www.vim.org/scripts/script.php?script_id=2572'&gt;vim ack plugin&lt;/a&gt; doesn&amp;#8217;t work if you use MacVim and MacPorts. The problem is the path (&lt;code&gt;/opt/local/bin/ack&lt;/code&gt;). MacVim doesn&amp;#8217;t get its path from your login shell (despite what the preferences page says) and &lt;code&gt;/opt/local/bin&lt;/code&gt; isn&amp;#8217;t a default path.&lt;/p&gt;

&lt;p&gt;The way to fix it is to add a file to &lt;code&gt;/etc/paths.d&lt;/code&gt; with one line it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/opt/local/bin&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can call the file whatever you want. Restart MacVim and &lt;code&gt;:Ack&lt;/code&gt; will work.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Safari Keyboard Shortcuts To Switch Tabs</title>
   <link href="http://blog.patrickcrosby.com/2009/09/10/safari-keyboard-shortcuts-to-switch-tabs.html" />
   <updated>2009-09-10T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/09/10/safari-keyboard-shortcuts-to-switch-tabs</id>
   <content type="html">&lt;p&gt;&lt;img src='/media/photos/zebras.jpg' alt='zebras' /&gt; &lt;em&gt;Photo by &lt;a href='http://www.flickr.com/photos/wwarby/2405490902/'&gt;wwarby&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I am so used to the cmd-1, cmd-2, cmd-3, cmd-9 keyboard shortcuts in Firefox to switch to the first, second, third, and last tabs in a window. Whenever I try to use Safari and I instinctually use these shortcuts, it goes to bookmarks (1, 2, 3, and 9), which is incredibly annoying. Apple provides no way to change this.&lt;/p&gt;

&lt;p&gt;With Leopard, I was using &lt;a href='http://store.giraffesoft.ca/'&gt;Safari Commander&lt;/a&gt;, but it stopped working with Snow Leopard. There are &lt;a href='http://twitter.com/jamesgolick/status/3618013749'&gt;hints on twitter&lt;/a&gt; that a new version is coming out soon that will work, but it requires Safari to run in 32-bit mode. And Firefox seems to be slower than usual under Snow Leopard.&lt;/p&gt;

&lt;p&gt;So the solution? &lt;a href='http://www.red-sweater.com/fastscripts/'&gt;Fastscripts&lt;/a&gt;. Thanks to &lt;a href='http://justinblanton.com/2009/02/go-to-safari-tab-with-keyboard'&gt;this blog post&lt;/a&gt; by &lt;a href='http://justinblanton.com/'&gt;Justin Blanton&lt;/a&gt;, I now have scripts to switch to tabs one through five and the last tab. I modified his scripts to be for Safari instead of WebKit. They are each one line long, but in case you&amp;#8217;re too lazy to type them in, here they are for you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href='/media/code/tab1.scpt'&gt;tab1.scpt&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/media/code/tab2.scpt'&gt;tab2.scpt&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/media/code/tab3.scpt'&gt;tab3.scpt&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/media/code/tab4.scpt'&gt;tab4.scpt&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/media/code/tab5.scpt'&gt;tab5.scpt&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href='/media/code/tab9.scpt'&gt;tab9.scpt&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put them in &lt;code&gt;~/Library/Scripts/Applications/Safari&lt;/code&gt; then assign them to the correct keys in the &lt;em&gt;Script Shortcuts&lt;/em&gt; preferences pane in FastScripts.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Jekyll Script</title>
   <link href="http://blog.patrickcrosby.com/2009/09/08/jekyll-script.html" />
   <updated>2009-09-08T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/09/08/jekyll-script</id>
   <content type="html">&lt;p&gt;Speaking &lt;a href='http://blog.patrickcrosby.com/2009/09/02/Jekyll-blog-engine.html'&gt;of&lt;/a&gt; &lt;a href='http://blog.patrickcrosby.com/2009/09/05/jekyll-exclude-files.html'&gt;jekyll&lt;/a&gt;, there&amp;#8217;s a way to get git to publish using post-commit hooks, but I like running a little script to do it. It just runs &lt;code&gt;jekyll&lt;/code&gt; to build the site, then calls &lt;code&gt;rsync&lt;/code&gt; to make it live (it connects to the server over ssh).&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/bin/sh

echo &amp;quot;running jekyll&amp;quot;
jekyll --no-auto
echo &amp;quot;rsyncing site with blog server&amp;quot;
cd _site &amp;amp;&amp;amp; rsync -Cavz --delete . example.com:/var/www/blog.example.com
echo &amp;quot;done&amp;quot;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That&amp;#8217;s it&amp;#8230;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Jekyll Exclude Files</title>
   <link href="http://blog.patrickcrosby.com/2009/09/05/jekyll-exclude-files.html" />
   <updated>2009-09-05T00:00:00-04:00</updated>
   <id>http://blog.patrickcrosby.com/2009/09/05/jekyll-exclude-files</id>
   <content type="html">&lt;p&gt;By default, &lt;a href='http://blog.patrickcrosby.com/2009/09/02/Jekyll-blog-engine.html'&gt;jekyll&lt;/a&gt; will copy everything in the source directory into &lt;code&gt;_site&lt;/code&gt;, but there&amp;#8217;s an undocumented feature that lets you exclude or ignore files. A configuration variable named &lt;code&gt;exclude&lt;/code&gt; exists. Any files or directories listed will be ignored. For example, the following is in my &lt;code&gt;_config.yml&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;exclude: [&amp;quot;makelive.sh&amp;quot;]&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;so that the script that syncs the site with the live version isn&amp;#8217;t copied onto the live site.&lt;/p&gt;</content>
 </entry>
 
 
</feed>
