Skip to content

Instantly share code, notes, and snippets.

View b3ll's full-sized avatar
💭
no u

Adam Bell b3ll

💭
no u
View GitHub Profile
@b3ll
b3ll / titlecased-commit-msg.sh
Created September 22, 2023 16:19
Reformat a git commit's title by running it through titlecase
#!/bin/bash
INPUT_FILE=$1
START_LINE=`head -n1 $INPUT_FILE`
FIXED_TITLE=`echo $START_LINE | titlecase`
sed -i '' "1s/$START_LINE/$FIXED_TITLE/" $INPUT_FILE
// Why does this work?
Menu {
Button {
print("applied")
} label: {
Text("Apply to All")
}
Button(role: .destructive) {
import UIKit
protocol DataSource<CellType>: AnyObject {
associatedtype CellType
func createCellFor(index: Int, reusing cell: CellType?) -> CellType
}
class ContainerView<CellType> where CellType: UIView {
@b3ll
b3ll / CornerRadii.swift
Created December 4, 2022 21:57
Switchable Corner Shapes in SwiftUI
public struct AlbumArtView: View {
var useContainerRelativeShape: Bool = false
public var body: some View {
// Option 1
overlayView(for: 2.0)
// Option 2
roundedCornerShape
@b3ll
b3ll / Raid Dad Localizable.strings
Last active October 11, 2021 18:31
Raid Dad Localizable Strings
"CHOOSE_FIRETEAM_MEMBERS" = "Choose fireteam members from the drawer below to get started";
"SEARCH_GUARDIANS" = "Search guardians…";
"LOG_IN" = "Log In";
"LOG_OUT" = "Log Out";
"SWITCH_ACCOUNT" = "Switch Account";
"LOG_OUT_QUESTION" = "Are you sure you want to log out?";
"CANCEL" = "Cancel";
"PLATFORM" = "Platform";
"CLAN" = "Clan";
"ENTER_CLAN" = "Enter Clan";
@propertyWrapper
public final class LayoutInvalidating<Value> where Value: Equatable {
public static subscript<EnclosingSelf>(
_enclosingInstance observed: EnclosingSelf,
wrapped wrappedKeyPath: ReferenceWritableKeyPath<EnclosingSelf, Value>,
storage storageKeyPath: ReferenceWritableKeyPath<EnclosingSelf, LayoutInvalidating>
) -> Value where EnclosingSelf: UIView {
get {
return observed[keyPath: storageKeyPath].stored
@b3ll
b3ll / simrecord.fish
Last active February 6, 2022 15:02
Record iOS Simulator Fish Function
function simrecord
if count $argv > /dev/null
set save_dir $argv
else
set save_dir ~/Downloads
end
pushd $save_dir
xcrun simctl io booted recordVideo --mask black --codec "h264" SimulatorRecording-(date +%F)-(date +%H.%M.%S).mov
popd
@b3ll
b3ll / FP.swift
Created July 25, 2020 04:37
Floating Point Stuff
public protocol ScalableValue: ExpressibleByFloatLiteral {
func scaled(by: Double) -> Self
}
public extension ScalableValue where Self: FloatingPoint {
func scaled(by constant: Double) -> Self {
return self * constant
import Foundation
protocol UnpackedProtocol {
associatedtype ObjectType
associatedtype PointType
var points: [PointType] { get set }
}
//: A Cocoa based Playground to present user interface
import AppKit
import PlaygroundSupport
let nibFile = NSNib.Name("MyView")
var topLevelObjects : NSArray?
Bundle.main.loadNibNamed(nibFile, owner:nil, topLevelObjects: &topLevelObjects)
let views = (topLevelObjects as! Array<Any>).filter { $0 is NSView }