Skip to content

Instantly share code, notes, and snippets.

@j03m
j03m / gist:4acc586bc9965d2f7237
Created April 28, 2015 14:50
docker via homebrew
brew cask install virtualbox
brew install docker
brew install boot2docker
boot2docker init
boot2docker up
docker run -i -t ubuntu /bin/bash
@j03m
j03m / gist:b171a3b1930656434bbb
Created April 28, 2015 14:31
docker mac fishshell fix
boot2docker shellinit ^ /dev/null | source.
@j03m
j03m / gist:e001d6acf222bce6636e
Created April 28, 2015 14:22
to:joe subj:boot2docker from:homebrew
i 8> u
To have launchd start boot2docker at login:
ln -sfv /usr/local/opt/boot2docker/*.plist ~/Library/LaunchAgents
Then to load boot2docker now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.boot2docker.plist
@j03m
j03m / gist:2022cf4c82305dec26a7
Created December 8, 2014 15:23
find matching curly brackets - takes into account that it might hit strings yay (from dev_tools chrome source)
findBalancedCurlyBrackets: function(source, startIndex, lastIndex) {
lastIndex = lastIndex || source.length;
startIndex = startIndex || 0;
var counter = 0;
var inString = false;
for (var index = startIndex; index < lastIndex; ++index) {
var character = source[index];
if (inString) {
if (character === "\\")
@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
@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: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: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: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 / 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