Skip to content

Instantly share code, notes, and snippets.


Mike Perham mperham

View GitHub Profile
View gist:149234
string =<<-EOX
<?xml version="1.0" encoding="utf-8" ?><Response xmlns:xsi="" xmlns=""
<title>Iphone Videos</title><rssUrl>;showAdult=0&amp;a=8466e666a2b70e9599b8d92d6c238d70</rssUrl><embedTag>&lt;embed src=&quot;;resultsnum=10&quot; quality=&quot;high&quot; wmode=&quot;transparent&quot; type=&quot;application/x-shockwave-flash&quot; width=&quot;600&quot; height=&quot;150&quot;&gt;&lt;/embed&gt;</embedTag><Video><id>1600467146</id><title>&#039;Top Gun&#039; for the iPhone</title><sponsored>0</sponsored><videoUrl>http
View gist:151646
This happens when I log into my chef server (CentOS RPM install). I suspect CouchDB was not initialized correctly (because it was already running) when I installed chef.
~ Params: {"action"=>"index", "controller"=>"chef_server_slice/nodes"}
~ 500 "Internal Server Error" - (Net::HTTPFatalError)
/usr/lib/ruby/1.8/net/http.rb:2097:in `error!'
/usr/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/rest.rb:232:in `run_request'
/usr/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/rest.rb:85:in `get_rest'
/usr/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/couchdb.rb:124:in `list'
/usr/lib/ruby/gems/1.8/gems/chef-0.7.4/lib/chef/node.rb:351:in `list'
View gist:153251
name "ruby_app_server"
recipes "capistrano", "rubyee", "rails", "memcached"
override_attributes "memcached" => { "memory" => 2048 }
override_attributes "rails" => { "version" => '2.1.2' }
mperham / gist:167863
Created August 14, 2009 14:36
Rails gems:install task that does not depend on database gems being installed already!
View gist:167863
task :gems_install do
GEMS = []
module Rails
class Config
def gem(name, options = {})
GEMS <<, options)
def method_missing(*args)
# ignore
View gist:169286
require "merb-mailer/mailer"
require 'socket'
Merb::Mailer.delivery_method = :sendmail
class ErrorMailer
def self.template(name, error, context)
data = <<-EOF
I regret to inform you that your daemon, #{name}, caught an error at #{} while running on #{Socket.gethostname}.
View gist:170575
goblin:~/.ruby_versions/jruby-1.3.1/bin$ export JRUBY_OPTS=
goblin:~/.ruby_versions/jruby-1.3.1/bin$ ./jruby --ng -v
jruby 1.3.1 (ruby 1.8.6p287) (2009-06-15 2fd6c3d) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_13) [x86_64-java]
goblin:~/.ruby_versions/jruby-1.3.1/bin$ export JRUBY_OPTS="--ng"
goblin:~/.ruby_versions/jruby-1.3.1/bin$ ./jruby --ng -v
jruby: unknown option --ng
goblin:~/.ruby_versions/jruby-1.3.1/bin$ ./jruby -v
jruby: unknown option --ng
View gist:179717
Using ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
goblin:~$ sudo gem install memcached
Building native extensions. This could take a while...
Successfully installed memcached-0.16
1 gem installed
goblin:~$ ruby -e 'system("ruby #{File.dirname(`gem which memcached`.split("\n").
> last)}/../test/profile/benchmark.rb")'
Loading memcached
Loading memcache
View gist:180381
Surround a heredoc with quotes and you can continue the code on the same line:
render :status => 404, :text => <<-'EOH' and return unless setup
article not found<br/>
I, as a server, have failed<br/>
View gist:181031 => 'UTF-8') do |xml|
osa = xml.add_namespace_declaration('osa', "")
xml.feed :xmlns=>'' do
xml.div :xmlns=>'', :class=>'info' do
xml.text "This is an Atom formatted XML site feed. It is intended to be viewed in a Newsreader or syndicated to another site."
xml.title 'feed title', :type=>"html"
xml.entry do
View builder.rb
require 'nokogiri'
xml = => 'UTF-8') do |xml|
:xmlns => '',
'xmlns:osa' => ''
) do
xml.title 'feed title', :type => "html"