Skip to content

Instantly share code, notes, and snippets.

create_table(:pairs) do
primary_key :id
foreign_key :left_leaf_id, :leafs, :key => :id
foreign_key :right_leaf_id, :leafs, :key => :id
String :description
FalseClass :enabled
Time :created_at, :null => false, :index => true
create_table(:pairs) do
primary_key :id
foreign_key :left_leaf_id, :leafs, :key => :id
foreign_key :right_leaf_id, :leafs, :key => :id
String :description
FalseClass :enabled
Time :created_at, :null => false, :index => true
class Car
attr_accessor :brand, :year, :model
def initialize(brand=nil, year=nil, model=nil)
@brand = brand
@year = year
@model = model
end
end
tmp
log
doc
daemon
*.swp
@gpherguson
gpherguson / quotes_test.rb
Created February 14, 2013 23:49
Test of double vs single quotes with escaped tabs vs embedded tabs
require 'benchmark'
n = 10_000_000
Benchmark.bm(24) do |b|
5.times do
b.report('double-quotes with \t') { n.times { "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" } }
b.report('double-quotes with <tab>') { n.times { " " } }
b.report('single-quotes with <tab>') { n.times { ' ' } }
end
@gpherguson
gpherguson / gist:765223
Created January 4, 2011 19:07
rvm trace
[gferguson@s2tlnetlab001 src]$ rvm install 1.9.2-p0 --trace
1.9.2-p0 --trace
rvm 1.1.12 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
+ [[ -z '' ]]
+ export 'PS4=+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+ PS4='+[${BASH_SOURCE}] : ${LINENO} : ${FUNCNAME[0]:+${FUNCNAME[0]}() $ }'
+[/home/gferguson/.rvm/scripts/cli] : 597 : __rvm_parse_args() $ [[ -z install ]]
+[/home/gferguson/.rvm/scripts/cli] : 599 : __rvm_parse_args() $ [[ 0 -eq 1 ]]
# USAGE: Hash.from_xml:(YOUR_XML_STRING)
require 'nokogiri'
# modified from http://stackoverflow.com/questions/1230741/convert-a-nokogiri-document-to-a-ruby-hash/1231297#1231297
class Hash
class << self
def from_xml(xml_io)
begin
result = Nokogiri::XML(xml_io)
return { result.root.name.to_sym => xml_node_to_hash(result.root)}
class Dungeon
@@levels = []
def add_level(n, h, w)
@@levels[n] = Level.new(h, w)
end
end
class Level
def initialize(height, width)
@height, @width = height, width
#
# at the bottom of the trace it says...
#
raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)
sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt 'SELECT count(1) AS count_1 \nFROM blogfeeds \nWHERE blogfeeds.blog_url ILIKE %(blog_url_1)s' {'blog_url_1': 'http://seanmalstrom.wordpress.com/2009/12/21/email-final-fantasy-crystal-chronicles-crystal-bearers/'}
#
# I'm using SqlSoup...
#
from sqlalchemy.ext.sqlsoup import SqlSoup