Skip to content

Instantly share code, notes, and snippets.

Mitchell Porter mitchellporter

View GitHub Profile
@warpling
warpling / Mento.playground
Last active Aug 1, 2019
Copying Tinder's "mentos" button animation (based on tweet: https://twitter.com/warpling/status/930567671015358464?s=20)
View Mento.playground
//: Playground - noun: a place where people can play
import UIKit
class Mento: UIView {
// The thickness ratio of our mento, 1.0 being a perfect sphere.
let mentoThicknessScale: CGFloat = 0.60
let shape: UIView = {
@timonus
timonus / programmatic-dynamic-images.m
Last active Jul 6, 2020
Programmatically create iOS 13 dynamic images
View programmatic-dynamic-images.m
- (UIImage *)dynamicImage
{
UITraitCollection *const baseTraitCollection = /* an existing trait collection */;
UITraitCollection *const lightTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]]];
UITraitCollection *const purelyDarkTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const darkTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[baseTraitCollection, purelyDarkTraitCollection]];
__block UIImage *lightImage;
[lightTraitCollection performAsCurrentTraitCollection:^{
lightImage = /* draw image */;
@laurenfazah
laurenfazah / express_postgress_knex.md
Last active Jul 26, 2020
Cheat Sheet: Setting up Express with Postgres via Knex
View express_postgress_knex.md

Express & Postgres via Knex

Note: <example> is meant to denote text replaced by you (including brackets).

Setup

// global dependencies
npm install -g knex
@NigelEarle
NigelEarle / Knex-Migrations-Seeding.md
Last active Aug 5, 2020
Migration and seeding instructions using Knex.js!
View Knex-Migrations-Seeding.md

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@Ben-G
Ben-G / L10NTests.swift
Created Jun 16, 2017
Very simple automated test to ensure localizations exist and are well-formed on iOS.
View L10NTests.swift
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 {
@brennanMKE
brennanMKE / genpass.swift
Last active Dec 10, 2018
Generate a password with Swift
View genpass.swift
#!/usr/bin/env xcrun swift
import Foundation
public typealias CharactersArray = [Character]
public typealias CharactersHash = [CharactersGroup : CharactersArray]
public enum CharactersGroup {
case Letters
case Numbers
@gerlacdt
gerlacdt / gracefulShutdown.js
Created Oct 25, 2016
Graceful shutdown of a nodejs server
View gracefulShutdown.js
'use strict';
/*
* Usage:
*
* const gracefulShutdown = require('./app/utils/gracefulShutdown');
*
* const server = app.listen(port, callback)
*
* gracefulShutdown.init(server, logger);
@coryhouse
coryhouse / mockDataSchema.js
Last active Jun 30, 2020
Mock Data Schema for "Building a JavaScript Development Environment" on Pluralsight
View mockDataSchema.js
export const schema = {
"type": "object",
"properties": {
"users": {
"type": "array",
"minItems": 3,
"maxItems": 5,
"items": {
"type": "object",
"properties": {
@NSExceptional
NSExceptional / ResponseParser.swift
Last active Feb 21, 2018
A simple class to automate the parsing of an NSURLSessionTask response.
View ResponseParser.swift
//
// Copyright © 2016 Tanner Bennett. All rights reserved.
//
import Foundation
typealias ResponseParserBlock = (ResponseParser) -> Void
class ResponseParser {
You can’t perform that action at this time.