Skip to content

Instantly share code, notes, and snippets.

View mitchellporter's full-sized avatar

Mitchell Porter mitchellporter

  • Seattle, WA
View GitHub Profile
@mitchellporter
mitchellporter / genpass.swift
Created November 16, 2016 03:42 — forked from brennanMKE/genpass.swift
Generate a password with Swift
#!/usr/bin/env xcrun swift
import Foundation
public typealias CharactersArray = [Character]
public typealias CharactersHash = [CharactersGroup : CharactersArray]
public enum CharactersGroup {
case Letters
case Numbers
@mitchellporter
mitchellporter / after_res_hooks.js
Created October 10, 2016 01:02 — forked from pasupulaphani/after_res_hooks.js
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@mitchellporter
mitchellporter / bootstrap.js
Created October 8, 2016 22:20 — forked from Unitech/bootstrap
PM2 / Keymetrics for Heroku/Rackspace/Joyent/Amazon Elasticbeanstalk/Azure...
// Make sure you added pm2 as a dependency in your package.json
// Then in your Procfile, do a simple `node bootstrap.js`
var pm2 = require('pm2');
var MACHINE_NAME = 'hk1';
var PRIVATE_KEY = 'z1ormi9vomgq66';
var PUBLIC_KEY = 'oa0m7nuhdfibi16';
var instances = process.env.WEB_CONCURRENCY || -1; // Set by Heroku or -1 to scale to max cpu core -1
@mitchellporter
mitchellporter / promise.js
Created October 8, 2016 22:08 — forked from wavded/promise.js
Promise A+ Implementation
"use strict"
var Promise = function () {
this.state = 'pending'
this.thenables = []
}
Promise.prototype.resolve = function (value) {
if (this.state != 'pending') return
this.state = 'fulfilled'
@mitchellporter
mitchellporter / Heroku_Staging.md
Created September 5, 2016 23:44 — forked from stevenyap/Heroku_Staging.md
Staging workflow on Heroku

This describes the workflow to use Heroku as a staging environment. It assumes you already have an existing heroku app in production.

# rename your git remote heroku to something else like production
git remote rename heroku production

# so now you will push as: git push production master

# create the staging app
heroku apps:create staging-appname
@mitchellporter
mitchellporter / gist:366958b8d0efb88ca04f8f29c04ffc01
Created August 31, 2016 21:24 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@mitchellporter
mitchellporter / fix-homebrew-npm.md
Created August 31, 2016 21:17 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@mitchellporter
mitchellporter / periscope.sh
Created August 19, 2016 02:36 — forked from dardo82/periscope.sh
Save Periscope Videos
#!/bin/zsh
cd "${0%/*}/../conf/url/"
for user in $(cat ../users.list); do
TWEETS=$(t search timeline -d -l user "#Periscope:" | grep -v " RT @")
OLDIFS=$IFS; IFS=$'\n'
for tweet in $(echo $TWEETS); do
DATE=$(echo $tweet | cut -d\ -f2-6)
OLD_LC_ALL=$LC_ALL; export LC_ALL="POSIX"
SEC=$(($(date +%s) - $(date -j -f ' %b %e %H:%M ' "$DATE" +%s)))
@mitchellporter
mitchellporter / getting-started.md
Created August 10, 2016 15:33 — forked from joepie91/getting-started.md
Getting started with Node.js

"How do I get started with Node?" is a commonly heard question in #Node.js. This gist is an attempt to compile some of the answers to that question.

And if this list didn't quite answer your questions, I'm available for tutoring and code review! A donation is also welcome :)

Javascript refresher

Especially if you normally use a different language, or you only use Javascript occasionally, it's easy to misunderstand some of the aspects of the language.

These links will help you refresh your knowledge of JS, and make sure that you understand the OOP model correctly.

@mitchellporter
mitchellporter / build_tvvlckit.sh
Created August 2, 2016 23:49 — forked from lg/build_tvvlckit.sh
Building MobileVLCKit for AppleTV: TVVLCKit
# note these instructions are as of Dec 28, 2015
# the vlc and vlckit repos are super complex and have thousands of dependencies from everywhere on the internet.
# so, you'll need to mess with things a bit
git clone http://code.videolan.org/videolan/VLCKit.git
cd VLCKit
./buildMobileVLCKit.sh -t