Skip to content

Instantly share code, notes, and snippets.

@mojombo
mojombo / omg.rb
Created January 6, 2011 05:44 — forked from tenderlove/omg.rb
require 'nokogiri'
doc = Nokogiri.HTML DATA
doc.xpath('//div//text()').map { |x| x.content = x.to_s }
p doc.serialize(:save_with => Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
__END__
<div>&nbsp;<span>x</span></div>

Title

1. Item 1
2. Item 2
@mojombo
mojombo / config_options.rb
Created December 14, 2010 04:54
config options mini parser thing
# Convert an array of nested key parts into a nested Hash and convert the
# value to a proper Ruby object.
#
# keyparts - An Array of String parts of the nested Hash. For instance, the
# list ['a', 'b', 'c'] would lead to a nested hash that looks like
# {'a' => {'b' => {'c' => X}}}.
# val - The String value that will be converted into the proper Boolean,
# Integer, or String.
#
# Returns the nested Hash.
[21:24][tom@lepton:~(master)]$ perl --version
This is perl, v5.10.0 built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)
[21:23][tom@lepton:~(master)]$ cat test.pod
=head1 Title
=over 4
$ git config --global user.name "Tom Preston-Werner"
$ git config --global user.email "tom@mojombo.com"
$ git config --global color.ui true
Another mustache.erl example, this time showing off lists and asking for context in one of the view functions.
Just a simple demonstration of how to use my soon-to-be-released mustache.erl library. Mustaches forever!
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rubygems'
require 'bert'
require 'json'
require 'yajl'
require 'benchmark'
ITER = 1_000
Failed on server connect attempt 1. Trying again...
Uncaught exception
recieved ConnectionUnbound for an unknown signature: f6f17803599e03b44307e9cbe741a2284
/Users/tom/.rip/active/lib/eventmachine.rb:1485:in `event_callback'
/Users/tom/.rip/active/lib/eventmachine.rb:245:in `release_machine'
/Users/tom/.rip/active/lib/eventmachine.rb:245:in `run'
./bin/../lib/proxymachine.rb:70:in `run'
bin/proxymachine:36