Skip to content

Instantly share code, notes, and snippets.

View m1entus's full-sized avatar

Michał Zaborowski m1entus

View GitHub Profile
@zaxbux
zaxbux / Dock.md
Last active November 5, 2025 19:30
macOS 26

Dock

Default Apps

Name URL Section Bundle ID
Apps file:///System/Applications/Apps.app/ persistentApps com.apple.apps.launcher
Safari file:///System/Volumes/Preboot/Cryptexes/App/System/Applications/Safari.app/ persistentApps com.apple.Safari
Messages file:///System/Applications/Messages.app/ persistentApps com.apple.MobileSMS
Mail file:///System/Applications/Mail.app/ persistentApps com.apple.mail
Maps file:///System/Applications/Maps.app/
@simonbs
simonbs / SwiftUIHostingConfiguration.md
Last active September 6, 2025 09:18
In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This project shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to the UIContentConfiguration protocol.

SwiftUIHostingConfiguration

In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This gist shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to UIContentConfiguration.

Starting from iOS 16, we can use SwiftUI views in an instance of UICollectionView or UITableViewCell like this:

cell.contentConfiguration = UIHostingConfiguration {
    ExampleCellContentView(color: Color(item.color), text: item.text)
}
@karpathy
karpathy / add_to_zshrc.sh
Created August 25, 2024 20:43
Git Commit Message AI
# -----------------------------------------------------------------------------
# AI-powered Git Commit Function
# Copy paste this gist into your ~/.bashrc or ~/.zshrc to gain the `gcm` command. It:
# 1) gets the current staged changed diff
# 2) sends them to an LLM to write the git commit message
# 3) allows you to easily accept, edit, regenerate, cancel
# But - just read and edit the code however you like
# the `llm` CLI util is awesome, can get it here: https://llm.datasette.io/en/stable/
gcm() {
@wakinchan
wakinchan / generate-target-dependencies.sh
Last active July 13, 2025 14:04
Generate Target Dependencies for Package.swift
#!/usr/bin/env sh
# usage: sh ./generate-target-dependencies.sh | dot -Tsvg -o target-graph.svg
packages=`swift package describe --type json`
targets=`echo $packages | jq '.targets'`
target_names=`echo $targets | jq -r '.[] | .name'`
body=""
template=`cat <<EOF
digraph DependenciesGraph {
@krzyzanowskim
krzyzanowskim / AsyncWaiter.swift
Last active June 25, 2022 12:25
Synchronously (well) wait for async Task value update https://twitter.com/krzyzanowskim/status/1523233140914876416
/// Wait for async operation to return value and call callback with the value
/// This class is intended to workaround/simplify async/await + actors isolation
/// https://twitter.com/krzyzanowskim/status/1523233140914876416
private class AsyncWaiter<T> {
var didReceiveValue: Bool = false
let value: (T) -> Void
let operation: () async throws -> T
init(_ value: @escaping (T) -> Void, operation: @escaping () async throws -> T) {
self.value = value
#!/bin/sh
#
# Disable Siri Suggestions on Simulators and SwiftUI Previews to
# avoid Spotlight heating up your MacBook by keeping 4 cores busy
# at 100%.
#
# See https://developer.apple.com/forums/thread/683277
#
import Combine
import Foundation
@available(iOS 13.0, macOS 10.15, tvOS 13, watchOS 6, *)
public struct ObjectDidChangePublisher<ObjectWillChangePublisher: Publisher>: Publisher {
private let upstream: ObjectWillChangePublisher
public typealias Output = ObjectWillChangePublisher.Output
public typealias Failure = ObjectWillChangePublisher.Failure
fileprivate init(upstream: ObjectWillChangePublisher) {
import SwiftUI
import UIKit
struct ContentView: View {
var body: some View {
NoSepratorList {
Text("Message 1")
Text("Message 1")
Text("Message 1")
Text("Message 1")
@wotjd
wotjd / debug_preview.swift
Created May 14, 2020 04:26
resolve sizeThatFits not working on Xcode Preview using UIView
import SwiftUI
// https://medium.com/@lyeskinnikitaalexandrovich/mastering-xcode-previews-with-snapkit-uikit-aa82a146059a
enum DebugPreviewLayout {
case fitWidth(CGFloat)
case fitHeight(CGFloat)
case `default`
}
final class DebugPreviewLayoutView: UIView {
@groue
groue / CancelBag.swift
Last active April 5, 2024 19:12
CancelBag
import Combine
import Foundation
/// A thread-safe store for cancellables which addresses usability pain points
/// with stock Combine apis.
///
/// ## Thread-safe storage of cancellables
///
/// let cancelBag = CancelBag()
/// cancellable.store(in: cancelBag)