Skip to content

Instantly share code, notes, and snippets.

View nehayward's full-sized avatar

Nick Hayward nehayward

View GitHub Profile
@kylebshr
kylebshr / ConditionalDefaultEntity.swift
Last active March 19, 2025 15:43
How to conditionally build widget configuration parameters based on UserDefaults or other conditions
//
// ConditionalDefaultEntity.swift
// Mercury
//
// Created by Kyle Bashour on 2/10/25.
// Copyright © 2025 Kyle Bashour. All rights reserved.
//
import AppIntents
//
// VolumePopupView.swift
//
// Created by Alex Rosenberg on 1/24/24.
//
import SwiftUI
import AVFoundation
import MediaPlayer
@insidegui
insidegui / devicectl.sh
Created October 19, 2023 21:58
Helper functions for using devicectl to kill processes on connected iOS devices
# Add to your zsh profile
function devicepid() {
if [ -z "$1" ]; then
echo "Usage: devicepid <device-name> <search>"
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard"
return 1
fi
if [ -z "$2" ]; then
@christianselig
christianselig / widget-center-async-await.swift
Created August 10, 2023 23:39
Adds async await support to WidgetCenter configuration fetch
import WidgetKit
extension WidgetCenter {
func currentConfigurations() async throws -> [WidgetInfo] {
try await withCheckedThrowingContinuation { continuation in
getCurrentConfigurations { result in
continuation.resume(with: result)
}
}
}
@nicklockwood
nicklockwood / OSKit.swift
Created January 28, 2023 11:32
A lightweight approach to writing cross-platform code in SwiftUI without a lot of conditional compilation blocks
import SwiftUI
enum OSDocumentError: Error {
case unknownFileFormat
}
#if canImport(UIKit)
import UIKit
@lukaskubanek
lukaskubanek / Bundle+TestFlight.swift
Last active November 3, 2024 17:20
A code snippet for detecting the TestFlight environment for a macOS app at runtime
/// MIT License
///
/// Copyright (c) 2021 Lukas Kubanek, Structured Path GmbH
///
/// 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:
@simonbs
simonbs / Unleashed.js
Created October 13, 2021 06:36
Scriptable widget that counts down to Apple's Unleashed event on October 18th
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: apple-alt;
const TITLE = ""
const DATE = "2021-10-18T17:00:00Z"
const BG_IMG_URL = "https://i.ibb.co/YQ09XTW/background.png"
const TITLE_IMG_URL = "https://i.ibb.co/qYH3Y9w/text.png"
const TITLE_IMG_SIZE = new Size(155, 25)
const LINK = "https://www.youtube.com/watch?v=exM1uajp--A"
@fayazara
fayazara / scriptable-widget-gh-stars.js
Last active October 19, 2021 00:07
Scriptable widget for displaying a Github repo stars
// Created by Fayaz https://twitter.com/fayazara
let widget = await createWidget();
if (config.runsInWidget) {
Script.setWidget(widget);
} else {
widget.presentSmall();
}
Script.complete();
@ABridoux
ABridoux / WindowPosition.swift
Last active March 1, 2025 11:01
Logic to easily set a NSWindow's origin horizontally and vertically in a screen (AppKit and SwiftUI)
// Free to use
// Written by Alexis Bridoux - https://github.com/ABridoux
import AppKit
#if canImport(SwiftUI)
import SwiftUI
#endif
// MARK: Model
@insidegui
insidegui / statusbarfix.sh
Created March 16, 2021 23:04
Alias called "statusbarfix" which will update the status bar on any iOS Simulator that's currently running to look better for marketing images
alias statusbarfix='xcrun simctl status_bar booted override --time 9:41 --cellularMode active --cellularBars 4 --batteryState charging --operatorName ""'