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
db.events.aggregate( | |
{'$group' : {_id : "$platform", devices: {"$addToSet" : "$device_id"} } }, | |
{"$unwind" : "$devices" }, | |
{"$group" : {_id : "$_id", count: {"$sum" : 1}}} | |
) |
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
{ | |
"currencyPacks" : [ | |
{ | |
"purchasableItem" : { | |
"marketItem" : { | |
"consumable" : 1, | |
"price" : 1.99, | |
"androidId" : "com.my.game.packs.bag_of_coins", | |
"iosId" : "com.my.game.packs.bag_of_coins" | |
}, |
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
{ | |
"name": "unity-mass-labeler", | |
"version": "0.0.1", | |
"description": "", | |
"main": "mass-labeler.js", | |
"dependencies": { | |
"lodash": "^3.5.0", | |
"recursive-readdir": "^1.2.0" | |
}, | |
"devDependencies": {}, |
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
db.users.find({created_at: {$gt: new ISODate('2015-03-29 00:53:55.997Z')}}).sort({_id: 1}).forEach(function(d) { | |
var firstName = d.name.split(/\s+/)[0]; | |
var match = d.name.match(/.*\s+(.*)/); | |
var lastName = match ? match[1] : ''; | |
print(d.email + '\t' + firstName + '\t' + lastName); | |
}); |
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
db.users.aggregate( | |
{ | |
"$match": { | |
created_at: { $gte: ISODate("2014-09-01T00:00:00Z") } | |
} | |
}, | |
{ | |
"$project": { | |
_id: 0, | |
"isoDate": { $substr: [ "$created_at", 0, 10 ] } |
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
var emails = {}; | |
db.users.find().sort({_id: -1}).forEach(function(d) { | |
var email = d.email.split('@')[1]; | |
emails[email] |= 0; | |
emails[email]++; | |
}); | |
var sortable = []; | |
for (var email in emails) | |
sortable.push([email, emails[email]]) |
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
cd ~ | |
mkdir tools | |
cd tools | |
git clone https://github.com/thenigan/git-diffall.git | |
sudo ln -s ~/tools/git-diffall/git-diffall /usr/bin/git-diffall |
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
complete -W "$(echo $(grep '^ssh ' ~/.bash_history | sort -u | sed 's/^ssh //'))" ssh |
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
_.extend(Backbone.View.prototype, { | |
bubbleEventsTo : function(targetView) { | |
this.on("all", function() { | |
Backbone.View.prototype.trigger.apply(targetView, arguments); | |
}); | |
return this; | |
}) |
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
(function() { | |
Backbone.Model.prototype._save = Backbone.Model.prototype.save; | |
Backbone.Model.prototype.save = function(attrs, options) { | |
var that = this; | |
if (!options) { options = {}; } | |
if (this.savingNewRecord) { | |
// store or replace last PUT request with the latest version, we can safely replace old PUT requests with new ones | |
// but if there are callbacks from a previous PUT request, we need to make sure they are all called as well | |
_(['success','error']).each(function(event) { | |
// convert all callbacks to a single array of callbacks) |
OlderNewer