Skip to content

Instantly share code, notes, and snippets.

@joseanpg
joseanpg / declarative style evaluation.js
Created September 22, 2011 20:29 — forked from bga/declarative style evaluation.js
declarative style evaluation.js
/*
http://twitter.com/#!/bga_/status/116861871423885312
*/
Object.prototype.thunk = function(name, calc) {
Object.defineProperty(this,name,{get: function() {
var ret = calc();
delete this[name] // memo result
this[name] = ret;
@joseanpg
joseanpg / gist:1146822
Created August 15, 2011 14:06 — forked from juandopazo/gist:1146157
Concatenar arrays anidados sin recursividad
function esArray(array) {
return Object.prototype.toString.call(array) == '[object Array]');
}
function desempaqueta(array,index) {
Array.prototype.splice.apply(array, [index, 1].concat(array[index]));
}
function flatten(arr) {
arr = arr.concat();
@joseanpg
joseanpg / aplaneitor2.js
Created August 13, 2011 18:43 — forked from juandopazo/gist:1144127
Concatenar arrays anidados recursivamente
function aplaneitor2(arr,sep){
return function step(a){return Array.isArray(a) ? a.map(step).join(sep) : a}(arr);
}
var test = ["hola", ["soy", ["juan", "fernandez"] ], "y", ["no", "tengo", ["dinero"] ] ];
console.log(aplaneitor2(test,'**')) // -> hola**soy**juan**fernandez**y**no**tengo**dinero
var Ajax = (function (){
function AjaxXMLHTTPRequest(){}
AjaxXMLHTTPRequest.prototype = {...};
function AjaxActiveX(){}
AjaxActiveX.prototype = {};
return (typeof window.ActiveXObject === 'undefined') ?
AjaxXMLHTTPRequest: