Skip to content

Instantly share code, notes, and snippets.

View korneil's full-sized avatar

Kornél korneil

  • Stanford
  • Menlo Park
View GitHub Profile
@korneil
korneil / gist:2263414
Created March 31, 2012 12:29
nodejs's global
// index.js
require("./m.js").init();
console.log(global.hi);
// m.js
exports.init=function(){
global.hi="hi";
};
/*
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 March 25, 2012 18:05
recursive iteration
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);
});
}
@korneil
korneil / foo.js
Created March 10, 2012 23:04
just a try
function stuff(){
console.log("hi");
}