Skip to content

Instantly share code, notes, and snippets.

@j03m
j03m / gist:7473710
Last active December 28, 2015 08:48
bindalicious
/*Expected usage:
var swapFade = jc.swapFade.bind(this);
swapFade(this.statsFrame.card, card);
Or
this.swapFade = jc.swapFade.bind(this);
*/
@j03m
j03m / gist:7990567
Created December 16, 2013 17:13
async no no
var async = require('async');
var operations = [
function player1Mp(callback) {
setTimeout(function(){
console.log("1");
callback('fail', undefined);
}, 400);
},
function player2Mp(callback) {
setTimeout(function(){
var jc = jc || {};
if (!jc.isBrowser){
function runBrowserMock(){
window = jc;
jc.addEventListener = function(entry, method){
method();
}
jc.removeEventListener = function(){
@j03m
j03m / gist:7c1656cd33d422ea6aab
Last active August 29, 2015 14:00
cua-ish vim
set nocompatible
set history=700
set backspace=indent,eol,start
set history=700
filetype plugin on
filetype indent on
set wildmenu
set wildignore=*.o,*~,*.pyc
set ruler
set number
@j03m
j03m / lc
Created May 6, 2014 22:35
lc = ls || cat depending on context
# If stdin present, assume user meant cat
#
if [ ! -t 0 ]
then
cat "$@"
exit
fi
# Find the argument that is file/directory name and test it
# to find out if it is an existing directory. Other arguments are
@j03m
j03m / gist:8bf0d088e586a2976661
Created August 21, 2014 14:30
Dependency injection sample
//global space
var MockDepedency = function(){}
MockDepedency.prototype.getValue = function(){
console.log("What what what what!!!");
}
function __setter(name){
"use strict";
@j03m
j03m / gist:fab2d946c6d5ffea163f
Created August 21, 2014 17:44
dependency injection with dynamic scoping
var MyClass = require("./classScope1.js");
function setter(name, value){
eval(name+"=value");
}
MyClass.injectSetter(String(setter));
MyClass.setter('fs', {});
var myclass = new MyClass();
myclass.go2();
@j03m
j03m / gist:23c45904ca383c7eab29
Last active August 29, 2015 14:05
hax all the things from the obj
function dump(obj){
while(obj!==undefined){
for(var key in obj){
log("j03m: " + key + " is " + obj[key].toString());
}
try{
obj = Object.getPrototypeOf(obj);
}catch(e){
obj = undefined;
}
@j03m
j03m / gist:7ff6d0aef714fb2747f4
Created October 21, 2014 22:28
sometimes i hate js in the face
function test(){
var a = function(){ console.log("called but ignored return"); return 7;};
return a(), function(){
console.log("if you do this, i hate you.");
return 5;
}();
}
console.log(test());
console.log("something"), console.log("somethingelse");
@j03m
j03m / gist:f209cefefdae0256e3b2
Created December 5, 2014 21:36
instrument all the js
replace this: ((\w*)[\.\:\=\s]*function\s*(\w*)\(.*\)\s*\{)
with this: $1\tconsole.log\("$2$3"\);\n