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
#!/usr/bin/env node | |
/* | |
Installation: npm install linewise | |
Usage: | |
cat urls.json | node extract.js > urls.txt | |
Assuming urls.json contains lines with zero or more urls per line, this will | |
extract all the urls and produce a file with one url per line. |
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
// Needs to be run in the context of an extension with the "tabs" permission. | |
chrome.tabs.query({}, function(tabs) { | |
var byWindow = {}; | |
tabs.forEach(function(t) { | |
if(!byWindow[t.windowId]) { | |
byWindow[t.windowId] = [] | |
} | |
byWindow[t.windowId].push(t.url); | |
console.log(JSON.stringify(byWindow, null, 2)); |
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
// this function can get the full stack trace, however, it's usefulness is | |
// somewhat limited by the fact that Chrome Dev tools can only display full | |
// urls that are passed as the first argument as a string. That means that | |
// every log line is preceded by a massively ugly URL block that works as | |
// a link but this is only mildly useful. There is no way to get the dev | |
// tools to linkify shorter URLs - if that were possible, then this | |
// might be a usable solution from a UI perspective | |
function getStack() { | |
var orig = Error.prepareStackTrace; |
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() { | |
var repos = []; | |
function parse_link_header(header) { | |
// Split parts by comma | |
var parts = (header ? header.split(',') : []), | |
links = {}; | |
// Parse each part into a named link | |
parts.forEach(function(p) { |
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
echo "AlmondJS shim: " | |
curl --silent https://raw.github.com/jrburke/almond/master/almond.js | uglifyjs --no-copyright | wc -c | |
echo "Browserify shim: " | |
curl --silent https://raw.github.com/substack/node-browserify/master/wrappers/prelude.js | uglifyjs --no-copyright | wc -c | |
echo "Browserbuild shim: " | |
curl --silent https://raw.github.com/LearnBoost/browserbuild/master/lib/require.js | uglifyjs --no-copyright | wc -c | |
echo "GlueJS new shim: " |
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 i = 0; | |
function fillLocalStorage(size) { | |
try { | |
window.localStorage.setItem('data'+i++, new Array(size).join('a')); | |
} catch(e) { | |
if(size == 1) { | |
throw e; | |
} else { | |
return fillLocalStorage(Math.floor(size / 2)); | |
} |
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
Pipe curl to: | |
node -e 'var d = "", p=process.stdin; p.resume(); p.on("data", function(c){d+=c;}); p.on("end", function(){ console.log(require("util").inspect(JSON.parse(d), false, null, 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
#/bin/bash | |
git branch -r | while read line ; | |
do | |
echo | |
echo "************" ${line#origin/} | |
echo | |
git log -1 $line | |
done |
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 Animal = function(name) { | |
this.name = name; | |
}; | |
Animal.prototype.move = function(meters) { | |
console.log(this.name+" moved "+meters+"m."); | |
}; | |
var Snake = function() { | |
Animal.apply(this, Array.prototype.slice.call(arguments)); |
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
// Illustrates a difference in behavior between OSX and Linux | |
// (tested on OSX and Arch) | |
var http = require('http'); | |
var server = http.createServer(); | |
server.on('request', function (req, res) { | |
res.writeHead(200); | |
res.end('Hello world.'); |