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
attrs = { a: true, b: true, c: false, d: true, e: false } | |
_.each attrs, (val, key) => | |
console.log(key, val) | |
@[key] = val | |
# a true | |
# b true | |
# c false |
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.getCollectionNames().forEach(function(collection) { | |
if (!db[collection].find({ updated_at: { $exists: true }}).count()) { | |
print(collection + " collection does not have an updated_at field.") | |
} | |
}); |
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/bash | |
# Inspired by http://dev.ghost.org/prevent-master-push/ | |
# Add this script to the following path in your local git repo: | |
# .git/hooks/pre-push | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ 'master' = $current_branch ] || [ 'staging' = $current_branch ] || [ 'production' = $current_branch ] |
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
{ | |
nil => 5007, | |
"Android 1" => 2, | |
"Android 2" => 1, | |
"Android 36" => 35, | |
"Android 38" => 1, | |
"Android 39" => 3, | |
"Android 4" => 4, | |
"Android 40" => 1, | |
"Android 43" => 5, |
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
{ | |
nil => 1092, | |
"Android 1" => 2, | |
"Android 38" => 1, | |
"Android 4" => 3, | |
"Chrome 28" => 1, | |
"Chrome 32" => 1, | |
"Chrome 35" => 15, | |
"Chrome 36" => 151, | |
"Chrome 38" => 3, |
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
const classifier = new BayesClassifier(); | |
classifier.train('BarackObama', 'Fighting climate change with solar power creates jobs.'); | |
classifier.train('elonmusk', 'Turns out ExxonMobil not 100% forthcoming about climate change'); | |
classifier.train('elonmusk', 'Yeah, climate change should really be considered a centrist issue, as it affects everyone.'); | |
classifier.stemCounts | |
/* | |
{ | |
'100': 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
class Balance | |
attr_accessor :person, :amount | |
def initialize(person, amount) | |
@person, @amount = person, amount | |
end | |
def to_s | |
"#{ person }: #{ amount }" | |
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
on |
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
/*************************************************************************************/ | |
/* Import Dependencies */ | |
/*************************************************************************************/ | |
const { mapSeries } = require('async'); | |
const axios = require('axios'); | |
const fs = require('fs'); | |
const { chain, flatten, sortBy, sortedUniqBy } = require('lodash'); | |
const moment = require('moment'); |
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
on |