Skip to content

Instantly share code, notes, and snippets.

Avatar

Helge Heß helje5

View GitHub Profile
@helje5
helje5 / main.swift
Last active Jan 12, 2022
Using async/await concurrency on iOS 14 and before
View main.swift
// Created by Helge Heß 2021-06-17
import Foundation
// They use obfuscated names to hide it from us!
import JavaScriptCore
/// Setup our async/await runtime.
let runtime = JSContext()!
@helje5
helje5 / servedocc.swift
Last active Jan 5, 2022
Small Swift Script to serve `.doccarchive`s to the browser
View servedocc.swift
#!/usr/bin/swift sh
import MacroExpress // @Macro-swift
// MARK: - Parse Commandline Arguments & Usage
func usage() {
let tool = path.basename(process.argv.first ?? "servedocc")
print(
"""
@helje5
helje5 / Tows.swift
Last active Dec 28, 2021
An 82-liner SwiftUI script similar to CodeCows 🐮
View Tows.swift
import SwiftUI
import cows // @AlwaysRightInstitute
struct ContentView: View {
@State var searchString = ""
@State var matches = allCows
@State var selectedCow : String?
let font = Font(NSFont
@helje5
helje5 / SparkleCommands.swift
Last active Jul 26, 2021
How to hookup Sparkle in SwiftUI
View SparkleCommands.swift
//
// SparkleCommands.swift
// Past for iChat
//
// Created by Helge Heß on 08.04.21.
//
import SwiftUI
#if SPARKLE && canImport(Sparkle)
@helje5
helje5 / KeyPathMirror.swift
Created Jan 28, 2018
Swift Key Path Memory Layout Decoding
View KeyPathMirror.swift
import Foundation
// https://github.com/apple/swift/blob/master/docs/ABI/KeyPaths.md
// https://bugs.swift.org/browse/SR-5689
public struct KeyPathMirror<T: AnyKeyPath> : CustomStringConvertible {
public let subject : T
@helje5
helje5 / SVGWebView.swift
Created May 10, 2021
A SwiftUI View to display SVGs using WKWebView
View SVGWebView.swift
// Created by Helge Heß on 06.04.21.
// Also available as a package: https://github.com/ZeeZide/SVGWebView
import SwiftUI
import WebKit
/**
* Display an SVG using a `WKWebView`.
*
* Used by [SVG Shaper for SwiftUI](https://zeezide.de/en/products/svgshaper/)
@helje5
helje5 / CliptIt.swift
Created Jul 17, 2020
Demo for SwiftBlocksUI: Clip Slack messages using a Message Action
View CliptIt.swift
#!/usr/bin/swift sh
import SwiftBlocksUI // @SwiftBlocksUI ~> 0.8.0
dotenv.config()
struct ClipItForm: Blocks {
@State(\.messageText) var messageText
@State var importance = "medium"
@helje5
helje5 / SlashCows.swift
Created Jul 17, 2020
ASCII Cows for Slack, as a Slash Command - a SwiftBlocksUI demo
View SlashCows.swift
#!/usr/bin/swift sh
import cows // @AlwaysRightInstitute ~> 1.0.0
import SwiftBlocksUI // @SwiftBlocksUI ~> 0.8.0
dotenv.config()
struct CowMessage: Blocks {
@Environment(\.messageText) private var query
@helje5
helje5 / ZzViewHolder.swift
Last active Sep 13, 2019
NSDictionaryOfVariableBindings for Swift
View ZzViewHolder.swift
/**
* NSDictionaryOfVariableBindings for Swift
*
* In Objective-C you could use macros to quickly get a Dictionary of views,
* keyed on their names in the sourcecode. Like so:
*
* UILabel *label = [UILabel autolayoutView];
* NSDictionary *views = NSDictionaryOfVariableBindings(label);
*
* Which you could then use in, for example, VFL:
@helje5
helje5 / AppDelegate.swift
Last active Mar 22, 2019
Dock gets stuck on drag
View AppDelegate.swift
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window : NSWindow!
@IBOutlet weak var tableView : NSTableView!
func applicationDidFinishLaunching(_ aNotification: Notification) {