Skip to content

Instantly share code, notes, and snippets.

@FredLackeyOfficial
FredLackeyOfficial / ncu-update-all.sh
Created March 14, 2017 20:39
Use npm-check-updates recursively to update Node modules and Bower components.
cmd_exists() {
command -v "$1" &> /dev/null
}
ncu-update-all(){
if ! cmd_exists "ncu"; then
printf "ncu is required, please install it!\n"
exit 1
fi
@FredLackeyOfficial
FredLackeyOfficial / ips.sh
Last active March 1, 2017 17:35
Simple bash function to find all active IP address, their MAC address, and the adapter manufacturer.
cmd_exists() {
command -v "$1" &> /dev/null
}
ips(){
local usage="ips [%NETWORK_BASE_IP%] [%BIT_DEPTH%] [ip-only | no-sudo]"$'\n'"Default IP: 192.168.1.0"$'\n'"Default Mask: 24"
local addr="$1";
local mask="$2";
local prefix="";
local suffix="";
@FredLackeyOfficial
FredLackeyOfficial / get-tunes.sh
Created March 1, 2017 16:27
Simple bash function to pull down videos and audio tracks from YouTube playlists.
get-tunes(){
local usage="get-tunes %PLAYLIST_OR_VIDEO_URL% [audio-only | video-only]";
local url="$1";
local option="$2";
local prefix="";
if [ -f "/usr/local/bin/youtube-dl" ]; then
prefix="/usr/local/bin/";
fi
if [ -z "${url}" ]; then
echo "Problem fetching track: Track URL not supplied";
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@FredLackeyOfficial
FredLackeyOfficial / node-enum-example.js
Last active November 16, 2016 17:15
Brainstorming boilerplate enum template for NodeJS
/**
* Created by Fred Lackey on 11/16/16.
*/
/*
Provides maximum flexibility when dealing with enums.
SCHEMA:
var schema = new mongoose.Schema({
status : { type: String, enum: enums.TOKEN_STATUS.ids }
@FredLackeyOfficial
FredLackeyOfficial / index.js
Last active April 15, 2016 21:17
Exploring Express use order
var express = require('express'),
router = express.Router();
router.use(init);
function init (req, res, next) {
req.appData = req.appData = {};
next();
}