Skip to content

Instantly share code, notes, and snippets.

Nick Cherry nickcherry

Block or report user

Report or block nickcherry

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lonely.js
function lonelyInteger(arr) {
return arr.reduce((acc, n) => acc ^ n);
}
const arr = [1, 4, 1, 2, 3, 4, 3];
console.log(lonelyInteger(arr));
// 2
View fetch_candles.js
/*************************************************************************************/
/* 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');
View debtors.rb
class Balance
attr_accessor :person, :amount
def initialize(person, amount)
@person, @amount = person, amount
end
def to_s
"#{ person }: #{ amount }"
end
View trained_bayes.js
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,
@nickcherry
nickcherry / browser_counts_last_month.rb
Created Feb 26, 2016
Browser Counts Signed in within Last Month - 2016-02-26
View browser_counts_last_month.rb
{
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,
@nickcherry
nickcherry / browser_counts.rb
Created Feb 26, 2016
Browser Counts - 2016-02-26
View browser_counts.rb
{
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 / pre-push
Last active Aug 29, 2015
Git Push Confirmation
View pre-push
#!/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 ]
View find_updated_at_less_collections.js
db.getCollectionNames().forEach(function(collection) {
if (!db[collection].find({ updated_at: { $exists: true }}).count()) {
print(collection + " collection does not have an updated_at field.")
}
});
You can’t perform that action at this time.