Skip to content

Instantly share code, notes, and snippets.

View ibolmo's full-sized avatar
🧠

Olmo Maldonado ibolmo

🧠
View GitHub Profile
@ibolmo
ibolmo / Injectigator AsciiView POC
Created November 12, 2009 20:31
Proof of concept for the Ascii Viewer for the executed JavaScript.
/*
# With vertical
├ Node Title ┐
│ ├ Node Title, 1000 ms
│────────────┘
# Without vertical and optional line number
@ibolmo
ibolmo / gist:238253
Created November 18, 2009 21:13
istype / instanceof gibberish
function log(var_) {
console.log(var_);
return var_;
}
function istype(test, Ctor) {
if (Ctor == void 0 && test == void 0) return true;
return log(test.constructor == Ctor || test instanceof Ctor);
}
//** Compat 1.2
Array.implement({
});
//**/
(If compat is unnecessary... strip the first '/' and let the rest of the build process continues, the rest of the code (comment) is automatically deleted by builder(s) or the JS skips the code since it's a comment.)
/** Compat 1.2
Array.implement({
$ python sexp.py test.js
(SCRIPT
(VAR (INITVAR a (FUNCTION (_ __ ___) (SCRIPT
(DEF-FUNCTION (b) (SCRIPT))))))
(VAR (INITVAR c 'hello world')))
/**
* Explanation: before compression, remove any first '/' for matched: ^[ \t]*\/\/\*\* *(Compat|Fix)\:?(\w)*
* That are not necessary for the build. E.g. if the build is for 1.3 with no compat, then all Compat
* matches will lose the first '/' and therefore all of that code becomes commented. Similarly for browser
* fixes.
*
* During compression, the user can optionally remove the comments and thereby removing the rest of the code.
*
* Otherwise, there is not JavaScript performance loss due to commenting. Parser will just skip.
*
'protected mutator method'.replace(/(\w*) +(?!(\w*)^)/g, function(m) {
console.log(m);
return '';
});
// original (1.99dev)
String.implement({
contains: function(string, separator){
return ((separator) ? (separator + this + separator).indexOf(separator + string + separator) : this.indexOf(string)) > -1;
}
});
// new
// horrible(?) attempt at minimizing global pollution and other tricks made by Jaml.
HAML('simple').
div().adopt().
h1('Some title').
p('Some exciting paragraph text').
br().
ul().adopt().
li('First item').
li('Second item').
@ibolmo
ibolmo / demo-alt-requires-syntax.html
Created December 11, 2009 19:47
How Shell/Forge can interpret Demos.
<html>
<head>
<title>Demo Title</title>
<meta name="description">Demo Description</meta>
<style class="shell css">
/* Demo CSS */
</style>
<script src="deps.js" title="Authors can generate a deps.js, or include from a temp (.gitignored) file."></script>
<script class="shell js requires" src="../Source/MyPlugin.js" title="'requires' help builders"></script>
@ibolmo
ibolmo / Function.compose.js
Created December 17, 2009 02:15
Helper for "wrapping" methods.
Function.compose = function(){
var fn, i = 0, fns = arguments, results = [];
return function(){
while(fn = fns[i]) results[i++] = fn.apply(this, arguments);
return results;
};
};
/*
Usage: