Skip to content

Instantly share code, notes, and snippets.

@allisonpaigemcentire
allisonpaigemcentire / make_accessible.py
Last active May 3, 2025 12:33
SwiftUI Accessibility Refactor Script
# make_accessible.py
import os
import sys
import re
from openai import OpenAI
INJECTION_PATTERNS = [
r"ignore.*instructions", r"disregard.*above", r"assistant.*role", r"user.*role",
r"only respond with", r"do not follow", r"system:.*", r"@role", r"::"
]
@joethephish
joethephish / PromptWindowController.swift
Last active June 13, 2025 22:17
Substage's flippy out command bar
import AppKit
import SwiftUI
class PromptWindowController: NSWindowController, NSWindowDelegate {
// Essential properties
private var promptWindowContext: PromptWindowContext
private let finderContext: FinderContext
init() {
import SwiftUI
/// `PartialForEach` is used to show a partial number of items, and a view builder to toggle the expansion.
public struct PartialForEach<Data: RandomAccessCollection, ID: Hashable, ItemView: View, ExpandView: View> {
public enum ExpandPlacement {
case first, last
}
/// This type defines a lazy map from `Data.indices` to `(index, (value, id))` tuple.
/// The `index` is required for bindable `ForEach` initializer.
@ole
ole / swift-has-feature.sh
Last active June 21, 2025 10:37
swift-list-features: List Swift compiler upcoming and experimental feature flags. · swift-has-feature: Check if a given compiler knows a specific feature flag, and whether it's an upcoming or experimental flag.
#!/bin/zsh
# Test if the Swift compiler knows about a particular language feature.
#
# Usage:
#
# swift-has-feature [--swift SWIFT_PATH] [--language-version LANGUAGE_VERSION] FEATURE
#
# The feature should be an upcoming or experimental language feature,
# such as `"StrictConcurrency"` or `"ExistentialAny"`.
@IanKeen
IanKeen / Example_Complex.swift
Last active September 10, 2024 11:53
PropertyWrapper: @transaction binding for SwiftUI to make changes to data supporting commit/rollback
struct User: Equatable {
var firstName: String
var lastName: String
}
@main
struct MyApp: App {
@State var value = User(firstName: "", lastName: "")
@State var showEdit = false
@sharplet
sharplet / KeychainItem.swift
Created April 25, 2020 23:57
A lightweight keychain wrapper for querying the keychain databse
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// 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
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@IsaacXen
IsaacXen / README.md
Last active July 1, 2025 10:24
(Almost) Every WWDC videos download links for aria2c.
// Copyright (c) 2019–20 Adam Sharp and thoughtbot, inc.
//
// 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
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@davedelong
davedelong / NSLocale.m
Last active October 15, 2022 08:02
Locales
/*
======================================================
THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY.
I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE.
IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU.
@laynemoseley
laynemoseley / deploy.sh
Last active October 1, 2019 19:16
Zork deploy script
#!/bin/bash
echo "You enter a dark dungeon. A sign in front of you says: Choose wisely or you'll probably die."
read -p 'staging or production: ' ENV
if [ $ENV != "staging" ] && [ $ENV != "production" ]
then
echo "You go into the wrong hallway, a skeleton comes out and decapitates you. The End."
exit 1
fi