Skip to content

Instantly share code, notes, and snippets.

@airportyh
airportyh / browserifiability.md
Last active February 23, 2016 07:16
Browserify Search Request For Help

Browserify Search Request For Help

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

@gregersrygg
gregersrygg / notify-install.sh
Last active August 29, 2015 14:00
Removed shebang to make it less than 140 bytes
echo -e 'S=${*:-`cat`}\n/usr/bin/osascript -e "display notification \"$S\""'|sudo -s "cd /usr/local/bin;tee notify&&chmod +x notify"
@telent
telent / gist:9742059
Last active February 19, 2024 09:30
12 factor app configuration vs leaking environment variables
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
#!/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
@creationix
creationix / app.js
Last active December 30, 2015 07:29
Generate a tree of events using process.addAsyncListener
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);
@rraptorr
rraptorr / stunnel-4.56-xforwarded-for.diff
Created May 17, 2013 14:51
X-Forwarded-For stunnel 4.56 patch
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"
@domenic
domenic / promises.md
Last active March 31, 2024 14:07
You're Missing the Point of Promises

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.

You're Missing the Point of Promises

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.
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];
@firedfox
firedfox / onDOMContentLoaded.js
Created April 24, 2012 02:12
phantomjs onDOMContentLoaded
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);
}
@ramnathv
ramnathv / gh-pages.md
Created March 28, 2012 15:37
Creating a clean gh-pages branch

Creating a clean gh-pages branch

This is the sequence of steps to follow to create a root gh-pages branch. It is based on a question at [SO]

cd /path/to/repo-name
git symbolic-ref HEAD refs/heads/gh-pages
rm .git/index
git clean -fdx
echo "My GitHub Page" &gt; index.html