This file contains hidden or 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 retry(isDone, next) { | |
| var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false; | |
| var id = window.setInterval( | |
| function() { | |
| if (isDone()) { | |
| window.clearInterval(id); | |
| next(is_timeout); | |
| } | |
| if (current_trial++ > max_retry) { | |
| window.clearInterval(id); |
This file contains hidden or 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
| // Reloading modules from the repl in Node.js | |
| // Benjamin Gleitzman (gleitz@mit.edu) | |
| // | |
| // Inspired by Ben Barkay | |
| // http://stackoverflow.com/a/14801711/305414 | |
| // | |
| // Usage: `node reload.js` | |
| // You can load the module as usual | |
| // var mymodule = require('./mymodule') | |
| // And the reload it when needed |
This file contains hidden or 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
| alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`" |
This file contains hidden or 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/sh | |
| npm install |
This file contains hidden or 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
| /** | |
| * Simple node.js style script loader for modern browsers | |
| **/ | |
| function loadScript(src, cb) { | |
| var script = document.createElement('script'); | |
| script.async = true; | |
| script.src = src; | |
| script.onerror = function() { | |
| cb(new Error("Failed to load" + src)); |
This file contains hidden or 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/sh | |
| #Based on this Mac OS X Hint: | |
| #http://hints.macworld.com/article.php?story=20110511111211385 | |
| #Modified for input of multiple commands to seperate .PS files | |
| CACHE=~/.mancache | |
| mkdir -p $CACHE | |
| COMMANDS="$@" | |
| for f in $COMMANDS | |
| do |
This file contains hidden or 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
| /** | |
| * Simple Node.js recursivily copy/rename files with specific pattern | |
| * @license WTFPL | |
| * @usage $ node copyFiles.js | |
| */ | |
| var fs = require('fs'), | |
| config; | |
| // config options | |
| config = { |
This file contains hidden or 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
| // from http://scratch99.com/web-development/javascript/convert-bytes-to-mb-kb/ | |
| function bytesToSize(bytes) { | |
| var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
| if (bytes == 0) return 'n/a'; | |
| var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); | |
| if (i == 0) return bytes + ' ' + sizes[i]; | |
| return (bytes / Math.pow(1024, i)).toFixed(1) + ' ' + sizes[i]; | |
| }; |
This file contains hidden or 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
| Recovering from a botched rebase: | |
| 1) mess up a rebase | |
| 2) `git reflog` and find the last commit before the rebase started | |
| 3) `git reset --hard <<that commit>>` | |
| 4) rebase again and try not to mess up this time |
This file contains hidden or 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 request; | |
| var progressBar; | |
| function loadImage(imageURI) | |
| { | |
| request = new XMLHttpRequest(); |