January 2010
1 post
Jan 30th
December 2009
1 post
Dec 30th
November 2009
2 posts
Nov 22nd
Nov 16th
October 2009
1 post
Named Scopes with PostgreSQL
When using chained named scopes that modify the :select finder option, the PostgreSQL adapter appears to give SELECT query preference to the first scope defined: named_scope :foo, {:select => "foo.*"} named_scope :bar, {:select => "bar.*"} Tester.bar.foo.all #=> SELECT bar.* FROM tester... While it seems somewhat straightforward in this example, when chaining multiple scopes, it is...
Oct 5th
September 2009
1 post
Pushing to a different git remote branch
If you have the need to push a local git branch to a differently named remote branch, try this: git push origin master:refs/heads/experimental Where “origin” is the remote name, “master” is your local branch name, and “experimental” is the remote branch to push into.
Sep 28th
August 2009
1 post
Ignoring database.yml
When database.yml is already in the repository, but you must have a modified local copy: git update-index --assume-unchanged config/database.yml
Aug 18th
July 2009
2 posts
Jul 25th
Jul 2nd
June 2009
1 post
Jun 30th
May 2009
2 posts
May 4th
May 4th
April 2009
1 post
Apr 7th
March 2009
1 post
Mar 21st
February 2009
9 posts
Ruby Gems with Autotest Discovery Break Rails
We’ll start off by clarifying which versions of which software I’m currently running: rails 2.2.2 ZenTest 3.11.1 mbleigh-seed-fu 0.0.3 I’m developing a basic Ruby on Rails application. Using Test::Unit and Shoulda for the test suite. The issue that I kept running into (sadly, for nearly a couple of hours) was this: loading autotest/rails_rspec Autotest style...
Feb 20th
Functional test for 404s in Rails 2.x
The Ruby on Rails version 2.x ActionController::TestCase thankfully abstracts a lot of the setup of your functional tests. There is a hidden issue, however, a problem that lingers for fully testing your controllers. How do you test for those automatically generated FAIL pages (i.e. 404, 500, 403, etc.)? Hidden in the TestCase code, there is an answer. By default, all @request calls are made...
Feb 20th
“Linux is the expert mode of operating systems.”
– Nathaniel Bibler
Feb 18th
1 tag
Automated Phusion Passenger installation prior to...
The following snippet will run the Phusion Passenger installation script (passenger-install-apache2-module) in an automated fashion. This would allow you to install the software via a boot script: echo -en "\n\n\n\n" | passenger-install-apache2-module
Feb 18th
1 note
“Application Error Hoptoad has hopped the toad. The application has notified...”
– Hoptoadapp
Feb 16th
Feb 16th
1 tag
God Damn Tropicana...
Of course, my last entry is a rant on how horrible the box design is for Tropicana. Now, two days ago, my wife sent me to the grocery store (“uhh ohhh”) … and what’d I get ? Tropicana, No Pulp. Low Acid. Seriously? All the f’n boxes look the same. REALLY? ReaLLY? I swear I stared at that shelf for .. easily 2 minutes, if not longer … trying to...
Feb 16th
1 tag
Feb 3rd
1 tag
Feb 3rd
January 2009
4 posts
1 tag
Using the Ruby Array#uniq with custom classes
You may (or may not) have noticed that when you create a custom class in Ruby, Array#uniq — and friends — no longer work as advertised. You can override the eql?, equal?, ==, and still not get it right. For the solution, you must override both the eql? and hash member methods of your custom object: class MyFoo attr_reader :custom_unique_id # Internally, Ruby converts your...
Jan 27th
1 tag
Jan 25th
1 tag
WatchWatch
Fox News, Fear Imbalance. God, I hate Fox News. Smite them, please.
Jan 23rd
1 tag
Jan 14th
December 2008
6 posts
2 tags
Phusion Passenger 2.0.5 and Ruby
After an hour or so of configuring a new, fresh CentOS 5.2 server, primarily relying on yum repositories, I thought I was nearly done. I installed Apache2, Ruby, rubygems, passenger, …. I was good to go. Passenger spawn server: symbol lookup error: /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.5/ext/passenger/native_support.so: undefined symbol: RARRAY_LEN *** Exception NoMethodError in...
Dec 10th
3 tags
git and opendiff
git config --global merge.tool opendiff
Dec 9th
2 tags
Remotely Securing CentOS
Lets assume you’ve got root access to a CentOS VPS. Further, lets assume you want to secure it in some way. Lets go with the following: First, create a new, non “root” user which will have sudo privileges. This creates the user, expires their password (prompting them to immediately change it), and sets the password empty. $ /usr/sbin/useradd my_user_name $ /usr/bin/chage -d...
Dec 8th
1 tag
Dec 8th
1 tag
OpenSSL::HMAC vs ruby-hmac Benchmarks
So, I’m writing a gem which requires an HMAC calculation. I came across the ruby-hmac gem, I assume to be maintained by Geoffrey Grosenbach, and was curious to investigate the performance differences between OpenSSL::HMAC and the ruby-hmac gem. I imagine one day, one other person, sometime between now and eternity, somewhere in the universe, maybe … might be interested in the...
Dec 4th
Dec 1st
November 2008
6 posts
1 tag
sqlite3-ruby and do_sqlite3 don't play well...
After recently installing merb 1.0.1 with datamapper 0.9.7, it appears that datamapper’s do_sqlite3 gem and the sqlite3-ruby gem (used by Rails) do not play nicely together. MissingSourceFile: no such file to load -- sqlite3 from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' The solution was to remove the do_sqlite3 gem until it has been fixed.
Nov 26th
2 tags
Generating a Rails application with a specific gem...
I know I’ve seen this elsewhere once or twice, but I can never find it when I need it. So, if you’ve got several rails gems installed (like me): $ gem list rails *** LOCAL GEMS *** rails (2.2.2, 2.1.2, 2.1.1, 2.1.0) And you’re looking to generate a new Rails application from a specific, not-most-recent version, you’ll need to do the following: $ rails _2.1.1_...
Nov 24th
2 tags
Slightly better performance in Ruby Liquid 1.9.0
With the not even close to recent release of Liquid 1.9.0, I figured I’d clean the dust off of my template benchmark suite and see how the new code lines up with the past: Liquid 1.7.0: user system total real Attribute Access (Liquid) 0.020000 0.000000 0.020000 ( 0.023265) Conditional Complex (Liquid) 0.030000 0.000000 ...
Nov 14th
Nov 2nd
rankmaniac
Ok, so forgive me for talking about a link posted on Reddit, but this is slightly amusing (at least, to me..). So, there is a TA at CMU who is giving his students an assignment to get a single web page to rank higher in a Google search than his own, when searching for “rankmaniac”. So, one smart student, got his entry listed on Digg and Reddit, mainly by explaining the purpose and...
Nov 2nd
1 tag
Nov 1st
October 2008
14 posts
2 tags
That merb install is a little crazy
$ sudo gem install merb Building native extensions. This could take a while... 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 rack-0.4.0 Successfully installed thor-0.9.8 Successfully installed merb-core-0.9.10 Successfully installed RubyInline-3.8.1 Successfully installed...
Oct 27th
1 tag
McCain's Campaign Politics are Appalling
There’s politics, with finger pointing and skewed statistics about opponent strategies, and that’s fine. But, then there’s defamation. It’s a very fine (legal!) line he’s walking. It’s ridiculous that people - mostly Republicans in this election cycle - throw around the ‘terrorist’ label in the first place. The whole thing is sickeningly...
Oct 23rd
1 tag
Oct 22nd
Oct 21st
1 tag
Oct 21st
“Toes have become an origami meme.”
– Robert Lang, TED Talks
Oct 20th
1 tag
Oct 20th
Oct 17th
1 tag
Oct 16th
1 tag
Oct 10th
1 tag
Oct 6th