Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
EvanHahn / gist:2623123
Created May 6, 2012 16:13
JavaScript Trabb Pardo-Knuth function
/*
JavaScript Trabb Pardo-Knuth function
by Evan Hahn (evanhahn.com)
licensing info at bottom of file
This doesn't ask for input because you might want to use it in the browser or
in Node or something.
Call like this:
@EvanHahn
EvanHahn / gist:2626784
Created May 7, 2012 09:00
CoffeeScript Caesar shift
###
CoffeeScript Caesar shift
by Evan Hahn (evanhahn.com)
* * * * * * * * * * * *
For small occasions (like month-anniversaries), I like to make little websites
for people that only "unlock" on the right day.
# Install something if we don't already have it
# Call like this:
# gimme git
# gimme hg pip
# gimme coffee npm (note that npm installs globally)
# This isn't particularly thorough (i.e., it assumes Ubuntu even if it's Debian).
# Sorry!
@EvanHahn
EvanHahn / gist:2847033
Created May 31, 2012 23:00
Wikipedia restyling
/*
Wikipedia restyling
by Evan Hahn (evanhahn.com)
Made for Stylebot.
**********************************************************************
This is free and unencumbered software released into the public domain.
@EvanHahn
EvanHahn / typechecking-matchers.js
Created June 11, 2012 03:34
Typechecking Jasmine matchers
/* Typechecking Jasmine matchers
by Evan Hahn (evanhahn.com)
Simple Jasmine matchers for checking types. Include this file to get the
following matchers:
expect(foo).toBeA(Thing); // Checks if foo is an instance of Thing.
// Alias: toBeAn(AwesomeThing)
expect(foo).toBeANumber();
expect(foo).toBeAnInteger();
@EvanHahn
EvanHahn / gist:2955637
Last active October 6, 2015 07:08
Instead of this, use Paul Miller's solution: https://github.com/paulmillr/console-polyfill
// Make console methods no-ops in unsupported browsers, complete
// More versions: <http://evanhahn.com/?p=990>
var noop = function(){};
window.console || (window.console = {});
window.console.assert || (window.console.assert = noop);
window.console.clear || (window.console.clear = noop);
window.console.count || (window.console.count = noop);
window.console.debug || (window.console.debug = noop);
window.console.dir || (window.console.dir = noop);
@EvanHahn
EvanHahn / gist:2955643
Last active October 6, 2015 07:07
Instead of this, use Paul Miller's solution: https://github.com/paulmillr/console-polyfill
// Make console methods no-ops in unsupported browsers, terse
// More versions: <http://evanhahn.com/?p=990>
var noop = function(){};
window.console || (window.console = {});
window.console.error || (window.console.error = noop);
window.console.info || (window.console.info = noop);
window.console.log || (window.console.log = noop);
window.console.warn || (window.console.warn = noop);
@EvanHahn
EvanHahn / gist:2955696
Last active October 6, 2015 07:07
Instead of this, use Paul Miller's solution: https://github.com/paulmillr/console-polyfill
# Make console methods no-ops in unsupported browsers, complete
# More versions: <http://evanhahn.com/?p=990>
noop = ->
window.console || (window.console = {})
window.console.assert || (window.console.assert = noop)
window.console.clear || (window.console.clear = noop)
window.console.count || (window.console.count = noop)
window.console.debug || (window.console.debug = noop)
window.console.dir || (window.console.dir = noop)
@EvanHahn
EvanHahn / gist:2955704
Last active October 6, 2015 07:08
Instead of this, use Paul Miller's solution: https://github.com/paulmillr/console-polyfill
# Make console methods no-ops in unsupported browsers, terse
# More versions: <http://evanhahn.com/?p=990>
noop = ->
window.console || (window.console = {})
window.console.error || (window.console.error = noop)
window.console.info || (window.console.info = noop)
window.console.log || (window.console.log = noop)
window.console.warn || (window.console.warn = noop)
@EvanHahn
EvanHahn / gist:3309613
Created August 10, 2012 00:38
Strip HTML tags
var tagsStripped = str.replace(/<[^>]*>/g, '');