Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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: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.
# 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: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.
@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:2587465
Last active October 9, 2023 01:26
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
"Encrypt" like this:
caesarShift('Attack at dawn!', 12); // Returns "Mffmow mf pmiz!"
And "decrypt" like this:
@EvanHahn
EvanHahn / Unlicense.txt
Created April 30, 2012 19:05
Unlicense backup
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@EvanHahn
EvanHahn / gist:2473233
Created April 23, 2012 19:24
Quickly-made flashcards for Asian 261
<!--
Quickly-made flashcards file, by Evan Hahn (evanhahn.com)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any