Skip to content

Instantly share code, notes, and snippets.

Kornél korneil

View GitHub Profile
@korneil
korneil / gist:2263414
Created Mar 31, 2012
nodejs's global
View gist:2263414
// index.js
require("./m.js").init();
console.log(global.hi);
// m.js
exports.init=function(){
global.hi="hi";
};
/*
View config.js
exports.Config={
backend:{
host:"nodejs",
port:80
},
files:{
chunkSize:1024*100, // size of chunks that a file is requested from server, saved, removed etc (bytes)
timeout404:60, // remove file from 404 list if it was not found after given amount of seconds (seconds)
//recheckBackendStatus:3600, // check if file's status and size changed on backend (seconds)
maxStorageSize:20*1024*1024, // maximum storage used for cached files (bytes)
@korneil
korneil / iteration.js
Created Mar 25, 2012
recursive iteration
View iteration.js
function a(i){
var aLotOfVariable;
iDo.some.asyncStuff(function(){
// here the callstack can grow huge a(0)->a(1)->a(2)->a(3)
// question is how to avoid this.
if(i<1000) a(i+1);
});
}
View foo.js
function stuff(){
console.log("hi");
}
You can’t perform that action at this time.