Skip to content

Instantly share code, notes, and snippets.

View jakehawken's full-sized avatar
🆒

Jake Hawken jakehawken

🆒
View GitHub Profile
@jakehawken
jakehawken / SuperviewsAndSubviews.swift
Last active June 26, 2023 15:14
Some handy methods for view debugging in iOS.
extension UIView {
func firstSuperview<T: UIView>(ofType type: T.Type) -> T? {
guard let superview = superview else {
return nil
}
if let superViewAsT = superview as? T {
return superViewAsT
}
return superview.firstSuperview(ofType: type)
@jakehawken
jakehawken / PrettyPrintable.swift
Last active June 23, 2023 15:53
Some handy tools for making things into more human-readable strings. Helpful for debugging!
import Foundation
protocol PrettyPrintable {
func prettyPrinted() -> String
func prettyPrintToConsole()
}
extension PrettyPrintable {
func prettyPrintToConsole() {
let pretty = prettyPrinted()
@jakehawken
jakehawken / ScreenStateHandler.swift
Last active June 30, 2023 16:08
ScreenStateHandler -- The glue to connect your views and presenters.
import Foundation
/*
I love the presenter pattern, but I hate connecting the presenter to the view using
delegation. Since protocol conformance can't be private in Swift, delegation always
leaks encapsulation because the conforming type has now announced to the world that
it has methods and properties that are irrelevant to everyone but the type doing the
delegating. ScreenStateHandler is a skinny little intermediary object that handles a
delegation-style 1:1 relationship between a presenter and a view but can be composed
into (rather than bolted onto) the types in question.

Jake's Sandwich Sourdough Bread

I created this recipe with three main goals in mind, and I'm delighted to say that I've achieved all three.

  1. Mild flavor: This bread is not very sour, despite its natural leavening/fermentation, and thus works well for a wide variety of purposes (my kids and I love using it for PB&J). This is largely due (I believe) to the introduction of fats and sugar early on. The fats coat the flour, slowing the lactic acid-producing bacteria, and making up for that by feeding the yeast some sugar up front.
  2. Fast turnaround time: Unlike other sourdough recipes, you can make your dough and bake it all in the same day (provided you feed your starter the night before).
  3. Functional sandwich bread: Unlike traditional, crusty sourdough, this loaf is tender, soft, and flexible. It's a super versatile sandwich bread, and maintains its freshness/moisture longer than most home-baked bread.

And on top of this, it's super easy and doesn't take much time where you're actually invo

Jake's Chili

It's not a particularly complicated recipe, but instead it's about the ingredients (e.g. solid rather than ground beef), and taking the time to do little things that will give huge flavor rewards (e.g. roasting your own chiles and convection browning the sauce). The majority of the cook time is fairly hands-off, and the early investment pays dividends in the simmer.

Remember: Chili is a stew, not a soup. It's ok if it's thick.

Prep time: ~30-40 minutes

Cook time: 3-6 hours (depending on preference and dedication)

Ingredients

@jakehawken
jakehawken / TestablePlaygrounds.swift
Last active June 23, 2023 15:53
Testable Swift Playgrounds! Just drop this in the Sources folder of a Swift Playground, and you'll be able to write XCTest-style tests right there in your code!
/*
Ever wanted to write unit tests in a Swift Playground? … No? Oh.
I’m really the only person? Well ok, then never mind.
If you change your mind though, you can drop this file directly
into the Sources folder and be able to write XCTest-style code
directly in your playground. A proper git repo with a README
file and code examples is on the way.
*/
import Foundation