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
################################################################## | |
# ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0] | |
# 10gen: mongo-1.5.2 | |
# bson-1.5.2 (BSON::BSON_C) | |
################################################################## | |
user system total real | |
10gen: insert 10,000 blank documents 0.670000 0.060000 0.730000 ( 0.744400) | |
10gen: insert 10,000 blank documents safe mode 1.200000 0.140000 1.340000 ( 1.800714) | |
10gen: insert 1,000 normal documents 0.090000 0.010000 0.100000 ( 0.091035) |
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
class Contact | |
include Mongoid::Document | |
embeds_one :email | |
embeds_one :phone | |
end | |
class Detail | |
include Mongoid::Document | |
end |
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
class Band | |
include Mongoid::Document | |
store_in collection: "artists", database: "musik", session: "primary" | |
end | |
Band.with(collection: "bands").create | |
Band.new.with(session: "secondary").save! | |
Band.where(name: "Depeche Mode").with(database: "legends") |
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
# encoding: utf-8 | |
require "mongoid/sessions/factory" | |
module Mongoid #:nodoc: | |
module Sessions | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :storage_options | |
end |
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
Mongoid logged query: | |
MONGODB mongoid_sandbox['availability_updates'].find({"availabilities"=>{"$elemMatch"=>{"inventory_id"=>"EZ_2_NR", "dateranges"=>{"$elemMatch"=>{"to"=>{"$gte"=>2011-12-29 00:00:00 UTC}, "from"=>{"$lte"=>2011-12-29 23:59:59 UTC}}}}}}).skip(20).limit(10) | |
Kyle's gist logged query: | |
MONGODB mongoid_sandbox['availability_updates'].find({"availabilities"=>{"$elemMatch"=>{"inventory_id"=>"EZ_2_NR", "dateranges"=>{"$elemMatch"=>{"to"=>{"$gte"=>2011-12-29 00:00:00 UTC}, "from"=>{"$lte"=>2011-12-29 23:59:59 UTC}}}}}}) |
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
Mongoid.database.add_stored_function "sequence", <<-__ | |
function(name) { | |
var ret = db.counters.findAndModify({ query: { _id: name}, update: { $inc : { next: 1}}, "new" :true, upsert: true}); | |
return ret.next; | |
} | |
__ | |
class Sequence | |
include Mongoid::Fields::Serializable |
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
module Windows | |
class Time | |
include Mongoid::Fields::Serializable | |
def deserialize(time) | |
Time.at(time) | |
end | |
def serialize(time) | |
time.to_i |
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
#!/bin/sh | |
set -e | |
cd .. | |
unset GIT_DIR | |
env -i git reset --hard | |
/home/user/.rvm/bin/rvm jruby@app exec bundle install | |
touch /data/app/tmp/restart.txt |
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
#! /bin/sh | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DESC="Trinidad server" | |
NAME=trinidad | |
RVM=/home/vader/.rvm/bin/rvm | |
RVM_EXEC_ARGS="jruby@yoda exec" | |
RACK_DIR=/data/yoda | |
PIDFILE=/var/run/trinidad.pid | |
DAEMON=$RVM |
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
# Get the count of notifications for this user | |
# and this post that need to be sent or have *not* | |
# been sent in the past 24 hours | |
User. | |
where({ _id: user._id, "notifs.post_id" => post_id }). | |
any_of( | |
{ "notifs.needs_send" => true }, | |
{ "notifs.last_send" => { '$exists' => false }}, | |
{ "notifs.last_send" => { "$lt" => 1.days.ago.utc }} |