Skip to content

Instantly share code, notes, and snippets.

View nickcherry's full-sized avatar

Nick Cherry nickcherry

View GitHub Profile
@nickcherry
nickcherry / gotcha.coffee
Created April 29, 2015 14:06
Implicit Returns
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
@nickcherry
nickcherry / find_updated_at_less_collections.js
Created June 8, 2015 19:50
Find updated_at-less Collections
db.getCollectionNames().forEach(function(collection) {
if (!db[collection].find({ updated_at: { $exists: true }}).count()) {
print(collection + " collection does not have an updated_at field.")
}
});
@nickcherry
nickcherry / pre-push
Last active August 29, 2015 14:23
Git Push Confirmation
#!/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 ]
@nickcherry
nickcherry / browser_counts.rb
Created February 26, 2016 15:53
Browser Counts - 2016-02-26
{
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,
@nickcherry
nickcherry / browser_counts_last_month.rb
Created February 26, 2016 15:59
Browser Counts Signed in within Last Month - 2016-02-26
{
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,
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,
class Balance
attr_accessor :person, :amount
def initialize(person, amount)
@person, @amount = person, amount
end
def to_s
"#{ person }: #{ amount }"
end
/*************************************************************************************/
/* 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');