Skip to content

Instantly share code, notes, and snippets.

View mperham's full-sized avatar

Mike Perham mperham

View GitHub Profile
string =<<-EOX
<?xml version="1.0" encoding="utf-8" ?><Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xml.truveo.com"
xsi:schemaLocation="http://xml.truveo.com/apiv3.xsd"><method>truveo.videos.getVideos</method><query>iphone</query><queryCategory>default</queryCategory>
<partialMatch>0</partialMatch><VideoSet><totalResultsAvailable>218367</totalResultsAvailable><totalResultsReturned>10</totalResultsReturned><firstResultPosition>0</firstResultPosition>
<title>Iphone Videos</title><rssUrl>http://xml.truveo.com/rss?query=iphone&amp;showAdult=0&amp;a=8466e666a2b70e9599b8d92d6c238d70</rssUrl><embedTag>&lt;embed src=&quot;http://www.truveo.com/truveo_listWidget.swf?query=iphone&amp;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
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'
name "ruby_app_server"
recipes "capistrano", "rubyee", "rails", "memcached"
override_attributes "memcached" => { "memory" => 2048 }
override_attributes "rails" => { "version" => '2.1.2' }
@mperham
mperham / gist:167863
Created August 14, 2009 14:36
Rails gems:install task that does not depend on database gems being installed already!
task :gems_install do
GEMS = []
module Rails
class Config
def gem(name, options = {})
GEMS << Rails::GemDependency.new(name, options)
end
def method_missing(*args)
# ignore
end
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 #{Time.now} while running on #{Socket.gethostname}.
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
Using ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
goblin:~$ sudo gem install memcached
Password:
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
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/>
https?
EOH
Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
osa = xml.add_namespace_declaration('osa', "http://www.onespot.com/Atom/Extensions/1.0")
xml.feed :xmlns=>'http://www.w3.org/2005/Atom' do
xml.div :xmlns=>'http://www.w3.org/1999/xhtml', :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."
end
xml.title 'feed title', :type=>"html"
xml.entry do
require 'nokogiri'
xml = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.feed(
:xmlns => 'http://www.w3.org/2005/Atom',
'xmlns:osa' => 'http://www.onespot.com/Atom/Extensions/1.0'
) do
xml.title 'feed title', :type => "html"