Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@rwaldron
rwaldron / .vimrc
Created July 26, 2011 13:18 — forked from jeresig/.vimrc
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
@rwaldron
rwaldron / ago.js
Created August 5, 2011 15:00 — forked from gf3/ago.js
Super small relative dates
module.exports = (function(){
const MS =
{ seconds: 1000
, minutes: 60 * 1000
, hours: 60 * 60 * 1000
, days: 24 * 60 * 60 * 1000
, weeks: 7 * 24 * 60 * 60 * 1000
, months: 30 * 7 * 24 * 60 * 60 * 1000
, years: 365 * 24 * 60 * 60 * 1000 }
var Person = {
'initialize': function(first, last) {
this.first = first;
this.last = last;
},
'speak': function(message) {
return this.first + ' ' + this.last + ': ' + message;
}
};
@rwaldron
rwaldron / es6proxy.htm
Created September 9, 2011 14:56 — forked from nzakas/es6proxy.htm
Example of ES6 Proxy
<!DOCTYPE html>
<!--
This is a simple experiment relying on ECMAScript 6 Proxies. To try this out,
use Aurora (http://www.mozilla.org/en-US/firefox/channel/).
The goal was to create a HTML writer where the method names were really just
the HTML tags names, but without manually creating each method. This uses
a Proxy to create a shell to an underlying writer object that checks each
method name to see if it's in a list of known tags.
@rwaldron
rwaldron / stack.js
Created September 12, 2011 20:02 — forked from nzakas/stack.js
Stack implementation using ES6 proxies
/*
* Another ES6 Proxy experiment. This one creates a stack whose underlying
* implementation is an array. The proxy is used to filter out everything
* but "push", "pop", and "length" from the interface, making it a pure
* stack where you can't manipulate the contents.
*/
var Stack = (function(){
var stack = [],
@rwaldron
rwaldron / getMyCode.js
Created September 24, 2011 16:37 — forked from creationix/getMyCode.js
Script to download all repos for a user
// Run this with node and then run the output with sh
var Http = require('http')
var ChildProcess = require('child_process');
Http.cat("http://github.com/api/v2/json/repos/show/creationix", function (err, json) {
if (err) throw err;
var data = JSON.parse(json);
data.repositories.forEach(function (repo) {
console.log("echo " + JSON.stringify(repo.name + " - " + repo.description));
console.log("git clone --bare " + repo.url);
});
@rwaldron
rwaldron / Pattern.lua
Created September 24, 2011 16:37 — forked from creationix/Pattern.lua
Pattern.js ported to Lua
Pattern = {}
function Pattern:extend(obj)
local child = obj or {}
setmetatable(child, {__index = self})
return child
end
function Pattern:new(...)
local obj = {}
@rwaldron
rwaldron / no-comma-first.js
Created October 5, 2011 13:49 — forked from indexzero/no-comma-first.js
JUST SAY NO TO COMMA FIRST
var fs = require('fs'),
path = require('path'),
colors = require('colors'),
argv = require('optimist').argv;
fs.readFile(path.join(__dirname, argv._[0]), function (err, data) {
var lines = data.toString().split('\n');
for (var i = 0; i < lines.length; i++) {
@rwaldron
rwaldron / jsfiddle-defaults.user.js
Created October 30, 2011 12:23 — forked from mathiasbynens/jsfiddle-defaults.user.js
Userscript that enables sensible defaults for jsFiddle.
// ==UserScript==
// @name Sensible defaults for jsFiddle.
// @author Mathias Bynens <http://mathiasbynens.be/>
// @link http://mths.be/bde
// @match http://jsfiddle.net/*
// ==/UserScript==
// Ignore existing fiddles
if (window.location.pathname == '/') {
@rwaldron
rwaldron / class.js
Created November 1, 2011 14:40 — forked from DmitrySoshnikov/class.js
Class lib sugar for JS
/**
* class.js
* @author Dmitry A. Soshnikov
*/
function Class(params) {
/**
* Constructor function
* If not specified, use default