Skip to content

Instantly share code, notes, and snippets.

@der-flo
der-flo / gist:89945
Created April 3, 2009 20:23
bad rexml
require 'pp'
require 'rexml/document'
test_xml_string = "<tag attr='value&amp;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
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
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
require 'rubygems'
require 'localmemcache'
cache = LocalMemCache.new(:namespace => 'testnamespace', :size_mb => 16)
cache[:foo] = :bar
puts cache[:foo]
$ cat /sys/block/*/queue/scheduler
noop anticipatory deadline [cfq]
noop anticipatory deadline [cfq]
none
none
none
none
none
none
none
class Foo < ActiveRecord::Base
default_value_for :store, {}
def entry_1= value
store[:entry_1] = value
end
end
Foo.new :entry_1 => 'bar'
# =>
# 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|
{
"caret_style": "phase",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"._*",
".DS_Store"
],
"folder_exclude_patterns":
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,