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 / postgres-cheatsheet.md
Created September 13, 2017 18:11 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@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 {
@mitchellporter
mitchellporter / config.json
Created June 10, 2017 20:54
CasperJS - Page rendering
{
"viewportSizes": [480, 720, 1200]
}
@mitchellporter
mitchellporter / main.js
Created June 10, 2017 20:23
CapserJS - Scraping google search results
const casper = require('casper').create();
const fs = require('fs');
var data;
casper.on('remote.message', function(msg) {
console.log('remote message is: ' + msg);
});
casper.start('http://www.google.com/', function() {
//: Mocks Playground
import UIKit
struct User {
}
struct PushNotificationController {
let registrar: PushNotificationRegistrar
init(registrar: PushNotificationRegistrar) {
@mitchellporter
mitchellporter / async-await.js
Created June 6, 2017 20:51
async/await IIFE snippet
(async () => {
const func = () => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('some async result');
}, 5000);
});
}

#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": {