Skip to content

Instantly share code, notes, and snippets.

require "paperclip_migrations"
class AddPaperclipColumnsToProducts < ActiveRecord::Migration
include PaperclipMigrations
def self.up
add_paperclip_fields :items, :vignette
Product.reset_column_information
Product.all.each do |product|
attachment = Asset.find(:first, :conditions => ["assetable_type = ? and assetable_id = ? and type = ?", "Item", product.id, "Vignette"])
# mongo_template.rb
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/prototype.js"
class LongPollHttpServer < EM::Connection
def unbind
end
def receive_data(data)
end
end
EM.epoll if EM.epoll?
EM.run do
class LongPollHttpServer < EM::Connection
def receive_data(data)
# some code here to extract path and params from the HTTP request
case path
when '/join'
when '/send'
class Room < EM::Channel
def say(nick, type, text = nil)
# some code here to build the string that will be sent back
push(str)
end
end
class LongPollHttpServer < EM::Connection
def receive_data(data)
class Person
include Mongoid::Document
field :name
field :number, Integer
embeds_many :phones
...
end
class Phone
include Mongoid::Document
class Person
include MongoMapper::Document
key :name
key :number, Integer
many :phones
...
end
class Phone
Person
.where(:last_name => "Zorg")
.and(:middle_initial => "J")
.and(:age.gt => 30)
class Player
include Mongoid::Document
include Mongoid::Versioning
field :status
User.where(:age.gt => 27).sort(:age).all,
User.where(:age.gt => 27).sort(:age.desc).all,
User.where(:age.gt => 27).sort(:age).limit(1).all
class User
include MongoMapper::Document
scope :johns, where(:name => 'John')
scope :bills, :name => 'Bill'
scope :by_name, lambda { |name| where(:name => name) }
Fatal error: Out of memory (allocated 31719424) (tried to allocate 312569 bytes) in /homepages/7/d283029777/htdocs/pot/wp-includes/wp-db.php on line 478