Skip to content

Instantly share code, notes, and snippets.

View nickcherry's full-sized avatar

Nick Cherry nickcherry

View GitHub Profile
@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 / 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 / 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 / application.css.txt
Last active August 29, 2015 14:18
Colorguard
$ colorguard --file application.css
Collision: #f7931d, #f89406
- #f7931d (#f7931d) [line: 148:14, 153:9] is too close (1.5127833911624) to #f89406 (#f89406) [line: 6015:76, 6016:58, 6017:48]
Collision: #00b4a4, #00b2a3
- #00b4a4 (#00b4a4) [line: 198:14, 203:9, 6620:14, 7055:12, 7058:14] is too close (0.6324791268300444) to #00b2a3 (#00b2a3) [line: 4804:20, 4812:20, 7191:20]
Collision: #00b4a4, #00b5a5
- #00b4a4 (#00b4a4) [line: 198:14, 203:9, 6620:14, 7055:12, 7058:14] is too close (0.28205982868491664) to rgba(0, 181, 165, 0.8) (#00b5a5) [line: 7070:14]
@nickcherry
nickcherry / chained-transitions.scss
Created April 1, 2015 14:08
Chained Transition
@mixin fade-in-out($duration: 0.6s, $ease: ease-out, $delay: 0s) {
opacity: 0;
transition: visibility 0s $ease ($duration + $delay), opacity $duration $ease $delay;
visibility: hidden;
&.visible {
opacity: 1;
transition-delay: 0s;
visibility: visible;
}
}
require 'benchmark'
iterations = 1_000_000
def rename(source, dest)
{ source: source, dest: dest }
end
Benchmark.bm do |bm|
@nickcherry
nickcherry / dictionary.json
Created January 4, 2015 17:37
Dictionary
This file has been truncated, but you can view the full file.
[
"bawk",
"bagawk",
"a",
"aa",
"aah",
"aahed",
"aahing",
"aahs",
"aal",
@nickcherry
nickcherry / caesar_cipher.rb
Last active August 29, 2015 14:12
Caesar Cipher
# To run the script:
# 1. Download caesar_cipher.rb
# 2. Download dictionary.json to the same directory (https://gist.githubusercontent.com/nickcherryjiggz/a615b4a39abedb84c50f/raw/3a8cec1c61cc6431bb84bdca19cab5ffb758ab8e/dictionary.json)
# 3. Open your terminal
# 4. Navigate to the directory where caesar_cipher.rb and dictionary.json live
# 5. Run the following command: ruby caesar_cipher.rb
require 'json' # We'll need this to parse the dictionary.
require 'open-uri' # We'll need this to fetch the dictionary from Github, if it's not available locally.
@nickcherry
nickcherry / controller.coffee
Last active April 26, 2017 00:00
custom-angular-select (array of objects)
angular.module 'angular-custom-select-examples', ['angular-custom-select']
.controller 'ExamplesController', ($scope) ->
$scope.selectedValues = {}
$scope.objects = [
{ name: 'Option A' }
, { name: 'Option B' }
, { name: 'Option C' }
, { name: 'Option D (disabled)', disabled: true }
@nickcherry
nickcherry / controller.coffee
Last active April 26, 2017 00:00
custom-angular-select (array of strings)
angular.module 'angular-custom-select-examples', ['angular-custom-select']
.controller 'ExamplesController', ($scope) ->
$scope.selectedValues = {}
$scope.strings = ['Option A', 'Option B', 'Option C', 'Option D', 'Option E']