Skip to content

Instantly share code, notes, and snippets.

@m5m1th
m5m1th / runAll.js
Last active December 19, 2015 08:09
Simple script to run a bunch of projects at once (Windows requires grunt.cmd for some reason)
var spawn = require('child_process').spawn;
spawn('node', ['app.js'], {stdio: 'inherit', cwd: 'gaviota-api/'});
spawn('node', ['app.js'], {stdio: 'inherit', cwd: 'gaviota-proxy/'});
spawn('node', ['app.js'], {stdio: 'inherit', cwd: 'gaviota-api-async/'});
spawn('node', ['app.js'], {stdio: 'inherit', cwd: 'mf-public-web/'});
spawn('grunt.cmd', ['server:fastcss'], {stdio: 'inherit', cwd: 'TrainerWeb/'});
spawn('sass.bat', ['--compass', '--watch', 'styles/main.scss:styles/main.css'], {stdio: 'inherit', cwd: 'TrainerWeb/app/Trainer/'});
@m5m1th
m5m1th / devChallenge1.js
Created December 5, 2014 21:53
Dev Challenge! What are all the issues with this code? Hint: there are several.
var hyperquest = require('hyperquest');
var result;
module.exports = function downloadUtf8FileIntoString(url, cb) {
if (!url) return cb(Error('url is required'));
result = '';
hyperquest(url)
.pipe(function (chunk, enc, tCb) {
result += chunk.toString('utf8'); // binary to utf8
tCb();
})
@m5m1th
m5m1th / localPorts.sh
Last active May 27, 2020 04:57
Redirect port 3080/3443 to 80/443 for local dev
#Requests from outside
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3080
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3443
#Requests from localhost
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 3080
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 443 -j REDIRECT --to-ports 3443