this is SO weird
hello gist?
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
#! /usr/bin/env ruby | |
puts "closing firefox ..." | |
`killall firefox` | |
require 'rubygems' | |
require 'activerecord' | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', | |
:database => '/home/remi/.mozilla/firefox/efs72yik.default/places.sqlite' |
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
# different possible syntaxes for generating models | |
Factory(:user, :foo => 'bar', :chunky => 'bacon') | |
Factory.build(:user, :foo => 'bar', :chunky => 'bacon') | |
User.generate :foo => 'bar', :chunky => 'bacon' | |
User.build :foo => 'bar', :chunky => 'bacon' | |
User.gen :foo => 'bar', :chunky => 'bacon' | |
User.make :foo => 'bar', :chunky => 'bacon' |
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
#! /usr/bin/env ruby | |
require 'rubygems' | |
require 'activerecord' | |
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:' | |
class CreateStuff < ActiveRecord::Migration | |
def self.up | |
create_table( :breeds ){|t| t.string :name } | |
create_table( :dogs ){|t| t.string :name; t.integer :breed_id } |
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
# randomly generate 0 or 1 ... you should get 1 about 10% of the time, 0 about 90% of the time | |
$ irb | |
>> rand | |
=> 0.534835738078545 | |
>> rand | |
=> 0.334280092272696 | |
>> rand * 10 | |
=> 2.22911939494193 | |
>> ( rand * 10 ).to_i | |
=> 0 |
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
# $ irb | |
>> require 'rack' | |
=> true | |
# to create and run a basic Rack application | |
>> Rack::Handler::Thin.run lambda {|e| [200, {}, ["Hello World!"]] } | |
Thin web server (v1.2.1 codename Asynctilicious Ultra Supreme) |
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
#! /usr/bin/env ruby | |
class Foo | |
DEFAULT_VAR = 'I am the default' | |
class << self | |
attr_accessor :var | |
end | |
def self.var |
OlderNewer