SpicyCode - The ramblings of Chad Humphries2013-12-18T12:19:05-08:00http://spicycode.com/Chad Humphrieschad@spicycode.comHoliday Lessons2011-12-26T00:00:00-08:00http://spicycode.com/2011/12/26/holiday-lessons<h1>Holiday Lessons</h1>
<p class="meta">26 Dec 2011</p>
<p>1) I can almost, <em>almost</em>, explain regular expressions to random people. I'm not sure how this came up.</p>
<p>2) Nothing beats a kick-ass race track with a loop when it comes to Christmas presents.</p>
<p>3) Friends leaving and joining Relevance. I love all the new people, but I'll miss Shay, Jess, and Aaron! All of you keep rocking.</p>
Recent improvements to RSpec 22010-06-20T00:00:00-07:00http://spicycode.com/2010/06/20/recent-improvements-to-rspec-2<h1>Recent improvements to RSpec 2</h1>
<p class="meta">20 Jun 2010</p>
<p>I just pushed the following two changes into rspec-core. They should show up in rspec-core 2.0.0.beta.13.</p>
<h1>You can specify the path to rcov finally!</h1>
<p>A good use is to set it to <em>bundle exec rcov</em>.</p>
<h1>RSpec rake task no longer shells out to ruby!</h1>
<p>Back in the day (i.e. before June 19th, 2010), when you ran <code>rake spec</code> it loads your project files, and then it calls out ala <em>system ruby ....</em>. This makes everyone sad if your project takes a while to load.</p>
<p>Now, we invoke the RSpec runner via code! So if your project environment takes a while to load, look forward to this in the next release!</p>
This is why RVM is cool2010-03-03T00:00:00-08:00http://spicycode.com/2010/03/03/this-is-why-rvm-is-cool<h1>This is why RVM is cool</h1>
<p class="meta">03 Mar 2010</p>
<h2>Step 1</h2>
<p>Take a directory, any directory. Sprinkle a <em>.rvmrc</em> file in the directory.</p>
<h2>Step 2</h2>
<p>Put "rvm your-ruby-version" in the file.</p>
<h2>Step 3</h2>
<p>Magic! Let’s test this in the real world…</p>
<pre><code>~/src/codes > ruby -v
ruby 1.9.2dev (2010-02-25 trunk 26759) [x86_64-darwin10]
~/src/codes > cd internet_superstar
~/src/codes/internet_superstar /msater > ruby -v
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-darwin10.2.0]
~/src/codes/internet_superstar /msater > cat .rvmrc
rvm ree
</code></pre>
<p>Want the full scoop? Check out the <a href="http://rvm.beginrescueend.com/workflow/rvmrc/">docs</a>.</p>
Updated shortcuts for Rails 2 and 32010-03-01T00:00:00-08:00http://spicycode.com/2010/03/01/updated-shortcuts-for-rails3<h1>Updated shortcuts for Rails 2 and 3</h1>
<p class="meta">01 Mar 2010</p>
<p>If you are like me and spend a good deal of time between rails 2 and 3 you have probably become frustrated by your aliases no longer working. Behold, functions!</p>
<pre><code>function ss {
if [ -e "./script/server" ]; then
./script/server
fi
if [ -e "./script/rails" ]; then
./script/rails server
fi
}
function sc {
if [ -e "./script/console" ]; then
./script/console
fi
if [ -e "./script/rails" ]; then
./script/rails console
fi
}
</code></pre>
GemKata - The Art of the Gem2009-10-09T00:00:00-07:00http://spicycode.com/2009/10/09/current-gem-practices<h1>GemKata - The Art of the Gem</h1>
<p class="meta">09 Oct 2009</p>
<p> <img class="awesome-image" src="/images/posts/gymkata.jpg" border="0" title="It's not like I could find a picture of GemKata, so deal with this" /></p>
<p>The dust has settled. The <a href="http://github.com">GitHub</a> has moved. What's that you say? They don't build gems anymore? Don't worry, you should use <a href="http://gemcutter.com">GemCutter</a>. This assumes that you are already using <em>jeweler</em>. You are, aren't you?</p>
<h2>Let's say you want to release a gem</h2>
<p>Make sure your jeweler config in your <em>Rakefile</em> looks something like the following.</p>
<pre><code>begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "your-awesome-gem-here"
# ...
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end
</code></pre>
<p>Now it's as easy as typing:</p>
<pre><code># If you have never released before
rake version write MAJOR=0 MINOR=1 PATCH=0
# If you are back for more, releasing again
rake version:bump:(major|minor|patch)
</code></pre>
<p>You now have an updated gemspec, and with the version set correctly. Now to tag the release on github.</p>
<pre><code>rake release
</code></pre>
<p>Finally, release it to <a href="http://gemcutter.com">GemCutter</a> using:</p>
<pre><code>rake gemcutter:release
</code></pre>
<h2>The users are at the gates, and they demand documentation!</h2>
<p>The next most awesome thing to do is to add <a href="http://github.com/voloko/sdoc">sdoc</a>. Think the best rdoc template in the history of the universe. And as a special bonus we'll generate them on your gh-pages branch so you can go to <em>http://yournamehere.github.com/your-awesome-gem-here</em> to see the rdoc documentation.</p>
<p>Open your <em>Rakefile</em> back up and put this at the bottom:</p>
<pre><code>begin
%w{sdoc sdoc-helpers rdiscount}.each { |name| gem name }
require 'sdoc_helpers'
rescue LoadError => ex
puts "sdoc support not enabled:"
puts ex.inspect
end
require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ''
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "your-awesome-gem-here #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
</code></pre>
<p>To generate the docs the first time run:</p>
<pre><code>rake pages:init
</code></pre>
<p>To rebuild the github pages branch after updates:</p>
<pre><code>rake pages
</code></pre>
<h2>Bask in your amazingness</h2>
<p>Now you've done it! You're the envy of ever ne'er-do-well programmer from here to there. Enjoy!</p>
Speeding up port install2009-05-17T00:00:00-07:00http://spicycode.com/2009/05/17/sudo-port-install-turbo<h1>Speeding up port install</h1>
<p class="meta">17 May 2009</p>
<p>I've been doing a lot of software installation via <a href="http://macports.org">macports</a> recently and I wanted to make sure things were building as fast as they could. After reading through the macports FAQ I found a few easy steps for speeding up installations.</p>
<h2>Install ccache</h2>
<p>From the <strong>ccache</strong> homepage:</p>
<blockquote><p>ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.</p></blockquote>
<p>To use <strong>ccache</strong> port install it by typing:</p>
<pre><code>sudo port install ccache
</code></pre>
<h2>Tweak your macports.conf</h2>
<p>We will need to edit a few settings in our <strong>macports.conf</strong> to enable ccache, and to make builds faster. First open <strong>macports.conf</strong> in your editor of choice.</p>
<pre><code>sudo vim /opt/local/etc/macports/macports.conf
</code></pre>
<p>Now find the <strong>configureccache</strong> setting and change it's value to <strong>yes</strong>. Next find <strong>buildmakejobs</strong> and change it's value from <strong>1</strong> to <strong>0</strong>. Now you can save and exit the file.</p>
<p>With the last changes we have enabled <strong>ccache</strong> integration in macports and also told it to detect the number of processor cores to use, instead of leaving it hardcoded to 1.</p>
<p>Things should zoom along quite a bit faster now when compiling in macports.</p>
RCov News Extravaganza2009-05-12T00:00:00-07:00http://spicycode.com/2009/05/12/rcov-updates<h1>RCov News Extravaganza</h1>
<p class="meta">12 May 2009</p>
<p>It's been a while since the last fireside chat about RCov, so let's head into this one at full-steam.</p>
<h2>No more REXML</h2>
<p>The source of countless bugs in RCov reporting across multiple versions of Ruby has been eliminated in favor of simple ERB templates. This simplifies the codebase and makes way for better template support down the road.</p>
<h2>The official repository on GitHub is now under the Relevance account</h2>
<p>This is great for everyone as it means more support, faster response to issues, and generally nothing but up for RCov going forward. Issues are moving to GitHub as well, so make sure to keep track of them at their <a href="http://github.com/relevance/rcov/issues">new location</a>.</p>
<h2>JRuby has a maintainer for their RCov version</h2>
<p>Charles Nutter is maintaining the official JRuby fork at <a href="http://github.com/jruby/rcov">http://github.com/jruby/rcov</a>. This should do similiarly great things for RCov on JRuby. Thanks to everyone who has submitted patches building out the initial version for JRuby in the past.</p>
<h2>Ruby 1.9 support is drawing near</h2>
<p>With the removal of REXML many of the biggest pain points are now gone, leading to a much more streamlined RCov. Work on Ruby 1.9 is progressing and already in <strong>alpha</strong> working state. More on this soon.</p>
<h2>To recap...</h2>
<p>1) Install Rcov by doing the following:</p>
<pre><code>gem install relevance-rcov --source=http://gems.github.com
</code></pre>
<p>2) Need JRuby support?</p>
<pre><code>gem install jruby-rcov --source=http://gems.github.com
</code></pre>
<p>3) Still having issues on Ruby 1.8.X with RCov? Make sure you are using <strong>relevance-rcov v0.8.3.2</strong> or higher. If you have an outstanding issue, or requests file it at our <a href="http://github.com/relevance/rcov/issues">GitHub Issue Tracker</a>.</p>
<p>4) Waiting on Ruby 1.9? Support is coming soon.</p>
Binding Option-Left and Option-Right in iTerm and Terminal2009-03-11T00:00:00-07:00http://spicycode.com/2009/03/11/binding-option-left-and-right-in-terminal<h1>Binding Option-Left and Option-Right in iTerm and Terminal</h1>
<p class="meta">11 Mar 2009</p>
<p>I finally got around to solving one of the consistency issues I encounter on OSX as I switch between Cocoa and the terminal. I really enjoy <code>Option-Left</code> and <code>Option-Right</code> as skip back one word and skip forward a word. Drop the following in your ZSH config to get things done.</p>
<pre><code># To see the key combo you want to use just do:
# cat > /dev/null
# And press it
bindkey '^K' kill-whole-line # ctrl-k
bindkey "^R" history-incremental-search-backward # ctrl-r
bindkey "^A" beginning-of-line # ctrl-a
bindkey "^E" end-of-line # ctrl-e
bindkey "[B": history-search-forward # down arrow
bindkey "[A": history-search-backward # up arrow
bindkey '^[[D' backward-word # option left
bindkey '^[[C' forward-word # option right
</code></pre>
<p>I've included the quick instructions on finding out what a key combo is in the terminal so you can bind any old thing. You can see what is currently bound by using <code>bindkey -L</code>.</p>
Keeping things clean when using MacPorts2009-02-23T00:00:00-08:00http://spicycode.com/2009/02/23/cleaning-up-with-macports<h1>Keeping things clean when using MacPorts</h1>
<p class="meta">23 Feb 2009</p>
<p>A common pattern I perform in MacPorts is embodied in the following function.</p>
<pre><code>function update_macports {
sudo port selfupdate
sudo port sync
sudo port outdated
}
</code></pre>
<p>It updates MacPorts, syncs the ports database, and then shows me what is outdated. For most ports I tend to uninstall the old version and then install the newer version. Sometimes this gets you in a never ending dependency removal loop.</p>
<p>Use <code>sudo port uninstall --follow-dependents your-portname-here</code>. This will uninstall this port and any dependent ports not in use by other ports on the system. Useful for cleanup after experimentation.</p>
Rubygems in your HOME directory, a 5 second guide.2009-02-14T00:00:00-08:00http://spicycode.com/2009/02/14/rubygems-in-your-home-directory<h1>Rubygems in your HOME directory, a 5 second guide.</h1>
<p class="meta">14 Feb 2009</p>
<p>It seems you are finally ready to let your gems live only in your <em>HOME</em> directory. I'll show you the ropes.</p>
<ol>
<li>First, stop typing <code>sudo gem whatever</code>, all the cool kids type <code>gem whatever</code>.</li>
<li>Add the following export to your zsh or bash config.</li>
<li>For ruby 1.8x it would be something like <code>export GEM_HOME=~/.gem/ruby/1.8</code></li>
<li>For 1.9.1 it would be <code>export GEM_HOME=~/.gem/ruby/1.9.1</code></li>
</ol>
<p>Now you can install and remove gems in your home directory with no issue.</p>
Installing Merb 1.02008-11-10T00:00:00-08:00http://spicycode.com/2008/11/10/installing-merb-10<h1>Installing Merb 1.0</h1>
<p class="meta">10 Nov 2008</p>
<p>I saw that merb 1.0 came out and decided to install it. I jumped, nay leaped to the terminal and ran <code>sudo gem install merb</code>.</p>
<p>In the terminal I saw the following:</p>
<pre><code>Successfully installed extlib-0.9.8
Successfully installed abstract-1.0.0
Successfully installed erubis-2.6.2
Successfully installed json_pure-1.1.3
Successfully installed mime-types-1.15
Successfully installed thor-0.9.8
Successfully installed merb-core-1.0
Successfully installed merb-action-args-1.0
Successfully installed merb-assets-1.0
Successfully installed merb-slices-1.0
Successfully installed merb-auth-core-1.0
Successfully installed merb-auth-more-1.0
Successfully installed merb-auth-slice-password-1.0
Successfully installed merb-auth-1.0
Successfully installed merb-cache-1.0
Successfully installed merb-exceptions-1.0
Successfully installed diff-lcs-1.1.2
Successfully installed templater-0.3.5
Successfully installed merb-gen-1.0
Successfully installed haml-2.0.4
Successfully installed merb-haml-1.0
Successfully installed merb-helpers-1.0
Successfully installed mailfactory-1.4.0
Successfully installed merb-mailer-1.0
Successfully installed merb-param-protection-1.0
Successfully installed addressable-1.0.4
Successfully installed data_objects-0.9.6
Successfully installed dm-core-0.9.6
Successfully installed dm-migrations-0.9.6
Successfully installed merb_datamapper-1.0
Successfully installed merb-more-1.0
Successfully installed do_sqlite3-0.9.6
Successfully installed dm-timestamps-0.9.6
Successfully installed uuidtools-1.0.4
Successfully installed dm-types-0.9.6
Successfully installed dm-aggregates-0.9.6
Successfully installed dm-validations-0.9.6
Successfully installed randexp-0.1.4
Successfully installed dm-sweatshop-0.9.6
Successfully installed merb-1.0
</code></pre>
<p>I’m all for modular, but ouch. 40 gems is quite a lot.</p>
Using MacVim and want the same ruby bindings in console VIM?2008-11-07T00:00:00-08:00http://spicycode.com/2008/11/07/using-macvim-with-the-terminal<h1>Using MacVim and want the same ruby bindings in console VIM?</h1>
<p class="meta">07 Nov 2008</p>
<p>Just alias vim to the following.</p>
<pre><code>alias vim='/Applications/MacVim.app/Contents/MacOS/Vim -p'
</code></pre>
Bringing VIM to the people2008-11-07T00:00:00-08:00http://spicycode.com/2008/11/07/bringing-vim-to-the-people<h1>Bringing VIM to the people</h1>
<p class="meta">07 Nov 2008</p>
<h2>What’s included?</h2>
<ul>
<li>IRB</li>
<li>Shell Mode with Syntax Highlighting for running test results</li>
<li>GUI+Terminal theme (spicycode) with nearest match color palletes</li>
<li>FuzzyFinder built-in and setup with reasonable defaults</li>
<li>User Settings file for user specific bits</li>
</ul>
<p><br /></p>
<h2>How do I use it?</h2>
<ul>
<li>Clone the repo, or fork it if you want, then symlink <code>.vimrc</code>, <code>.gvimrc</code>, and <code>.vim</code> to your <code>$HOME</code> directory.</li>
<li>Copy the <code>~/.vim/example_user_settings.vim</code> to <code>~/.vim/user_settings.vim</code></li>
<li>Customize it as necessary</li>
</ul>
<p><br /></p>
<h2>Where is it?</h2>
<pre><code>git clone git://github.com/spicycode/bringing-vim-to-the-people.git
</code></pre>