View ow.js
1
$('img').attr('src', 'http://i2.kym-cdn.com/photos/images/facebook/000/001/582/picard-facepalm.jpg');
View textnode-innerhtml.js
1 2 3 4 5 6 7 8 9 10
/**
* Proof of concept ESLint rule for warning about potential
* XSS vulnerabilities caused by mixing innerHTML/text node
* property access.
*
* More here: http://benv.ca/2012/10/2/you-are-probably-misusing-DOM-text-methods/
*/
'use strict';
var WARNING_MSG =
View gist:5889180
1 2 3 4 5 6 7 8 9 10
~ » curl -s -D - https://github.com -o /dev/null ben@Sinclair-2
HTTP/1.1 200 OK
Server: GitHub.com
Date: Sat, 29 Jun 2013 00:52:59 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 200 OK
Cache-Control: private, max-age=0, must-revalidate
Strict-Transport-Security: max-age=2592000
X-Frame-Options: deny
View gist:3361951
1 2 3 4 5
List of websites that force anonymous visitors to sign in to view content indexed by Google:
 
quora.com
estocksdaily.com
travelzoo.com
View gist:3208798
1 2 3 4 5 6 7 8 9
// Execute fn for each element in arr, releasing to the UI
// thread (via underscore's _.defer) between each execution
 
_.chainedDefer = (function () {
function next(arr, fn, scope) {
if (!arr.length)
return;
fn.call(scope, arr.shift());
View gist:3140509
1 2 3 4 5 6 7 8 9
// no document ready check - put this at the end of <body>
 
;(function() {
var pre = Array.prototype.slice.call(document.getElementsByTagName('code'));
 
pre.forEach(function (p) {
p.setAttribute('contenteditable', 'true');
});
})();
View gist:2474195
1 2 3 4 5 6 7 8 9 10
function forEach(arr, fn) {
var impl = fn.toString();
var m = impl.match(/function \((\w+),?\s*(\w+)?\) { (.*) }/);
var arg0 = m[1];
var arg1 = m[2];
var body = m[3];
var program = [];
program.push('var ' + arg0 + ';');
if (arg1)
program.push('var ' + arg1 + ';');
View subdomain.js
1 2 3 4 5 6 7 8 9
/**
* Replace $.ajax on your subdomain with a copy taken
* from your base domain. All jQuery AJAX actions go
* through $.ajax (i.e. $.get, $.post), so it's all good.
*/
(function() {
var iframe,
onload,
queue = [],
View gist:727646
1 2 3 4 5 6 7 8 9
//--------------------------------------------------
// Get binary value of checkbox checked/not-checked
//--------------------------------------------------
 
// Seen often:
$('selector').attr('checked') ? 1 : 0;
 
// Alternatively:
Number($('selector').is(':checked'));
View gist:726057
1 2 3 4 5 6 7 8 9 10
// Relevant jQuery Template source:
// https://github.com/jquery/jquery-tmpl/blob/master/jquery.tmpl.js#L206
 
// Example usage: {{pretty_datetime some.date.obj}}
 
$.extend(jQuery.tmpl.tag, {
"pretty_datetime": {
open: "if($notnull_1){_.push(pretty_datetime($1a));}"
}
});
Something went wrong with that request. Please try again.