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
module.exports = function(fileInfo, api) { | |
var j = api.jscodeshift; | |
var out = j(fileInfo.source) | |
.find(j.Literal) | |
.forEach(function (path) { | |
// Only consider literals that start/end w/ double quotes | |
if (!/^".*"$/.test(path.value.raw)) { | |
return; | |
} |
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
/** | |
* Utility lib for setting/unsetting JavaScript breakpoints | |
* | |
* Usage: | |
* breakpoint.set('globalMethodName'); | |
* breakpoint.unset('globalMethodName'); | |
* | |
* breakpoint.set('namespacedMethodName', namespaceObject); | |
* breakpoint.unset('namespacedMethodName', namespaceObject); | |
*/ |
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
/* npm install -g source-map */ | |
var fs = require('fs'); | |
var sourceMap = require('source-map'); | |
var rawSourceMap = fs.readFileSync('./app.js.map').toString(); | |
var smc = new sourceMap.SourceMapConsumer(rawSourceMap); | |
// output original filename, line, column, token for input {line, column} | |
// in built/minified file (e.g. app.min.js) |
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
~ » 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 |
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
List of websites that force anonymous visitors to sign in to view content indexed by Google: | |
quora.com | |
estocksdaily.com | |
travelzoo.com |
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
// 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()); |
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
// 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'); | |
}); | |
})(); |
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 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 + ';'); |
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
/** | |
* 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 = [], |
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
//-------------------------------------------------- | |
// Get binary value of checkbox checked/not-checked | |
//-------------------------------------------------- | |
// Seen often: | |
$('selector').attr('checked') ? 1 : 0; | |
// Alternatively: | |
Number($('selector').is(':checked')); |
NewerOlder