Skip to content

Instantly share code, notes, and snippets.

@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)
}
}
}
@chockenberry
chockenberry / simkill.sh
Last active December 9, 2023 14:04
A simple shell script to reset CoreSimulator
#!/bin/sh
pids=`ps axo pid,command | grep CoreSimulator | grep -v "grep CoreSimulator" | cut -c 1-5`
if [ "$1" = "go" ]; then
kill -9 $pids
elif [ "$1" = "echo" ]; then
echo $pids
else
pid_param=`echo $pids | tr -s ' ' ','`
#!/usr/bin/env xcrun -sdk macosx swift
// Displays UI in an NSWindow which can interact with the commandline
// Usage: `echo "Bar" | ./swift-ui-commandline-tool.swift`
import Foundation
import SwiftUI
extension CommandLine {
static let input: String = { AnyIterator { readLine() }.joined() }()
@SwiftStudies
SwiftStudies / IncrementalUpdateTests.swift
Last active August 29, 2015 14:21
Incremental Update Challenge
//
// IncrementalUpdateTests.swift
//
// Copyright (c) 2015 Swift Studies. All rights reserved.
//
import Foundation
import XCTest
import Cocoa
// Only needed until we have class variables
var __SwizzleSayHello = { (who:String) -> String in
return "Hello, \(who)"
}
class Swizzle {
//Only needed until we have class variables
class var _sayHello : (String)->String { get{ return __SwizzleSayHello } set (swizzle) {__SwizzleSayHello = swizzle} }