Skip to content

Instantly share code, notes, and snippets.

View fl034's full-sized avatar
💬

Frank Lehmann fl034

💬
View GitHub Profile
@fl034
fl034 / fix-tahoe-audio.sh
Last active April 6, 2026 00:53
macOS Tahoe audio workaround script for external output devices. Uses switchaudio-osx to quickly switch to the internal output and back to the current external device, restoring audio when it gets stuck. Does nothing if the current output is already internal
#!/usr/bin/env bash
set -euo pipefail
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:${PATH:-}"
switch_audio_bin="${SWITCH_AUDIO_BIN:-}"
internal_prefix="${INTERNAL_AUDIO_PREFIX:-Mac}"
if [[ -z "$switch_audio_bin" ]]; then
@fl034
fl034 / doubleTapZoom
Last active March 4, 2025 10:32 — forked from gunantosteven/doubleTapZoom
Double Tap Zoom to The Tap Location Swift 5 iOS 13
@objc func handleDoubleTap(_ recognizer: UITapGestureRecognizer) {
let scale = min(scrollView.zoomScale * 2, scrollView.maximumZoomScale)
if scrollView.zoomScale == scrollView.minimumZoomScale { // zoom in
let point = recognizer.location(in: imageView)
let scrollSize = scrollView.frame.size
let zoomScale = scrollView.maximumZoomScale * 0.7
let size = CGSize(width: scrollSize.width / zoomScale,
height: scrollSize.height / zoomScale)
import SwiftUI
enum Tab: String, Identifiable, Hashable, CaseIterable {
case green, yellow, red
var id: String { rawValue }
}
struct ContentView: View {
// This needs to be set to the first tab.
import SwiftUI
enum Tab: String, Identifiable, Hashable, CaseIterable {
case green, yellow, red
var id: String { rawValue }
}
struct ContentView: View {
// Starting with last element. Changing this to .green doesn't work,
// From this answer https://stackoverflow.com/a/39425959/4846592
extension Character {
/// A simple emoji is one scalar and presented to the user as an Emoji
var isSimpleEmoji: Bool {
guard let firstScalar = unicodeScalars.first else { return false }
return firstScalar.properties.isEmoji && firstScalar.value > 0x238C
}
/// Checks if the scalars will be merged into an emoji
@fl034
fl034 / UIImage+Trim.swift
Created January 23, 2021 22:06
UIImage+Trim.swift
//
// UIImage+Trim.swift
//
//
// Created by Frank Lehmann on 19.01.21.
//
import UIKit
import AlamofireImage
@fl034
fl034 / OpenAPI Generator Kotlin Array at Root Level Bug.yml
Created October 27, 2020 12:49
OpenAPI Generator Kotlin Array at Root Level Bug
openapi: 3.0.0
info:
title: API
description: Testing arrays at root level in kotlin
version: 1.0.0
paths:
/myObjectsAtRootLevel:
get:
tags:
@fl034
fl034 / Localization.swift
Last active June 9, 2020 13:03
XIB + Storyboard Localization
//
// Localization.swift
//
//
// Created by Frank Lehmann on 03.07.19.
// Based on: https://medium.com/@mario.negro.martin/easy-xib-and-storyboard-localization-b2794c69c9db
//
import UIKit
@fl034
fl034 / Array+Duplicates.swift
Created December 18, 2019 00:15
Removing duplicates in arrays with keypath
extension Array {
func removingDuplicates<T: Equatable>(uniqueProperty: KeyPath<Element, T>) -> Self {
var newArray = Self()
for item in self {
if !newArray.contains(where: { $0[keyPath: uniqueProperty] == item[keyPath: uniqueProperty] }) {
newArray.append(item)
}
}
return newArray
}
@fl034
fl034 / martyn-ticket-import-link-structure.md
Last active October 19, 2019 18:27
Martyn ticket-import link structure