Skip to content

Instantly share code, notes, and snippets.

@timrwood
timrwood / timrwood.bash_profile
Created September 14, 2011 17:25
timrwood bash_profile
# @@@@@@@ @@@@@@@ @@@@@@ @@@@@@@@@@ @@@@@@@ @@@@@@@
# @@! @@@ @@! @@@ @@! @@@ @@! @@! @@! @@! @@@ @!!
# @!@@!@! @!@!!@! @!@ !@! @!! !!@ @!@ @!@@!@! @!!
# !!: !!: :!! !!: !!! !!: !!: !!: !!:
# : : : : : :. : : : : :
RESET="\[\033[0;37;00m\]"
GREEN="\[\e[0;32m\]"
@timrwood
timrwood / gist:1280098
Created October 12, 2011 02:41
moment.closest requirements

Functionality

Show the date with the smallest order of magnitude of difference from now.

Names

closest

calendar

@timrwood
timrwood / gist:1335476
Created November 3, 2011 01:04
140 bytes change making
function x(total, values, place) {
var output = i = 0,
f = function(i){
output += (i == total);
};
while (place = values[i++]) {
(function(b,c){
f = function(a, i){
@timrwood
timrwood / LICENSE.txt
Created November 3, 2011 21:27 — forked from 140bytes/LICENSE.txt
Ways to make change for a dollar (or any other amount)
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Tim Wood <timwoodcreates.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@timrwood
timrwood / gist:1407315
Created November 30, 2011 00:21
ES5 native research
http://kangax.github.com/es5-compat-table/
http://stackoverflow.com/questions/6799559/javascript-reserved-keywords
http://stackoverflow.com/questions/5306315/browser-support-for-using-a-reserved-word-as-a-property-name-in-javascript
http://stackoverflow.com/questions/4298594/javascript-keywords-in-hash-keys
@timrwood
timrwood / gist:1535827
Created December 29, 2011 19:36
Critter Chaos Lite Level 1
{
"collectables": [{
"py": 349,
"px": 599,
"id": 281
}],
"obstacles": [{
"py": 426,
"sx": 198,
"f": 2,
@timrwood
timrwood / gist:1734013
Created February 4, 2012 00:27
moment lang test migrator
var fs = require("fs");
var wrapReplace = /}\);\s*test\((["a-zA-Z ]+), ?(\d+), ?function\(\)\s*{/g;
var replace = " test.done();\n },\n\n $1 : function(test) {\n test.expect($2);";
var erg = /}\);\s*$/g;
var es = 'test.done();\n }\n};';
var frg = /\s*module\((["a-zA-Z:\- ]+)\);\s*test\((["a-zA-Z ]+), ?(\d+), ?function\(\)\s*{/g;
var fst = "\n\nexports[$1] = {\n $2 : function(test) {\n test.expect($3);";
@timrwood
timrwood / moment.calendarWithoutTime.js
Created February 8, 2012 16:50
Moment calendar without time plugin
(function(){
var oldcal = moment.calendar;
var newcal = {
sameDay : '[Today]',
nextDay : '[Tomorrow]',
nextWeek : 'dddd',
lastDay : '[Yesterday]',
lastWeek : '[last] dddd',
sameElse : 'L'
};
@timrwood
timrwood / gist:2726713
Created May 18, 2012 17:53
Routing roundup
@timrwood
timrwood / gist:2789940
Created May 25, 2012 19:08
Year difference
var now = new Date();
var birth = new Date(1986, 6, 10); // remember that we're using zero indexed months...
var yearDiff = now.getFullYear() - birth.getFullYear();
var monthDiff = now.getMonth() - birth.getMonth();
var dayDiff = now.getDate() - birth.getDate();
var hourDiff = now.getHours() - birth.getHours();
var minuteDiff = now.getMinutes() - birth.getMinutes();
var secondDiff = now.getSeconds() - birth.getSeconds();
var millisecondDiff = now.getMilliseconds() - birth.getMilliseconds();