Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
#
# This is a Git pre-commit hook.
#
# Reject commits that contain any of the following strings:
# # NO COMMIT | // NO COMMIT | #NOCOMMIT | //NOCOMMIT | etc
# debugger
# binding.pry
# console.log
@meagar
meagar / legacy_branches.rb
Created September 24, 2014 14:33
show legacy branches in a git repo
require 'time'
DAY = 60 * 60 * 24
def print_branches(branches)
by_author = Hash.new { |hash,key| hash[key] = {} }
branches.each do |branch|
lines = `git show -s --pretty=medium #{branch}`.lines
# commit d8f1e9d4c755d46192db635e964a9b04d6882f90
@meagar
meagar / keybase.md
Created October 8, 2014 21:25
keybase.md

Keybase proof

I hereby claim:

  • I am meagar on github.
  • I am meagar (https://keybase.io/meagar) on keybase.
  • I have a public key whose fingerprint is 6CBA F179 B60D D17D A8DA 9A06 B227 183C DC1F A2E5

To claim this, I am signing this object:

@meagar
meagar / SassMeister-input.sass
Created March 14, 2015 18:42
Generated by SassMeister.com.
// ----
// Sass (v3.4.12)
// Compass (v1.0.3)
// ----
.loggedIn
margin: 0
&.active
margin: auto
@meagar
meagar / gist:1204660
Created September 8, 2011 20:47
Exercise 07 - add closure
function isPrime( num ) {
// everything but 1 can be prime
var prime = num != 1;
for ( var i = 2; i < num; i++ ) {
if ( num % i == 0 ) {
prime = false;
break;
}
}
return prime;
@meagar
meagar / gist:1204679
Created September 8, 2011 20:54
Exercise 01 - functional vs OO
function logCar(car) {
console.info("I'm a", car.color, car.make);
}
function Car(make, color) {
this.make = make;
this.color = color;
}
Car.prototype.log = function () { logCar(this); }
@meagar
meagar / gist:1206576
Created September 9, 2011 15:53
Caching wrapper redux
Function.prototype.cachify = function () {
var cache = {}, self = this;
return function (arg) {
if (arg in cache) {
console.info('cache hit');
return cache[arg];
}
return cache[arg] = self.call(self, arg);
};
var Person = function(name) {
this.name = name;
};
// Part 2
Person.prototype.getName = function() {
return this.name;
};
var thomas = new Person('Thomas');
// Part 1
document.getElementById('the_div' ).addEventListener('click', function(){ log('the_div!') }, true);
document.getElementById('the_list').addEventListener('click', function(){ log('the_list!') }, false);
document.getElementById('the_item').addEventListener('click', function(){ log('the_item!') }, true);
// Part 2
document.getElementById('the_div' ).addEventListener('click', function(){ log('the_div!') }, false);
document.getElementById('the_list').addEventListener('click', function(){ log('the_list!') }, false);
@meagar
meagar / refresh-css.js
Last active October 13, 2015 12:38
Refresh only CSS via ctrl-R
/**
* Include via a <script> tag and reload CSS files via ctrl-R without a full-page refresh.
* Maintains your state, especially useful for JavaScript-based single-page apps
*
* Requires jQuery 1.6 or greater
*/
(function () {
"use strict";