This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function abc() { | |
var u = 12; | |
return function() { | |
eval("alert(u);"); | |
}; | |
} | |
var blah = abc(); | |
blah(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var promise = (function(){ | |
var undef; | |
function Promise(){} | |
Promise.prototype.constructor = Promise; | |
return function(cb) { | |
var publicAPI, queue = [], old_ret, promise_fulfilled = false; | |
function fulfill(val) { | |
var ret_val = val; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// promise() comes from: http://gist.github.com/311586 | |
// show possible "error" handling | |
function xhrcall(){ | |
return promise(function(P){ | |
var xhr = new XMLHttpRequest(); | |
xhr.open("GET","/"); | |
xhr.onreadystatechange = function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// be careful with those implicit .toString() calls in == comparison | |
typeof "abc" == "string" // true | |
typeof String("abc") == "string" // true | |
String("abc") == "abc" // true -- same types get casted to equal each other | |
String("abc") instanceof String // false -- hmmm... | |
(new String("abc")) instanceof String // true | |
String("abc") == (new String("abc")) // true -- wait, wtf? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[] == 0 | |
+[] === 0 | |
++[] === 1 // sorta, though this is invalid js syntax, so... | |
[[]][0] === [] | |
++[[]][0] === 1 | |
++[[]][+[]] === 1 // yay! wtf! | |
// FYI: this comes from John Resig explaining here: | |
// http://news.ycombinator.com/item?id=1154338 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LABjs.jquery.ready -- adds .ready() to $LAB api for wrapping a .wait() and a $(document).ready(...) together | |
// v0.0.1 (c) Kyle Simpson | |
// MIT License | |
(function(global){ | |
var oDOC = global.document; | |
if (!global.$LAB || !global.jQuery) return; // only adapt LABjs if LABjs exists and jQuery is present | |
function wrap_API(obj) { | |
var ret = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var FOO = (function() { | |
var a = "Hello"; | |
return { | |
something:function(){ | |
alert(a); // referenced via closure | |
} | |
}; | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script>var _queue = [];</script> | |
</head> | |
<body> | |
... | |
... | |
<script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $ = function(fn) { | |
setTimeout(fn,2000); | |
}; | |
$.foo = "yay"; | |
$(function(){ | |
alert($.foo); // which $ am I looking at? | |
}); | |
$.foo = "cool"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +ExecCGI | |
AddHandler perl-script cgi | |
PerlResponseHandler ModPerl::Registry | |
PerlOptions +ParseHeaders | |
RewriteEngine on | |
RewriteCond %{ENV:REDIRECT_REDIRECT_INTERNAL_ROUTING} !yes | |
RewriteRule .* routing.cgi [L,E=INTERNAL_ROUTING:yes] | |
## So, this .htaccess file first redirects all requests to one script |