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 / module_pattern_init.js
Created April 28, 2011 01:40 — forked from nathansmith/module_pattern_init.js
Init + Module Pattern JS
//
// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern
//
var APP = (function(window, document, $, undefined) {
// For use only inside APP.
var PRIVATE_CONSTANT_1 = 'foo';
var PRIVATE_CONSTANT_2 = 'bar';
// Expose contents of APP.
@rwaldron
rwaldron / var-indenting.js
Created April 29, 2011 02:33 — forked from cowboy/var-indenting.js
JavaScript var indenting thoughts.
// I don't have answers yet, just questions. Keep in mind that I prefer code
// that is easiest to maintain.
// Example from http://www.nczonline.net/blog/2010/10/26/wanted-dynamic-execution-contexts-in-javascript/
// Consider:
// Let's say you start with this, but need to (in a later commit) add a few
// additional vars.
var myglobal = {
@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();
@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();
/*!
* 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 / 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).

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 / 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
@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 / 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"