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
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, RSpec, Rake.2 comments
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 or EXTENSION=erb rake spec:missing_view_templates
Passenger with Rails 2.3 application (MissingSourceFile) March 1, 2009
Posted by John Dewey in Apache, New Category, Passenger, WebServers.8 comments
I’m such an idiot. I spent the last few days, trying to figure out the following error reported on my Ubuntu 8.10 Passenger install.
Error message: no such file to load -- application (MissingSourceFile) Exception class: Passenger::UnknownError
I was installing libapache2-mod-passenger_2.0.3 from the apt-get repo, which does not understand the application_controller.rb rename.
2.0.6 mod-passenger has yet to show up in the apt-get repo. You can use these instructions to install the brightbox mod-passenger build.
using geminstaller with vlad the deployer February 28, 2009
Posted by John Dewey in Configuration, Deployment, Example, Rake, Vlad.1 comment so far
I really really really like vlad the deployer. I recently switched my apps over to geminstaller vs Rails’ config.gem.
This gist adds in geminstaller functionality to vlad’s update task.
ActionMailer Timeouts February 22, 2009
Posted by John Dewey in Code, Monkey Patch, Rails.add a comment
The following gist contains a monkeypatch allowing configurable timeouts on ActionMailer. Since ActionMailer is blocking, it is nice to set a reasonable timeout, rather than wrapping each of your ActionMailer calls with a Timeout (alarm). I actually monkeypatch all of ‘net/smtp’, so just rescue ‘Timeout::Error’ where needed.
chef-solo VPS provisioning February 21, 2009
Posted by John Dewey in Apache, Automation, Chef, Code, Configuration.add a comment
I probably built a naive chef solo configuration. I also know I could have used one of the many “Ready Stack” solutions VPS providers are creating. However, I like my systems setup a particular way.
Take a peek the configuration is pretty cool. The code is on github.
Ideally chef would have built my system from the ground up, installing ruby, libs, etc… Since I do not control this piece, there are a few prerequisites to setting up chef.
Once complete, drop in your virtualhost, and deploy your code. This is not intended as zero-conf. Merely a standard base configuration for all of my hosts.
icanhasrspec – lolspek sneak peek February 17, 2009
Posted by John Dewey in Example, RSpec.add a comment