Skip to content

Instantly share code, notes, and snippets.

/* this shit is the dumb... ignore pls */
function clone(obj){
if(obj == null || typeof(obj) != 'object')
return obj;
var temp = {};
for(var key in obj) temp[key] = clone(obj[key]);
return temp;
}
@fat
fat / gist:859445
Created March 7, 2011 22:58
make this better.
function __tailingFn () {
for (var i = arguments.length; i--;) {
if (typeof arguments[i] == 'function') {
var fn = arguments[i];
arguments[i] = undefined;
return fn;
}
}
}
Dashboard.Format = {
types: {
bytes: ['b', 'kb', 'MB', 'GB', 'TB', 'PB'],
integer: ['', 'K', 'M', 'B', 'T', 'P']
},
abbreviate: function(metric, value){
var i = value ? Math.floor(Math.log(value)/Math.log(metric.devisor)) : 0;
return (value/Math.pow(metric.devisor, Math.floor(i))).round(2).format({
group: ',',