jump to navigation

Run a single cookbook recipe with chef-solo November 25, 2009

Posted by John Dewey in Chef, Code, Example, Rake.
1 comment so far

I generally build my systems with chef-solo cookbooks. I do not want to maintain a central server for recipes. However, I’m getting to the point where I’d like to share my cookbooks from one solo project to another. Anyways, I
wanted to run an individual recipe of a given cookbook. The following gist allows for this. Although, it may not be necessary, since cookbooks are generally idempotent. Seemed like a good idea earlier in the evening, meh.


Adding environment variables to cron via whenever November 24, 2009

Posted by John Dewey in Crontab, Plugins & Gems.

I wanted my users’ cron to run under zsh, so it picks up the .zshenv — which contains additional environment variables, my rake task required.

Can add the following to schedule.rb. This will work with any ENVIRONMENT=variable.

### schedule.rb
env ‘SHELL’, ‘/usr/bin/zsh’

Using Ohai to obtain platform September 1, 2009

Posted by John Dewey in Chef, Code, Deployment, Ohai.
add a comment

I have found myself needing to know the operating system platform. Rather than explicitly checking for /etc/lsb-base or /etc/issue to determine if it’s Ubuntu or Debian respectively. Let Ohai do the work for you.

This small gist prints the platform. You can access just about anything you want to know about your system via this method.

Funny reCAPTCHA August 6, 2009

Posted by John Dewey in Uncategorized.
add a comment

Picture 2.png

Changing the default error text in the Rails reCAPTCHA plugin July 15, 2009

Posted by John Dewey in Configuration, Example, Plugins & Gems, Rails.
add a comment

I couldn’t find information on changing the default “Captcha response is incorrect, please try again.” text returned by the reCAPTCHA Rails plugin.

This gist uses Rails 2.2’s internationalization (I18n) to change the message.

Sinatra utf-8 Content-Type before filter April 22, 2009

Posted by John Dewey in Code, Example, Sinatra.
add a comment

I wanted to learn Sinatra, so I started converting my personal Rails site over to Sinatra. I scrape my Twitterholic rating, and redisplay it on my site. I need the css and html to have a Content-Type of utf-8.

I came up with the following before filter. There is probably a better way to do this, I just wanted my controllers to be less “wet”.

I also use the following to render all css.

Running Sinatra with Phusion Passenger April 19, 2009

Posted by John Dewey in Passenger, Rack, Ruby, Sinatra.
1 comment so far

Here is a config.ru for use with Sinatra. It also includes a logging section for your app. This configuration works on Sinatra ( Quite a few of the examples out there use the deprecated Sinatra::Application.default_options vs set.


Updated config.ru with Blake’s suggestions.

gem install that (well kind-of) April 11, 2009

Posted by John Dewey in Code, Plugins & Gems.
add a comment

Geminstallthat is a pretty groovy name, which reidmix came up with. What would be really geeky is a gem named ‘that‘, which allows you to read my blog. I didn’t feel like dealing with rubyforge (to get the non-githuby gem name) , so here is a sneak peek at that.

$ gem sources -a http://gems.github.com
$ sudo sudo gem install retr0h-that
Successfully installed retr0h-that-0.0.0
1 gem installed
Installing ri documentation for retr0h-that-0.0.0...
Installing RDoc documentation for retr0h-that-0.0.0...
$ that

It will display all posts from the time the gem was built to Time.now.

Syncing bundle_fu assets to s3 for Cloudfront April 2, 2009

Posted by John Dewey in Amazon, CDN, Rake, Vlad.
1 comment so far

I wanted to automatically upload my bundle_fu assets to Amazon’s s3, and use their Cloudfront CDN for SnGs. I came up with the following rake task, which can be hooked into Vlad.

It’s as simple as adding the following to production.rb, and running the rake task ‘cloud:upload’.

ActionController::Base.asset_host = "cloudfront_url"

Find missing RSpec view tests March 16, 2009

Posted by John Dewey in Code, Rake, RSpec.

I created a quick little rake task which finds missing RSpec view tests. It assumes the extension is .haml, however, this can be overridden with the EXTENSION environment variable.

rake spec:missing_view_templates
EXTENSION=erb rake spec:missing_view_templates