Skip to content

Instantly share code, notes, and snippets.

View Slurpgoose's full-sized avatar
🦆

Slurpgoose

🦆
  • Bakkt
  • Atlanta, GA
View GitHub Profile
@almoore
almoore / nodeApp.service
Created December 18, 2017 03:59
Systemd node start script
[Unit]
Description=hello_env.js - making your environment variables rad
Documentation=https://example.com
After=network.target
[Service]
Environment=NODE_PORT=3001
Type=simple
User=root
ExecStart=/usr/bin/node /home/ubuntu/hello_env.js
@oepn
oepn / random-weighted-es6.js
Last active December 28, 2020 21:16 — forked from aesnyder/random-weighted.coffee
Weighted random value in ES6
// Defined first due to TDZ
let weighted = (...weightMap) => weightMap
.map(({0: value, 1: weight}) => new Array(weight).fill(value))
.reduce((acc, current) => [...acc, ...current]);
let random = (array) => array[Math.floor(Math.random() * array.length)];
// You can generate a weighted array
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active May 20, 2024 11:27
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');