Skip to content

Instantly share code, notes, and snippets.

View getify's full-sized avatar
💭
Just coding

Kyle Simpson getify

💭
Just coding
View GitHub Profile
function abc() {
var u = 12;
return function() {
eval("alert(u);");
};
}
var blah = abc();
blah();
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;
// 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(){
// 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?
[] == 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
// 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 = {
var FOO = (function() {
var a = "Hello";
return {
something:function(){
alert(a); // referenced via closure
}
};
})();
<html>
<head>
<script>var _queue = [];</script>
</head>
<body>
...
...
<script>
var $ = function(fn) {
setTimeout(fn,2000);
};
$.foo = "yay";
$(function(){
alert($.foo); // which $ am I looking at?
});
$.foo = "cool";
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