This file contains hidden or 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
> db.users.find({last_logged_in : {'$ne': null}}).explain() | |
{ | |
"cursor" : "BasicCursor", | |
"startKey" : { | |
}, | |
"endKey" : { | |
}, | |
"nscanned" : 536299, |
This file contains hidden or 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
> db.users.find({last_logged_in : {'$ne': null}}).hint({last_logged_in: 1}).explain() | |
{ | |
"cursor" : "BtreeCursor last_logged_in_1", | |
"startKey" : { | |
"last_logged_in" : { | |
"$minElement" : 1 | |
} | |
}, | |
"endKey" : { | |
"last_logged_in" : { |
This file contains hidden or 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
> db.users.find({last_logged_in : {'$gt': null}}).explain() | |
{ | |
"cursor" : "BtreeCursor last_logged_in_1", | |
"startKey" : { | |
"last_logged_in" : null | |
}, | |
"endKey" : { | |
"last_logged_in" : { | |
"$maxElement" : 1 | |
} |
This file contains hidden or 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
> db.users.find({last_logged_in : {'$gt': 0}}).explain() | |
{ | |
"cursor" : "BtreeCursor last_logged_in_1", | |
"startKey" : { | |
"last_logged_in" : 0 | |
}, | |
"endKey" : { | |
"last_logged_in" : 1.7976931348623157e+308 | |
}, | |
"nscanned" : 0, |
This file contains hidden or 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
> db.users.find({last_logged_in : {'$gt': new Date(0)}}).explain() | |
{ | |
"cursor" : "BtreeCursor last_logged_in_1", | |
"startKey" : { | |
"last_logged_in" : "Wed Dec 31 1969 16:00:00 GMT-0800 (PST)" | |
}, | |
"endKey" : { | |
"last_logged_in" : "Tue Jan -2147483647 584556020 06:25:52 GMT-0800 (PST)" | |
}, | |
"nscanned" : 8, |
This file contains hidden or 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
@collection = db.collection('docs') | |
loop do | |
# Find a record to work on | |
new_record = @collection.find_one({:state => "NEW"}, {:sort => "created_at asc"}) | |
# Set the state to my process id, but only if it's still in the "NEW" state | |
response = @collection.update({:_id => new_record.id, :state => "NEW"}, | |
{'$set' => {:state => Process.pid}}, | |
{:upsert => false, :safe => true}) |
This file contains hidden or 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
db_config = YAML::load(File.read(RAILS_ROOT + "/config/database.yml")) | |
if db_config[Rails.env] | |
mongo = db_config[Rails.env] | |
mongo_host = mongo['host'] || 'localhost' | |
mongo_port = mongo['port'] || 27017 | |
RAILS_DEFAULT_LOGGER.error("Connecting to #{mongo_host}:#{mongo_port}") | |
MongoMapper.connection = Mongo::Connection.new(mongo_host, mongo_port, :logger => RAILS_DEFAULT_LOGGER) | |
MongoMapper.database = File.basename(mongo['database']).split(".")[0] | |
end |
This file contains hidden or 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
> db.tiles.find({ position: { $within: { $box: [ [ 1466, -2128 ], [ 1506, -2088 ] ] } } }).explain() | |
{ | |
"cursor" : "GeoBrowse-box", | |
"nscanned" : 341, | |
"nscannedObjects" : 341, | |
"n" : 341, | |
"millis" : 657, | |
"indexBounds" : { | |
} |
This file contains hidden or 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
> db.tiles.find({ position: { $within: { $box: [ [ 1466, -2128 ], [ 1506, -2088 ] ] } } }).explain() | |
{ | |
"cursor" : "GeoBrowse-box", | |
"nscanned" : 341, | |
"nscannedObjects" : 341, | |
"n" : 341, | |
"millis" : 725, | |
"indexBounds" : { | |
} |
This file contains hidden or 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
var net = require('net'), fs = require('fs'), _ = require('./underscore-min')._; | |
// Our active connections | |
var connections = {}; | |
var doc = fs.readFileSync('lyrics.txt', 'utf8').split(" "); | |
var word = 0; | |
var intervalId = null; | |
var sing = function() { | |
if ((word >= doc.length || _.size(connections) == 0) && intervalId != null) { |