Skip to content

Instantly share code, notes, and snippets.

View vpsteinmann's full-sized avatar
👨‍💻

Vincent Steinmann vpsteinmann

👨‍💻
View GitHub Profile
@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)
}
// Type-safe State Machine with Phantom Type May 2022 @AtarayoSD
import Foundation
protocol State {}
// Transitions
protocol TransferableToB {}
protocol TransferableToC {}
protocol TransferableToD {}
@merlinmann
merlinmann / usage I dislike.md
Last active February 28, 2024 21:24
An Epicenter of Wordsmithing…for the Enterprise.

Usage I Dislike


An Epicenter of Wordsmithing…for the Enterprise.


Words: Ugly, Dumb, or Overpriced

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 / quotes.md
Last active June 28, 2025 06:28
Quotes to get right. #runx

Quotations to Get Right

@merlinmann
merlinmann / wisdom.md
Last active April 28, 2025 20:57
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.

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) }
import UIKit
class RootViewController: UIViewController {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let text = "Cute cat"
let image = UIImage(named: "cat.jpg")!
// Note: you can't wrap the text and image into a single "TextImage" object and selectively return both or one as UIActivityItemSource doesn't like holding arrays
@troyfontaine
troyfontaine / 1. Windows.md
Last active June 5, 2024 18:30 — forked from igorkulman/CompareTools.plist
Visual Studio Code as a merge tool for Git Tower.

Enable Visual Studio Code for Merge/Diff on Windows

From PowerShell or CMD:

cd C:\Program Files (x86)\fournova\Tower\CompareTools
code .

Edit VisualStudioCode.json and replace line 10 which is:

@kamui545
kamui545 / dock.sh
Created October 24, 2019 03:37
Customize macOS dock via command line
#!/usr/bin/env bash
source "./dock_functions.sh"
declare -a apps=(
'/System/Applications/Utilities/Terminal.app'
'/System/Applications/Music.app'
'/Applications/Google Chrome.app'
'/Applications/PhpStorm.app'
'/Applications/Visual Studio Code.app'