Skip to content

Instantly share code, notes, and snippets.

@geraldalewis
geraldalewis / gist:1711902
Created January 31, 2012 18:03
Emulating `let`
var print = console.log;
var header = function(name){print("\n>>"+ name.toUpperCase() +"<<")}
var subheader = function(name){print(" >"+ name +"< ")}
header("iterating arrays");
subheader("emulated let");
(function() {
var callbacks = [];
@geraldalewis
geraldalewis / implicit_this.coffee
Created February 18, 2012 02:08
Implicit `this` in CoffeeScript
class Sprite
@id: 0
id: -1
x: 0
y: 0
width: 0
height: 0
@geraldalewis
geraldalewis / gist:3742581
Created September 18, 2012 10:59
Do does
class Frame
constructor: (@elements) ->
methods = ['remove', 'show', 'hide', 'stop']
for method in methods
do (method) ->
Frame::[method] = ->
element[method]() for element in @elements
@geraldalewis
geraldalewis / ringer.js
Created April 14, 2017 15:38
Smart styled <button> focus ring behavior
function initializeRinger(){
var pressedAt = 0;
document.removeEventListener('DOMContentLoaded', initializeRinger);
function checkRing(target){
if (!target.classList.contains('ringer')) return;
if (target.classList.contains('ringer-no-ring')) return;
target.classList.add('ringer-no-ring');
}
function onpress(event){