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 / ba-ghettotmpl.js
Created June 11, 2011 14:25 — forked from cowboy/ba-ghettotmpl.js
Ghetto fabulous templating system. More ghetto than fabulous.
// Ghetto fabulous template system for replacing values in strings. If {{.foo}}
// or {{.bar[0].baz}} is encountered (leading dot), attempt to access properties
// of data object like `data.foo` or `data.bar[0].baz`. Alternately, if {{foo}}
// or {{bar("baz")}} is encountered (no leading dot), simply evaluate `foo` or
// `bar("baz")`. If an error occurs, return empty string. @rworth++
function ghettoTmpl(data, str) {
return (str + '').replace(/\{\{((\.)?.*?)\}\}/g, function(_, str, dot) {
return eval('try{' + (dot ? 'data' : '') + str + '}catch(e){""}');
});
Getting up and running with OS X, Textmate & Scheme
===================================================
SCHEME
======
I ran across two implementations of Scheme which appear to work well with OS X.
mit-scheme & PLT Scheme.
I was able to install mit-scheme from darwin ports ( sudo port install mit-scheme)
@rwaldron
rwaldron / gist:1007531
Created June 4, 2011 03:16 — forked from voodootikigod/gist:1007426
BS ≈ BreakfastScript
Conditionals
( false :)
console.log "if"
:( true )
console.log "else if"
:()
console.log "else"
@rwaldron
rwaldron / annoying.js
Created June 1, 2011 16:16 — forked from Kilian/annoying.js
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@rwaldron
rwaldron / ProjectEuler.coffee
Created June 1, 2011 01:30 — forked from Janiczek/ProjectEuler.coffee
First few Project Euler problems solved in CoffeeScript. Comments on how to make it more beautiful (in terms of CoffeeScript, not algorithm) highly appreciated!
@_1 = ->
# sum of multiples of 3 or 5 (not both) under 1K
answer = 0
for n in [1...1000]
if n % 3 == 0 or n % 5 == 0
answer += n

This perhaps deserves a blog post, but whatever.

The challenge: What if you wanted to determine what level my Bulgarian language skills were at? Using this sample document:

{
    "name": {
        "first": "Lloyd",
        "last": "Hilaiel"
    },

"favoriteColor": "yellow",

@rwaldron
rwaldron / description.md
Created May 23, 2011 22:22 — forked from alunny/description.md
my git configuration

My Git Configuration

For best results, use hub and git bash completion (included with git under contrib/completion).

/*!
* jQuery initData - v0.1pre - 5/18/2011
* http://benalman.com/
*
* Copyright (c) 2011 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){
@rwaldron
rwaldron / this-propagation.js
Created May 19, 2011 01:59 — forked from cowboy/this-propagation.js
JavaScript: A few ways to work around the lack of `this` propagation in inner functions
var name = 'window baby';
var obj = {
name: 'object baby',
// This is totally broken, because inner functions don't "inherit" the outer
// function's `this` value. Instead, their `this` value is the global object.
broken: function() {
function doStuff() {
return this.name + '!?!';
}
return doStuff();
@rwaldron
rwaldron / gist:970812
Created May 13, 2011 16:07 — forked from anonymous/gist:970223
Object.prototype.toString redefinition for DOM objects with WeakMap
"use strict";
/* ***
** ENVIRONNEMENT SETTING
*/
(function(global){
var constructorName = "MyDOMNode";
var MyDOMNodeMap = WeakMap();