Skip to content

Instantly share code, notes, and snippets.

View mathewsanders's full-sized avatar

Mathew Sanders mathewsanders

View GitHub Profile
@mathewsanders
mathewsanders / neo-neopolitan-pizza-dough.md
Last active October 1, 2020 14:45
Pizza pizza pizza!

Neo-Neopolitan Pizza Dough

Makes 4-5 pizza bases. You can also use this focaccia bread/garlic herb bread.

Ingredients

  • 680 g bread flour or Italian "OO" flour (5 1/3 cups)
  • 14 g salt (2 teaspoon regular salt or 1 tablespoon coarse salt)
  • 3 g instant yeast (1 teaspoon)
  • 482 g water at room temp ~75-80F (2 cups + 2 tablespoons)
  • 28 g sugar or honey or agave (2 tablespoons)
@mathewsanders
mathewsanders / Email template
Created June 3, 2020 01:48
NYC Controller Request
To: action@comptroller.nyc.gov
Subject: NYC Expense Budget Reform
Dear Scott Stringer,
My name is [Name] and I am a resident of [Borough]. Last April, NYC Mayor Bill De Blasio proposed major budget cuts for the fiscal year 2021, especially to education and youth programs, while refusing to slash the NYPD budget by any significant margin. I urge you to consider pressuring the office of the mayor towards an ethical and equal reallocation of the NYC Expense Budget, away from NYPD, and towards social services and education programs, effective at the beginning of FY 21, July 1st.
It’s time to defund the NYPD’s harmful expansion into homeless services, schools, youth services, mental health, and other social services where police don’t belong. It’s time to protect investments in human services, the social safety net, racial and economic justice, and the vision that all New Yorkers deserve to thrive. Historically, the city government has spent far more on police than on public health, homeless services, youth se
@mathewsanders
mathewsanders / Animation.playground.swift
Last active March 13, 2017 21:15
Example of exploring animation in a playground with use of UISlider to scrub animation.
import UIKit
import PlaygroundSupport
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
containerView.backgroundColor = .white
// Show the container view in the Assistant Editor
PlaygroundPage.current.liveView = containerView
// transformations for the dots to be pushed to either left or right of capsule
@mathewsanders
mathewsanders / FlattenTests.swift
Created March 9, 2017 15:43
XCTest to look at tail-call optimization
import XCTest
class FlattenTests: XCTestCase {
var input: [Any] = []
override func setUp() {
let test: [Any] = [1, [2], [3, [4]], [5, [6]], 7, [8], [[[[9, [10]]], [11, [12], 13]], 14, [15, [16]], [17, [18]], 19], 20, [21, 22], [23, 24, 25]]
@mathewsanders
mathewsanders / ResizingTextView.swift
Created January 3, 2017 21:01
TextView subclass that animates resize as text is entered
import UIKit
/// TextView subclass that animates resize as text is entered
/// Should be used with constraints that pin width so that contentView
/// expands in height to accommodate the current text
class ResizingTextView: UITextView {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
isScrollEnabled = false
@mathewsanders
mathewsanders / SubstringTests.swift
Created January 3, 2017 15:41
Benchmark substring speed
//
// SubstringTests.swift
// SubstringTests
//
// Created by Mat on 1/3/17.
// Copyright © 2017 Mat. All rights reserved.
//
import XCTest
@mathewsanders
mathewsanders / FooBar.swift
Created October 24, 2016 19:14
Hashable enum
enum FooBar: Hashable {
case foo(String)
case bar
case baz
// I want to use an enum as a dictionary key, so it needs to be Hashable,
// will hardcoding hashValues like this lead to a disaster? What's a better alternative?
public var hashValue: Int {
switch self {
@mathewsanders
mathewsanders / CGSize+Extension.swift
Created October 14, 2016 19:20
Create CGContext from a CGSize
extension CGSize {
typealias ContextClosure = (_ context: CGContext, _ frame: CGRect) -> ()
func image(withContext context: ContextClosure) -> UIImage? {
UIGraphicsBeginImageContext(self)
let frame = CGRect(origin: .zero, size: self)
context(UIGraphicsGetCurrentContext()!, frame)
let image = UIGraphicsGetImageFromCurrentImageContext()
@mathewsanders
mathewsanders / pattern-matching.swift
Last active April 25, 2016 00:56
Array pattern matching
// the types of items that a template can be built up from, in the future I'd be interested in expanding this
// to allow a wider range of options.
enum TemplateItem<T> {
case Exact(T) // matches only this exact element
case Either([T]) // matches any one of the elements given
case LazySequence // matches any sequence of elements
}
// create a template to describe the pattern you want to look for in the array
let moreThanTemplate: [TemplateItem<String>] = [
@mathewsanders
mathewsanders / regex.swift
Created April 25, 2016 00:35
Using a regular expression to check for a possible rule structure
let pattern = "(greater|more|)(.+)(than|)(.+)"
let regex = try! NSRegularExpression(pattern: pattern, options: .CaseInsensitive)
let text = "more blue triangles than red circles"
let matches = regex.matchesInString(text, options: [], range: NSRange(location: 0, length: text.characters.count))
if let match = matches.first {
let seperator1 = (text as NSString).substringWithRange(match.rangeAtIndex(1))
let fragment1 = (text as NSString).substringWithRange(match.rangeAtIndex(2))
let seperator2 = (text as NSString).substringWithRange(match.rangeAtIndex(3))