Skip to content

Instantly share code, notes, and snippets.

View bennokress's full-sized avatar
👨‍💻
while !isSuccessful { tryAgain() }

Benno Kress bennokress

👨‍💻
while !isSuccessful { tryAgain() }
View GitHub Profile
@bennokress
bennokress / CompareTools.plist
Created February 26, 2024 16:02
Application Information Plist to get JuxtaCode Support in Tower
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>com.naiveapps.juxtacode</string>
<key>ApplicationName</key>
<string>JuxtaCode</string>
@bennokress
bennokress / juxtacode.sh
Last active February 27, 2024 20:14
Integration Script to get JuxtaCode Support in Tower
#!/bin/sh
# CHECK IF JUXTA IS INSTALLED AS A COMMAND LINE TOOL #
# Set CMD to where the juxta is in the PATH of the environment.
CMD=`which juxta`
# If that didn't produce any results we search for juxta at the default path.
if [ -z "$CMD" ] ; then
if [ -e '/usr/local/bin/juxta' ] ; then
@bennokress
bennokress / custom-cozy-kagi-theme.css
Last active September 14, 2023 17:39
Custom Cozy Theme for Kagi Search (based onthe version by James Lyons). Be sure to set the default Kagi themes to "Calm Blue" and "Moon Dark" for the themes to apply properly.
/* Remove Outline around selected items in the advanced search options */
.filter-item ._0_selected {
outline: 0px;
outline-offset: 0px;
}
/* Increase bottom below search result URLs */
.__sri-url-box {
padding-bottom: 4px;
}
@bennokress
bennokress / .swiftformat
Last active July 24, 2022 15:09
My standard code formatting definitions using SwiftFormat by nicklockwood.
# File options
--exclude Pods
# Rules
## Enabled
--enable andOperator
--enable anyObjectProtocol
--enable assertionFailures
//
// ContentView.swift
// Component Designer
//
// Created by Benno on 15.03.22.
//
import SwiftUI
struct ContentView: View {
@bennokress
bennokress / PreviewDevice.swift
Created February 12, 2021 22:04
Add convenience to your SwiftUI Previews by using `.previewDevice(.iPhone12)` instead of initializing by String.
import SwiftUI
extension PreviewDevice: Identifiable {
public var id: String { rawValue } // Support for each loops over an array of Preview Devices
static var iPhoneSE1: PreviewDevice { .init(.iPhoneSE1) }
static var iPhone7: PreviewDevice { .init(.iPhone7) }
static var iPhone7Plus: PreviewDevice { .init(.iPhone7Plus) }
static var iPhone8: PreviewDevice { .init(.iPhone8) }
import Foundation
extension Array {
func shifted(by shiftAmount: Int) -> Array<Element> {
// 1
guard self.count > 0, (shiftAmount % self.count) != 0 else { return self }
// 2
@bennokress
bennokress / UIFontExtensions.swift
Created April 22, 2020 09:59
Extensions for Swift's UIFont Type.
import UIKit
extension UIFont {
/// Prints all fonts that can be used with `UIFont(name:, size:)` to the console.
static func printAllAvailableFontNames() {
for familyName in UIFont.familyNames {
print("\n\(familyName)")
for fontName in UIFont.fontNames(forFamilyName: familyName) {
print("\t- \(fontName)")
@bennokress
bennokress / Equatable.swift
Last active January 12, 2018 19:59
Extensions for Swift's Equatable Protocol
extension Equatable {
// Usage: 3.isAny(of: 0, 1, 2, 3) // true
func isAny(of candidates: Self...) -> Bool {
return candidates.contains(self)
}
}
@bennokress
bennokress / ArrayExtensions.swift
Last active June 24, 2017 17:34
Extensions for Swift's Array type
extension Array {
// Usage: [1,2,3,4].shifted(by: 2) --> [3,4,1,2] or "hello".shifted(by: -1) --> "elloh"
func shifted(by shiftAmount: Int) -> Array {
guard self.count > 0, (shiftAmount % self.count) != 0 else { return self }
let moduloShiftAmount = shiftAmount % self.count
let effectiveShiftAmount = moduloShiftAmount < 0 ? moduloShiftAmount + self.count : moduloShiftAmount
let shift: (Int) -> Int = { return $0 + effectiveShiftAmount >= self.count ? $0 + effectiveShiftAmount - self.count : $0 + effectiveShiftAmount }
return self.enumerated().sorted(by: { shift($0.offset) < shift($1.offset) }).map { $0.element }
}