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
/* Mocha test | |
to use: | |
npm install mocha | |
mocha <filename> | |
or | |
npm test | |
*/ | |
var assert = require('assert'); | |
var tzwhere = require('../lib/index'); |
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 testCollection = require('mongojs')('test').collection('testCollection'), | |
shouldBeOneDoc = testCollection.find({}).sort({ myField : 1 }).limit(1); | |
shouldBeOneDoc.count(function (err, count) { console.log(count) }); |
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
// https://developers.google.com/latitude/v1/using#ListingHistory | |
var minTimeMs = 0, // Earliest location to pull, 1st Jan 1070 seems far back enough. | |
maxTimeMs = Date.new().getTime(), // Latest location to pull, now. | |
lastResponse = []; | |
while { | |
// it is assumed this returns a max of 1000 locations in reverse chronological order, | |
// most recent location before maxTime first, | |
// then 999 more locations going back in time. |
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
vagrant@heroku:~$ sudo su postgres | |
$ psql | |
psql (9.1.9) | |
Type "help" for help. | |
postgres=# SELECT rolname FROM pg_roles; | |
rolname | |
---------- | |
postgres | |
vagrant |
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
mySchema.statics.validateAndUpsert = function (conditions, update, callback) { | |
var updateModel = new this(update); | |
updateModel.validate(function (err) { | |
if (err) { | |
callback(err); | |
} else { | |
this.findOneAndUpdate(conditions, update, { upsert: true}, callback); | |
} | |
} | |
}; |
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
mySchema.statics.upsert = function (conditions, update, callback) { | |
this.findOne(conditions, function (err, existingDoc) { | |
if (err) { | |
callback(err); | |
} else if (existingDoc) { | |
// I don't think this is valid | |
existingDoc.update(update); | |
existingDoc.save(callback); | |
} else { | |
return this.create(update, callback); |
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 timer, | |
work = function () { | |
asyncWork(function(err) { | |
timer = setTimeout(work, 10000); | |
} | |
}, | |
exports.start = function () { | |
work(); |
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
original_bobs = User.where first_name: 'Bob' | |
# Assume this deletes a Bob: | |
User.destroy 123 | |
# Now I'd like to see user 123 in this list: | |
puts original_bobs | |
We can't make this file beautiful and searchable because it's too large.
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
1.0986533107808496 | |
1.583960737452346 | |
0.13734048649924682 | |
3.5384582189028078 | |
0.8109541275321867 | |
1.4710983394905912 | |
1.2568627243577724 | |
0.6561450580865987 | |
1.2664615130882972 | |
1.10855911768647 |
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
Mon Jun 10 19:17:51 MST 2013: performing suspend | |
Tue Jun 11 07:52:44 MST 2013: Awake. | |
Tue Jun 11 07:52:44 MST 2013: Running hooks for resume | |
Running hook /etc/pm/sleep.d/novatel_3g_suspend resume suspend: | |
/etc/pm/sleep.d/novatel_3g_suspend resume suspend: success. | |
Running hook /usr/lib/pm-utils/sleep.d/99video resume suspend: | |
/usr/lib/pm-utils/sleep.d/99video resume suspend: success. | |
Running hook /etc/pm/sleep.d/99bcmbluetooth resume suspend: |