Skip to content

Instantly share code, notes, and snippets.

View vpsteinmann's full-sized avatar
👨‍💻

Vincent Steinmann vpsteinmann

👨‍💻
View GitHub Profile
extension Result {
public func `catch`(_ handler: () throws -> Success) -> Result<Success, Error> {
flatMapError { _ in
.init { try handler() }
}
}
public func `catch`(_ handler: (Failure) throws -> Success) -> Result<Success, Error> {
flatMapError { error in
.init { try handler(error) }
@merlinmann
merlinmann / wisdom.md
Last active November 14, 2025 03:16
Merlin's Wisdom Project (Draft)

Merlin's Wisdom Project

Or: “Everybody likes being given a glass of water.”

By Merlin Mann.

It's only advice for you because it had to be advice for me.

@merlinmann
merlinmann / quotes.md
Last active December 22, 2025 21:31
Quotes to get right. #runx

Quotations to Get Right

private let configKey = CodingUserInfoKey(rawValue: UUID().uuidString)!
private struct ConfigWrapper<Value> {
let value: Value
}
extension ConfigWrapper: Decodable where Value: DecodableWithConfiguration {
init(from decoder: Decoder) throws {
let config = decoder.userInfo[configKey]! as! Value.DecodingConfiguration
value = try Value(from: decoder, configuration: config)
@merlinmann
merlinmann / usage I dislike.md
Last active November 2, 2025 20:53
An Epicenter of Wordsmithing…for the Enterprise.

Usage I Dislike


An Epicenter of Wordsmithing…for the Enterprise.


Words: Ugly, Dumb, or Overpriced

// Type-safe State Machine with Phantom Type May 2022 @AtarayoSD
import Foundation
protocol State {}
// Transitions
protocol TransferableToB {}
protocol TransferableToC {}
protocol TransferableToD {}
@KrisRJack
KrisRJack / Array+Extension.swift
Last active February 22, 2025 13:41
Helpful Swift Extensions
import UIKit
extension Array where Element == NSLayoutConstraint {
/// Activates each constraint in an array of `NSLayoutConstraint`.
///
/// Example usage: `[view.heightAnchor.constraint(equalToConstant: 30), view.widthAnchor.constraint(equalToConstant: 30)].activate()`
func activate() {
NSLayoutConstraint.activate(self)
}
import UIKit
import AVFoundation
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
let tableView = UITableView(frame: .zero, style: .plain)
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(PlayerTableViewCell.self, forCellReuseIdentifier: "PlayerCell")
@kconner
kconner / macOS Internals.md
Last active December 27, 2025 05:31
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@chockenberry
chockenberry / simkill.sh
Last active December 9, 2023 14:04
A simple shell script to reset CoreSimulator
#!/bin/sh
pids=`ps axo pid,command | grep CoreSimulator | grep -v "grep CoreSimulator" | cut -c 1-5`
if [ "$1" = "go" ]; then
kill -9 $pids
elif [ "$1" = "echo" ]; then
echo $pids
else
pid_param=`echo $pids | tr -s ' ' ','`