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 / sm.js
Created May 10, 2012 14:39 — forked from dherman/sm.js
sm.js with classes
/*
* Here is an implementation of an NPM module I recently wrote, done with ES6 classes.
* Is it a "betrayal" of the prototypal nature of JavaScript to use classes? Come on.
* Classes are a very common design pattern that's easy to implement with prototypes.
* And for some use cases, they're a good fit. Node's EventEmitter abstraction is a
* perfectly reasonable use of classes and inheritance: it's an abstract datatype that's
* user-extensible. So the 'events' module provides a base class with some built-in
* functionality that you can extend.
*
* And yes, it's a "class." Just check the docs:
@rwaldron
rwaldron / data-markdown.user.js
Created May 10, 2012 00:48 — forked from paulirish/data-markdown.user.js
*[data-markdown] - use markdown, sometimes, in your HTML
// ==UserScript==
// @name Use Markdown, sometimes, in your HTML.
// @author Paul Irish <http://paulirish.com/>
// @link http://git.io/data-markdown
// @match *
// ==/UserScript==
// If you're not using this as a userscript just delete from this line up. It's cool, homey.
@rwaldron
rwaldron / git_logging.txt
Created April 25, 2012 16:27 — forked from softprops/git_logging.txt
fancy git log flags
git log --all --pretty=format:"%h %cd %s (%an)" --since='7 days ago'
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short --since='1 day ago'
git log --pretty=format:"%ad, %s%d [%an]" --graph --date=short --since='1 day ago'
(function (exports) {
// These aliases can be safely removed.
var toString = {}.toString, hasOwn = {}.hasOwnProperty,
// **defer** attempts to execute a callback function asynchronously in supported
// environments.
defer = function (callback, context) {
// `process.nextTick` is an efficient alternative to `setTimeout(..., 0)`.
// As of Node 0.6.9, neither `process.nextTick` nor `setTimeout` isolate
// execution; if the `callback` throws an exception, subsequent deferred
@rwaldron
rwaldron / es-monsters.js
Created April 8, 2012 00:02
ES Monsters
// A private name used by the Monster class
const pHealth = Name.create();
class Monster {
// A method named "new" defines the class’s constructor function.
new(name, health) {
this.name = name;
this[pHealth] = health;
@rwaldron
rwaldron / hack.sh
Created March 31, 2012 13:56 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@rwaldron
rwaldron / mouse.js
Created March 12, 2012 14:47 — forked from bfncs/mouse.js
Read Linux mouse(s) in node.js
/**
* Read Linux mouse(s) in node.js
* Author: Marc Loehe ([email protected])
*
* Adapted from Tim Caswell's nice solution to read a linux joystick
* http://nodebits.org/linux-joystick
* https://github.com/nodebits/linux-joystick
*/
var fs = require('fs'),
@rwaldron
rwaldron / short-functions.js
Created March 12, 2012 14:45 — forked from dherman/short-functions.js
using -> for concise functions and => for TCP functions
// 1. Shorter function syntax.
//
// This version does not respect "Tennent's correspondence principle" -- it's nothing
// more than syntactic sugar for the traditional function syntax. That means when you
// see the normal braced body of a function, whether it's a longhand function or this
// shorthand version, there's no difference: return, this, and arguments are all tied
// to the new function body, and there's no implicit returning of the last expression
// result.
a.some((x) -> {
@rwaldron
rwaldron / z.js
Created February 27, 2012 17:09 — forked from heapwolf/z.js
z
//
// an experimental flow control library.
// please dont ever use this for anything.
//
var z = function z(f) {
if (!(this instanceof z)) {
return new z(f);
}
@rwaldron
rwaldron / z.js
Created February 27, 2012 17:08 — forked from bga/z.js
z
var match = []
var _finalizeExpr = function(match) {
var vs = match[0]
var _iter = match[1]
var _done = match[2]
var i = 0
var _iterWrappper = function() {
if(i === vs.length) {