Skip to content

Instantly share code, notes, and snippets.

View achiurizo's full-sized avatar
🌞

Arthur Chiu achiurizo

🌞
View GitHub Profile
---
:benchmark: false
:verbose: true
:update_sources: true
gem: --no-ri --no-rdoc
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org/
:backtrace: false
:bulk_threshold: 1000
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:49: warning: already initialized constant H
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:50: warning: already initialized constant NL
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:51: warning: already initialized constant UNICODE
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:57: warning: already initialized constant NONASCII
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:58: warning: already initialized constant ESCAPE
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:59: warning: already initialized constant NMSTART
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:60: warning: already initialized constant NMCHAR
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:61: warning: already initialized constant STRING1
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx.rb:62: warning: already initialized constant STRING2
/Library/Ruby/Gems/1.8/gems/haml-3.0.7/lib/sass/scss/rx
# Add a new child to this person
@person.children_attributes = [ { :name => 'Son' } ]
@person.children #=> [ <#Person: name: 'Son'> ]
@person.children.clear
# Add two new children to this person
@person.children_attributes =
[ { :name => 'Son' }, { :name => 'Daughter' } ]
@person.save
@person.children #=> [ <#Person: name: 'Son'>, <#Person: name: 'Daughter'> ]
require 'rubygems'
require 'sinatra'
require 'data_mapper'
require 'dm-sqlite-adapter'
DataMapper.setup(:default, "sqlite3://" + '/tmp/development.db')
class Post
include DataMapper::Resource
@entry = Entry.find_or_create_by(:link => something.url)
@entry.update_attributes(:title => title, :body => content, :site_id => site_ids[url]
require 'carrierwave/orm/mongoid'
class Photo
include Mongoid::Document
include Mongoid::Timestamps # adds created_at and updated_at fields
# fields
field :caption, :type => String
mount_uploader :file, Uploader
end
def test(options={})
Class.new
puts 'testing the gist'
end
Mongoid.database = case Padrino.env
when :development
Mongo::Connection.from_uri("mongodb://user:[email protected]:27048/development_db").db('development_db')
when :production
Mongo::Connection.from_uri("mongodb://user:[email protected]:27048/production_db").db('production_db')
when :test
Mongo::Connection.new('localhost',Mongo::Connection::DEFAULT_PORT).db('test_db')
end
get %r{/\w+/} do
"Hello!"
end
get '/call/:number', :number => /\d+/ do
"Call #{params[:number]}"
end
get '/regex/:route/:data', :route => /\w+/, :data => /\d+/ do
"Route: #{params[:route]}, Data: #{params[:data]}"
@achiurizo
achiurizo / gist:837683
Created February 21, 2011 20:48
Get will_paginate to work with AR on Padrino
# In your gemfile, add will_paginate.
# We are using the latest ActiveRecord(3.0.x)
# As of this gist, the version for will_paginate is 2.3.15, we want 3.x version
## Gemfile
gem 'will_paginate', '3.0.pre2'
# In config/boot.rb, enable activerecord in Padrino.after_load.