Skip to content

Instantly share code, notes, and snippets.

// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@IanColdwater
IanColdwater / twittermute.txt
Last active June 15, 2025 16:53
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@steventroughtonsmith
steventroughtonsmith / Info.plist
Created October 27, 2019 17:02
[Catalyst] Registering for & responding to AppleScript events in a Mac Catalyst app
<key>NSAppleScriptEnabled</key>
<true/>
<key>OSAScriptingDefinition</key>
<string>ScriptableTasks.sdef</string>
@CypherPoet
CypherPoet / KeyboardFollower.swift
Last active October 29, 2019 08:25
Keyboard follower implemented as an ObservableObject using Swift Combine Publishers
import Combine
import Foundation
import UIKit
final class KeyboardFollower: ObservableObject {
private var subscriptions = Set<AnyCancellable>()
@Published var keyboardHeight: CGFloat = 0.0
@bvaughn
bvaughn / trimming–demo-videos.md
Last active November 10, 2020 13:53
Handy tip for trimming demo videos

Handy tip for trimming demo videos

Thought I'd document the process I used for trimming down my React conf demo videos in case it might be useful to someone else in the future.

Let's say I have a 40 second video named original-video.mp4, and I want to only keep the following sections (in seconds): 1-8, 10-11, 20-33

I could create 3 chunks using ffmpeg like so:

ffmpeg -i original-video.mp4 -ss 1 -t 7 piece-a.mp4 -ss 10 -t 1 piece-b.mp4 -ss 20 -t 33 piece-c.mp4
declare function bind<T>(component: React.ComponentType<T & InjectedProps>): React.ComponentType<T>;
declare class A<B> extends React.Component<PubProps<B> & InjectedProps> { }
const APrimeComponent = bind(A);
// type inferred to: React.ComponentType<PubProps<unknown>>
declare function AFunc<B>(props: PubProps<B> & InjectedProps): React.ReactElement;
const AFuncPrimeComponent = bind(AFunc);
// type inferred to: React.ComponentType<PubProps<unknown>>
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 27, 2025 14:38
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://bsky.app/profile/tholanda.com
*
* (the twitter account is now deleted, please, do not try to reach me there)
* https://twitter.com/tholanda
*
* MIT license
*/
@janicduplessis
janicduplessis / androidx-class-mapping.csv
Last active September 9, 2024 12:24
Update react-native libraries under node_modules to androidx
Support Library class Android X class
android.support.v8.renderscript.Allocation android.renderscript.Allocation
android.support.v8.renderscript.Element android.renderscript.Element
android.support.v8.renderscript.RenderScript android.renderscript.RenderScript
android.support.v8.renderscript.ScriptIntrinsicBlur android.renderscript.ScriptIntrinsicBlur
android.support.transition.AnimatorUtils androidx.transition.AnimatorUtils
android.support.transition.ArcMotion androidx.transition.ArcMotion
android.support.transition.AutoTransition androidx.transition.AutoTransition
android.support.transition.ChangeBounds androidx.transition.ChangeBounds
android.support.transition.ChangeClipBounds androidx.transition.ChangeClipBounds
@zephraph
zephraph / clean_node_modules.sh
Last active December 14, 2024 08:04
A shell script to clean up all node_modules in projects that haven't been touched in a couple weeks.
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14 # If a project hasn't been touched in this long its node_modules will be deleted
SEARCH_PATH="./Git" # Update this to the path where your code is stored
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find $SEARCH_PATH -name "node_modules" -type d -prune)
@bvaughn
bvaughn / LICENSE.md
Last active April 27, 2025 22:07
Advanced example for manually managing subscriptions in an async-safe way using hooks

The MIT License (MIT)

Copyright © <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell