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 / gracefulShutdown.js
Created August 9, 2017 23:18 — forked from gerlacdt/gracefulShutdown.js
Graceful shutdown of a nodejs server
'use strict';
/*
* Usage:
*
* const gracefulShutdown = require('./app/utils/gracefulShutdown');
*
* const server = app.listen(port, callback)
*
* gracefulShutdown.init(server, logger);

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@mitchellporter
mitchellporter / L10NTests.swift
Created June 16, 2017 20:48 — forked from Ben-G/L10NTests.swift
Very simple automated test to ensure localizations exist and are well-formed on iOS.
import Foundation
import XCTest
/// Basic sanity check that ensures that we are able to retrieve localized strings for all languages
/// we support.
final class L10NTests: XCTestCase {
func testLocalizations() {
let locales = ["en", "es", "zh-Hans", "zh-Hant", "fi"]
for locale in locales {
//: Mocks Playground
import UIKit
struct User {
}
struct PushNotificationController {
let registrar: PushNotificationRegistrar
init(registrar: PushNotificationRegistrar) {

#Installing ngrok on OSX

  1. Download ngrok
  2. Unzip it to your Applications directory
  3. Create a symlink (instructions below)

Creating a symlink to ngrok

Run the following two commands in Terminal to create the symlink.

# cd into your local bin directory
@mitchellporter
mitchellporter / mockDataSchema.js
Created April 18, 2017 21:21 — forked from coryhouse/mockDataSchema.js
Mock Data Schema for "Building a JavaScript Development Environment" on Pluralsight
export const schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
@mitchellporter
mitchellporter / ello.md
Created April 18, 2017 21:17 — forked from conatus/ello.md
Ello API

Ello API

This is a basic exploration of the Ello API. Completely unofficial, your mileage my vary, don't smash their servers as they are likely very busy.

Methods return HTML for their representation where appropriate which is a nice little pattern. Everything returns application/json.

Like this:

{
 "id": ,
@mitchellporter
mitchellporter / mongoose-find-by-reference-field.js
Created March 16, 2017 01:16 — forked from furf/mongoose-find-by-reference-field.js
Finding a thing by reference using a non ID field.
var mongoose = require('mongoose'),
// Load User model
User = mongoose.model('User'),
// Create Thing schema
thingSchema = new mongoose.Schema({
_user: {
type: ObjectId,
@mitchellporter
mitchellporter / Procfile
Created March 12, 2017 04:38 — forked from stephenlb/Procfile
Twitter / PubNub Bridge - Heroku Worker
tweetstream: node twitter-pubnub-stream.js
@mitchellporter
mitchellporter / server-part.js
Created March 12, 2017 03:09 — forked from nleush/server-part.js
Node.JS + MongoDB: automatic anonymous user creation
// This function implements anonymous creation logic.
function loadOrCreateAnonymousProfile(req, res, next) {
var sess = req.session,
auth = sess && sess.auth;
if (!auth || !auth.userId) {
dbCounter('anonymousUsers', function(err, counter) {
if (err) {
console.log('Error getting anonymous users counter', err);
next();