Skip to content

Instantly share code, notes, and snippets.

View steipete's full-sized avatar

Peter Steinberger steipete

View GitHub Profile
@steipete
steipete / windsurf-auto-continue.js
Last active May 14, 2025 12:37
Windsurf Auto Continue press button JS. Windsurf Menu Help -> Toggle Developer Tools -> Paste into Console.
// Windsurf Auto Press Continue v13.2 (with added logging)
(() => {
const SCRIPT_NAME = 'Windsurf Auto Press Continue v13.2 (logged)'; // Updated name for clarity
let intervalId = null, lastClick = 0;
// --- Config ---
const BTN_SELECTORS = 'span[class*="bg-ide-button-secondary-background"]';
const BTN_TEXT_STARTS_WITH = 'continue';
const SIDEBAR_SELECTOR = null;
const COOLDOWN_MS = 3000;
// Ultra-simple Cursor Auto Resume Script - Copy & paste into browser console
(function() {
console.log('Cursor Auto Resume: Running');
// Track last click time to avoid multiple clicks
let lastClickTime = 0;
// Main function that looks for and clicks the resume link
function clickResumeLink() {
// Prevent clicking too frequently (3 second cooldown)
@steipete
steipete / karabiner.json
Created May 4, 2025 13:06 — forked from Happyholic1203/karabiner.json
Karabiner settings for UHK Simulation
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@steipete
steipete / zshrc
Last active May 3, 2025 12:12
git ≥ 2.23‑style “nuke‑and‑pave”. Gets you out of everything, even worktrees!
fresh() {
# 0) escape half‑finished merges / rebases (no‑ops if nothing to abort)
git merge --abort 2>/dev/null || git rebase --abort 2>/dev/null || :
git fetch --prune --no-auto-maintenance --quiet origin && # 1 refs up‑to‑date fast  [oai_citation:0‡git-scm.com](https://git-scm.com/docs/git-fetch)
git switch --discard-changes --recurse-submodules -C main origin/main && # 2 hard‑reset + checkout incl. submodules 
git clean -ffdx && # 3 wipe every untracked/ignored artefact 
git for-each-ref --format='%(refname:short)' --merged main refs/heads \
| grep -v '^main$' | xargs -r git branch -D # 4 trash merged locals in one hit
clear
@steipete
steipete / Sparkle.swift
Last active May 5, 2021 15:18
Sparkle + SwiftUI
lass AppUpdateHandler: ObservableObject {
#if SPARKLE
private let delegateHandler = SparkleDelegateHandler()
let sparkle: SPUStandardUpdaterController
init() {
// Setup sparkle updater
// https://docs.microsoft.com/en-us/appcenter/distribution/sparkleupdates
// https://rambo.codes/posts/2021-01-08-distributing-mac-apps-outside-the-app-store
sparkle = SPUStandardUpdaterController(updaterDelegate: delegateHandler, userDriverDelegate: delegateHandler)
@steipete
steipete / TouchBarSwiftUIHack.swift
Created April 19, 2021 15:17
Your SwiftUI app crashes in *** Assertion failure in -[NSTouchBarLayout setLeadingWidgetWidth:], NSTouchBarLayout.m:78 ? Use this hack to work around the problem!
import Foundation
import InterposeKit
import OSLog
/// Hack tow work around Assertion failure in -[NSTouchBarLayout setLeadingWidgetWidth:], NSTouchBarLayout.m:78
/// This sometimes happens when macOS restores a window.
/// This even runs if there is no OS-level touch bar.
class MacOSWorkarounds {
static let logger = Logger(category: "MacOSWorkarounds")
@steipete
steipete / SwiftUIThingsToKnow.swift
Last active February 5, 2023 15:33
10 Things I Wish I Knew When Starting SwiftUI (See also https://gist.github.com/steipete/6c430d08bd57b066fada7628d3b8b719)
- In almost all cases where you type `@ObservedObject`, you really want `@StateObject`.
If you need to support iOS 13, use `@State` on parent and pass value into child with `@ObservedObject` to simulate `@StateObject`.
Pass arguments to that model in `onAppear`. Example: https://github.com/ra1028/SwiftUI-Hooks/blob/main/Sources/Hooks/HookScope.swift#L39-L41
```
.onAppear {
model.onAppear(userTag: userTag)
}
.onDisappear {
model.onDisappear()
@steipete
steipete / SwiftUIPerformance.swift
Created April 16, 2021 12:57
SwiftUI Performance Notes (Adding as I learn)
- Optimize Hashable and Equatable. e.g. if you have an id, just use that - instead of having the system use reflection and diff all properties:
public func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
public static func == (lhs: UserBox, rhs: UserBox) -> Bool {
return lhs.id == rhs.id
}
@steipete
steipete / RandomColor.swift
Created April 6, 2021 17:20
Random Color for SwiftUI
extension Color {
/// Return a random color
static var random: Color {
return Color(
red: .random(in: 0...1),
green: .random(in: 0...1),
blue: .random(in: 0...1)
)
}
}
@steipete
steipete / View.swift
Created April 4, 2021 13:43
Accept dropping a file onto SwiftUI (both iOS and macOS)
.onDrop(of: [.fileURL], isTargeted: nil) { providers in
if let loadableProvider = providers.first(where: { $0.canLoadObject(ofClass: URL.self) }) {
_ = loadableProvider.loadObject(ofClass: URL.self) { fileURL, _ in
if let fileURL = fileURL, fileURL.pathExtension.lowercased() == "zip" {
self.logger.info("Dropped \(fileURL.path)")
DispatchQueue.main.async {
importer.open(zipArchiveURL: fileURL)
}
}
}