<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: Caffo's Code Snippets</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 22:19:29 GMT</pubDate>
    <description>DZone Snippets: Caffo's Code Snippets</description>
    <item>
      <title>rake task to rename views to rails 2.0 format </title>
      <link>http://snippets.dzone.com/posts/show/5262</link>
      <description>// This task will rename your files to the rails 2.0 format, using git mv. Add it to /lib/tasks/rails.rake&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;namespace 'views' do&lt;br /&gt;  desc 'Renames all .rhtml views to .html.erb, .rjs to .js.rjs, .rxml to .xml.builder, and .haml to .html.haml'&lt;br /&gt;  task 'rename' do&lt;br /&gt;    Dir.glob('app/views/**/[^_]*.rhtml').each do |file|&lt;br /&gt;      puts `git mv #{file} #{file.gsub(/\.rhtml$/, '.html.erb')}`&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    Dir.glob('app/views/**/[^_]*.rxml').each do |file|&lt;br /&gt;      puts `git mv #{file} #{file.gsub(/\.rxml$/, '.xml.builder')}`&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    Dir.glob('app/views/**/[^_]*.rjs').each do |file|&lt;br /&gt;      puts `git mv #{file} #{file.gsub(/\.rjs$/, '.js.rjs')}`&lt;br /&gt;    end&lt;br /&gt;    Dir.glob('app/views/**/[^_]*.haml').each do |file|&lt;br /&gt;      puts `git mv #{file} #{file.gsub(/\.haml$/, '.html.haml')}`&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 20 Mar 2008 03:11:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5262</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>overwrite heroku code with an alien git repository</title>
      <link>http://snippets.dzone.com/posts/show/5243</link>
      <description>// Use this command in your repos directory to push to your heroku repos. Useful for github / heroku sync.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;git push -v -f git@heroku.com:&lt;application&gt;.git&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 18 Mar 2008 06:15:51 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5243</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>delicious read later bookmarklet</title>
      <link>http://snippets.dzone.com/posts/show/5195</link>
      <description>&lt;code&gt;&lt;br /&gt;javascript:delicious=window.open('https://api.del.icio.us/v1/posts/add?description='+encodeURIComponent(document.title)+'&amp;tags=2read'+'&amp;url='+window.location.href,'delicious','toolbar=no,width=50,height=50');setTimeout('delicious.close()',1500);&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 03 Mar 2008 01:51:24 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5195</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>css properties reset</title>
      <link>http://snippets.dzone.com/posts/show/5176</link>
      <description>&lt;code&gt;&lt;br /&gt;html, body, div, span, applet, object, iframe,&lt;br /&gt;h1, h2, h3, h4, h5, h6, p, blockquote, pre,&lt;br /&gt;a, abbr, acronym, address, big, cite, code,&lt;br /&gt;del, dfn, em, font, img, ins, kbd, q, s, samp,&lt;br /&gt;small, strike, strong, sub, sup, tt, var,&lt;br /&gt;b, u, i, center,&lt;br /&gt;dl, dt, dd, ol, ul, li,&lt;br /&gt;fieldset, form, label, legend,&lt;br /&gt;table, caption, tbody, tfoot, thead, tr, th, td {&lt;br /&gt;	margin: 0;&lt;br /&gt;	padding: 0;&lt;br /&gt;	border: 0;&lt;br /&gt;	outline: 0;&lt;br /&gt;	font-size: 100%;&lt;br /&gt;	vertical-align: baseline;&lt;br /&gt;	background: transparent;&lt;br /&gt;}&lt;br /&gt;body {&lt;br /&gt;	line-height: 1;&lt;br /&gt;}&lt;br /&gt;ol, ul {&lt;br /&gt;	list-style: none;&lt;br /&gt;}&lt;br /&gt;blockquote, q {&lt;br /&gt;	quotes: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* remember to define focus styles! */&lt;br /&gt;:focus {&lt;br /&gt;	outline: 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* remember to highlight inserts somehow! */&lt;br /&gt;ins {&lt;br /&gt;	text-decoration: none;&lt;br /&gt;}&lt;br /&gt;del {&lt;br /&gt;	text-decoration: line-through;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/* tables still need 'cellspacing="0"' in the markup */&lt;br /&gt;table {&lt;br /&gt;	border-collapse: collapse;&lt;br /&gt;	border-spacing: 0;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 26 Feb 2008 01:08:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5176</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>isWorkingDay?</title>
      <link>http://snippets.dzone.com/posts/show/5135</link>
      <description>// description of your code here&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  public boolean isWorkingDay(Date date) {&lt;br /&gt;        Calendar cal = GregorianCalendar.getInstance();&lt;br /&gt;        cal.setTime(date);&lt;br /&gt;        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); &lt;br /&gt;        if ((dayOfWeek  Calendar.SATURDAY) || (dayOfWeek  Calendar.SUNDAY)) {&lt;br /&gt;            return false;&lt;br /&gt;        } &lt;br /&gt;        return true;&lt;br /&gt;   }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 13 Feb 2008 02:45:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5135</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>install rmagick on leopard</title>
      <link>http://snippets.dzone.com/posts/show/4798</link>
      <description>&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz&lt;br /&gt;tar xzvf freetype-2.3.5.tar.gz&lt;br /&gt;cd freetype-2.3.5&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.22.tar.bz2&lt;br /&gt;tar jxvf libpng-1.2.22.tar.bz2&lt;br /&gt;cd libpng-1.2.22&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz&lt;br /&gt;tar xzvf jpegsrc.v6b.tar.gz&lt;br /&gt;cd jpeg-6b&lt;br /&gt;ln -s `which glibtool` ./libtool&lt;br /&gt;export MACOSX_DEPLOYMENT_TARGET=10.5&lt;br /&gt;./configure --enable-shared --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz&lt;br /&gt;tar xzvf tiff-3.8.2.tar.gz&lt;br /&gt;cd tiff-3.8.2&lt;br /&gt;./configure --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz&lt;br /&gt;tar xzvf libwmf-0.2.8.4.tar.gz&lt;br /&gt;cd libwmf-0.2.8.4&lt;br /&gt;make clean&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O http://www.littlecms.com/lcms-1.17.tar.gz&lt;br /&gt;tar xzvf lcms-1.17.tar.gz&lt;br /&gt;cd lcms-1.17&lt;br /&gt;make clean&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz&lt;br /&gt;tar zxvf ghostscript-8.60.tar.gz&lt;br /&gt;cd ghostscript-8.60/&lt;br /&gt;./configure  --prefix=/usr/local&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz&lt;br /&gt;tar zxvf ghostscript-fonts-std-8.11.tar.gz&lt;br /&gt;sudo mv fonts /usr/local/share/ghostscript&lt;br /&gt;&lt;br /&gt;curl -O http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz&lt;br /&gt;tar xzvf ImageMagick-6.3.5-9.tar.gz&lt;br /&gt;cd ImageMagick-6.3.5&lt;br /&gt;export CPPFLAGS=-I/usr/local/include&lt;br /&gt;export LDFLAGS=-L/usr/local/lib&lt;br /&gt;./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts&lt;br /&gt;make&lt;br /&gt;sudo make install&lt;br /&gt;cd ..&lt;br /&gt;&lt;br /&gt;sudo gem install RMagick&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 19 Nov 2007 21:59:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4798</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>Ruby : sort an array of hashes</title>
      <link>http://snippets.dzone.com/posts/show/4733</link>
      <description>// will sort an array of hashes by key&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;my_arr.sort_by { |my_item| my_item[:my_key] }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;</description>
      <pubDate>Sun, 04 Nov 2007 18:16:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4733</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>rubygems update</title>
      <link>http://snippets.dzone.com/posts/show/4163</link>
      <description>&lt;code&gt;&lt;br /&gt;sudo gem update &#8211;system&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 19 Jun 2007 18:53:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4163</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>install rmagick ubuntu</title>
      <link>http://snippets.dzone.com/posts/show/4140</link>
      <description>let's undo some of the damage (just in case):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo apt-get remove --purge librmagick-ruby-doc librmagick-ruby1.8&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Next let's get the version we need:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo apt-get install libmagick9-dev ruby1.8-dev&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Lastly, go grab rmagick, the gem&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo gem install rmagick&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 14 Jun 2007 02:44:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4140</guid>
      <author>caffo ()</author>
    </item>
    <item>
      <title>.autotest file</title>
      <link>http://snippets.dzone.com/posts/show/3718</link>
      <description>&lt;code&gt;&lt;br /&gt;require 'autotest/redgreen'&lt;br /&gt;require 'autotest/timestamp'&lt;br /&gt;#require 'autotest/growl'&lt;br /&gt;&lt;br /&gt;#require 'autotest/html_report'&lt;br /&gt;#require 'autotest/kdenotify'&lt;br /&gt;#require 'autotest/menu'&lt;br /&gt;#require 'autotest/pretty'&lt;br /&gt;#require 'autotest/snarl'&lt;br /&gt;&lt;br /&gt;# Sort-of from http://blog.labratz.net/articles/2006/09/13/growl-autotest-rails-with-zentest-3-4-0&lt;br /&gt;def growl(title, msg, pri=0, stick="", image="")&lt;br /&gt;  image_arg = (!image.empty?) ? "--image #{image}" : ""&lt;br /&gt;  system "growlnotify -n autotest #{image_arg} -p #{pri} -m #{msg.inspect} #{title} #{stick}" &lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Autotest.add_hook :red do |at|&lt;br /&gt;  growl("Tests Failed", "#{at.files_to_test.size} tests failed", 2, "", "/Applications/Mail.app/Contents/Resources/Caution.tiff")&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;Autotest.add_hook :green do |at|&lt;br /&gt;  growl("Tests Passed", "All tests passed", -2, "", "/Applications/Mail.app/Contents/Resources/certificate.tiff") #if at.tainted&lt;br /&gt;end  &lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 23 Mar 2007 10:31:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3718</guid>
      <author>caffo ()</author>
    </item>
  </channel>
</rss>
