I have been working on making a search index for npm modules that work with browserify. In order to do this, obviously, for each module on npm, I need to determine whether or not it works with browserify. Easy! I thought. I will run the browserify cli tool on the module browserify node_modules/that_module
, and if it exits normally, it works with browserify. So I did that, and implemented a search engine on this premise. Except that, in the search results, I found a lot of modules which, although it "passed the test", they still were useless because simple the act of loading the bundle in a browser would result in a runtime error - a lot of these were a result of the module testing for process.versions.node
which doesn't exist in the browserify process shim. Okay, I thought, I'll run the resulting bundle in jsdom, genious! That did reject lots of modules, but it still wasn't good enough. I still got a lot of modules in the search inde
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 -e 'S=${*:-`cat`}\n/usr/bin/osascript -e "display notification \"$S\""'|sudo -s "cd /usr/local/bin;tee notify&&chmod +x notify" |
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
App configuration in environment variables: for and against | |
For (some of these as per the 12 factor principles) | |
1) they are are easy to change between deploys without changing any code | |
2) unlike config files, there is little chance of them being checked | |
into the code repo accidentally | |
3) unlike custom config files, or other config mechanisms such as Java |
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 | |
# - updates ubuntu | |
# - creates a sudo-able non-root user called $user_name (for logging into the server later and doing stuff) | |
# - sets up ssh keys for that user by copying the over from /root/.ssh | |
# - disables ssh root login (that's what $user_name is for) | |
# - creates a system user "taco" for the taco process to run as | |
# - sets up basic iptables firewall | |
# | |
printf '\e[1;34m%b\e[m' "\nUpdating the system...\n" | |
apt-get -y -qq update |
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 http = require('http'); | |
var send = require('send'); | |
var urlParse = require('url').parse; | |
var count = 2; | |
var server = http.createServer(function (req, res) { | |
if (!--count) server.close(); // Only allow two connection and then exit. | |
send(req, urlParse(req.url).pathname) | |
.root(__dirname) | |
.pipe(res); |
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
diff --git a/doc/stunnel.8 b/doc/stunnel.8 | |
index 7624a27..3593f24 100644 | |
--- a/doc/stunnel.8 | |
+++ b/doc/stunnel.8 | |
@@ -753,6 +753,10 @@ This options has been renamed to \fInone\fR. | |
.RE | |
.RS 4 | |
.RE | |
+.IP "\fBxforwardedfor\fR = yes | no" 4 | |
+.IX Item "xforwardedfor = yes | no" |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
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 collectData(){ | |
function copy(src, obj, keys){ | |
for(var name, i = 0, len = keys.length; i < len; i++){ | |
name = keys[i]; | |
if(typeof src[name] !== 'undefined'){ | |
if (typeof src[name] === 'function') { // function this and that | |
} else if (typeof src[name] === 'object'){ | |
for(var subkey in src[name]){ obj[name+'_'+subkey] = src[name][subkey]; } | |
} else { | |
obj[name] = src[name]; |
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
const PHANTOM_FUNCTION_PREFIX = '/* PHANTOM_FUNCTION */'; | |
var page = require('webpage').create(); | |
page.onConsoleMessage = function(msg) { | |
if (msg.indexOf(PHANTOM_FUNCTION_PREFIX) === 0) { | |
eval('(' + msg + ')()'); | |
} else { | |
console.log(msg); | |
} |