Skip to content

Instantly share code, notes, and snippets.

View SanderSpies's full-sized avatar
🐫
wasm

Sander SanderSpies

🐫
wasm
View GitHub Profile
@SanderSpies
SanderSpies / gist:7132734
Created October 24, 2013 07:24
Graph Idea
var graphDefinition = {
'somewhere': 'there is a ${./over/therainbow}',
'over':{
'therainbow' : 'pot of gold'
},
'value': 'genius',
'act':{
'of': '${../value}'
@SanderSpies
SanderSpies / gist:7039585
Created October 18, 2013 10:26
Simple input event polyfill
// function
function onKeyDown(e){
// [input|textarea] trigger input with target.value // in case of input field, textarea
// [contenteditable] trigger input with textContent // in case of contentEditable ?
}
// detect support for input
if(!'oninput' in document.createElement("input")){
// add polyfill in this case
}
@SanderSpies
SanderSpies / Protected Inheritance
Created August 29, 2013 06:15
Example for inheritance that protects the parent's functions by using Object.freeze
var Parent = function Parent(){
};
Parent.prototype = {
a:function a(){
console.log(333);
}
};
@SanderSpies
SanderSpies / PubSubManager.js
Created April 16, 2012 06:15
PubSubManager
define([], function () {
var PubSubManager = function PubSubManager() {
this.subscribers = {};
};
var instance = undefined;
PubSubManager.getInstance = function PubSubManager$getInstance() {
if (!instance) {
instance = new PubSubManager();