Skip to content

Instantly share code, notes, and snippets.

@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();
}
@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 }
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@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";
@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 / 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 / remove-all-group-members.js
Created March 30, 2017 14:15
Remove all members from Facebook group
// Load the group's member list and then paste this into the console.
// You may have to hit RETURN after the end of it.
// And you'll also have to click the CONFIRM button a bunch of times.
var deleteAllGroupMembers = (function () {
var deleteAllGroupMembers = {};
// the facebook ids of the users that will not be removed.
// IMPORTANT: add your own facebook id here so that the script will not remove yourself!
var excludedFbIds = ['1234','11223344']; // make sure each id is a string!
var usersToDeleteQueue = [];
@FredLackeyOfficial
FredLackeyOfficial / dreamfactory-docker-up.sh
Created June 21, 2017 18:19
Bash script to bring up Dreamfactory in Docker
#!/bin/bash
main(){
local PROJECT_PATH="$(realpath "../")";
local PROJECT_NAME="$(basename $PROJECT_PATH)";
create_network "$PROJECT_NAME"
create_databases "$PROJECT_NAME"
create_dreamfactory "$PROJECT_NAME"
}
@FredLackeyOfficial
FredLackeyOfficial / git-keep
Created June 21, 2017 18:56 — forked from miraculixx/git-keep
create .keep files for empty directories currently ignored by git
#!/bin/bash
# create .keep files for empty directories currently ignored by git
# run git clean -nd to see which directories are empty and therefore ignored by git currently
# run git keep to add these directories by adding a .keep file
# see this discussion http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository/21422128#21422128
git clean -nd | awk '{ print $3 }' | xargs -L1 -I{} touch {}.keep
@FredLackeyOfficial
FredLackeyOfficial / README.md
Last active October 25, 2017 22:33
Using DbSchema with Postgres, Sequelize, and Sequelize-Auto

Using DbSchema with Postgres & Sequelize

The road to using Postgres, Sequelize, Sequelize-Auto, and DbSchema have some bumps along the way. More specifically, these "bumps" have to do with automatic incrementing and audit fields. These are the steps I recommend when working with this combination.

Rule #1: Do not use Sync
Sequelize-Auto does not handle indexes. For this reason, any indexes created in DbSchema will be ignored. This is why we use DbSchema to work with database modifications. We only tweak enough of Sequelize's models to work with the columns. Since the models will not have indexes by default, we must never use Sequelize to push changes to the database.

The process...

1. Define Sequences