Skip to content

Instantly share code, notes, and snippets.

Promise.all([ 1000, 2000, 3000 ].map(async n => await new Promise(r => setTimeout(() => {
console.log(n)
r()
}, n))))
@ironman9967
ironman9967 / git-status-all-subdirs.sh
Last active August 19, 2017 16:35
run `git status` on all directories in the cwd
#!/bin/bash
for d in ./*/
do
echo ""
echo " -------------------------------------------- "
echo ""
echo ""
cd "$d"
echo "SUBDIR --> $d"
echo ""
chmod +x dist/index.js
cmd="[Unit]\n" \
"Description=[service]\n" \
"After=network.target\n" \
"\n" \
"[Service]\n" \
"ExecStart=/home/ubuntu/[user]/dist/index.js\n" \
"Restart=always\n" \
"User=myUser\n" \
import dgram from 'dgram'
const procId = process.argv[2]
const myPort = process.argv[3]
const theirPort = process.argv[4]
if (!procId) {
throw new Error("must supply a procId as the first argument")
}
if (!myPort) {
import Hapi from 'hapi'
import Good from 'good'
const {
connection,
register,
route,
start
} = new Hapi.Server()
@ironman9967
ironman9967 / gist:47a44b18f19288f6a952
Last active August 29, 2015 14:07
gets current and next dates based on day of week and week number
var _ = require('lodash');
var today = new Date('9/30/2014');
var dayOfWeek = "tuesday";
var weekNumber = 4;
console.log(getCurrentAndNext(today, dayOfWeek, weekNumber));
function getCurrentAndNext(today, dayOfWeek, weekNumber) {
var result = { current: void 0, next: void 0 };
@ironman9967
ironman9967 / addon.cc
Last active August 31, 2016 13:50
node-addon
#include <node.h>
using namespace v8;
struct point {
int x;
int y;
};
void pointerFunction(point* p) {