This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'rexml/document' | |
test_xml_string = "<tag attr='value&text'></tag>" | |
pp REXML::Document.new(test_xml_string).root.attributes['attr'] | |
# value&text | |
parser = REXML::Parsers::BaseParser.new(test_xml_string) | |
while parser.has_next? | |
event = parser.pull |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should escape text values in url" do | |
title = 'Chart & Title' | |
legend = ['first data & set label', 'n data set label'] | |
chart = Gchart.line(:title => title, :legend => legend) | |
chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should escape text values in url" do | |
title = 'Chart & Title' | |
legend = ['first data & set label', 'n data set label'] | |
chart = Gchart.line(:title => title, :legend => legend) | |
chart.include?(Gchart.jstize("chdl=first+data+%26+set+label|n+data+set+label")).should be_true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'localmemcache' | |
cache = LocalMemCache.new(:namespace => 'testnamespace', :size_mb => 16) | |
cache[:foo] = :bar | |
puts cache[:foo] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat /sys/block/*/queue/scheduler | |
noop anticipatory deadline [cfq] | |
noop anticipatory deadline [cfq] | |
none | |
none | |
none | |
none | |
none | |
none | |
none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo < ActiveRecord::Base | |
default_value_for :store, {} | |
def entry_1= value | |
store[:entry_1] = value | |
end | |
end | |
Foo.new :entry_1 => 'bar' | |
# => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://railsrx.com/2010/09/27/a-quick-ruby-kata/ | |
# dirty: | |
result = [] | |
1.upto(5) do |ab| | |
((1..9).to_a - [ab]).each do |c| | |
((1..9).to_a - [ab]).each do |d| | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"caret_style": "phase", | |
"draw_white_space": "all", | |
"ensure_newline_at_eof_on_save": true, | |
"file_exclude_patterns": | |
[ | |
"._*", | |
".DS_Store" | |
], | |
"folder_exclude_patterns": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
require 'aws-sdk' | |
require 'forwardable' | |
require 'futuroscope/convenience' | |
region = AWS.regions['eu-west-1'] | |
table = region.dynamo_db.tables['futuroscope'] | |
unless table.exists? | |
table = region.dynamo_db.tables.create('futuroscope', 10, 5, |