I hereby claim:
- I am jpmhouston on github.
- I am jpmhouston (https://keybase.io/jpmhouston) on keybase.
- I have a public key ASAvAMoNWlz7u41pqqpci8CXG1_2hzd_M7xuRrQDerLJuwo
To claim this, I am signing this object:
// Insired by https://forums.swift.org/t/iscontained-in-array-extension-of-equatable/20223/28 | |
// Exercise for the reader: define operators ∈ and ∉ | |
// | |
// Created primarily for excluded, which I wanted to use in an | |
// expression like: | |
// `let foos = things.compactMap({ $0.foo?.excluded(from: [a,b,c]) })` | |
// I then went on to generalize to included(in:) and all the | |
// variations below, and found an even better way to write similar | |
// expressions: `let x = y.excluding([u,v,w])` | |
// |
// | |
// BareTextView.swift | |
// Cleepp | |
// | |
// Created by Pierre Houston on 2024-03-27. | |
// Copyright © 2024 Bananameter Labs. All rights reserved. | |
// | |
// Based on snippits from https://stackoverflow.com/a/56854375/592739 | |
// and https://stackoverflow.com/a/14469815/592739 | |
// and https://gist.github.com/mminer/597c1b2c40adcf3c319f7feeade62ed4 |
// | |
// HyperlinkTextField.swift | |
// Cleepp | |
// | |
// Created by Pierre Houston on 2024-03-28. | |
// Copyright © 2024 Bananameter Labs. All rights reserved. | |
// | |
// Based on snippits and tips from | |
// https://stackoverflow.com/a/56854375/592739 | |
// https://gist.github.com/mminer/597c1b2c40adcf3c319f7feeade62ed4 |
# Useful to refer to finder selections from the fish shell command line, like: | |
# $ file (selection) | |
# /Users/me/Documents/Files/Throwback.dvtcolortheme: XML 1.0 document text, ASCII text | |
# /Users/me/Documents/Files/Test.sparsebundle/: directory | |
# | |
function selection | |
osascript -e "tell application \"Finder\" to set s to the selection as alias list" -e "repeat with f in s" -e "set contents of f to POSIX path of f" -e "end repeat" -e "set AppleScript's text item delimiters to linefeed" -e "s as string" | |
end |
extension Result { | |
func failed(else handleSuccess: ((Success) -> Void)? = nil) -> Failure? { | |
switch self { | |
case .success(let value): | |
handleSuccess?(value) | |
return nil | |
case .failure(let error): | |
return error | |
} | |
} |
I hereby claim:
To claim this, I am signing this object:
extension Data { | |
struct HexEncodingOptions: OptionSet { | |
let rawValue: Int | |
static let uppercase = HexEncodingOptions(rawValue: 0) | |
static let lowercase = HexEncodingOptions(rawValue: 1 << 0) | |
} | |
func hexEncodedString(options: HexEncodingOptions = []) -> String { | |
let hexDigits = Array((options.contains(.lowercase) ? "0123456789abcdef" : "0123456789ABCDEF").utf16) | |
var dump: [unichar] = [] | |
var ascii: [unichar] = [] |
// | |
// NSManagedObject+Clone.h | |
// TResActivityLog | |
// | |
// Created by Pierre Houston on 2016-05-30. | |
// Copyright © 2016 Resilience software. All rights reserved. | |
// | |
// When no context provided, uses [NSManagedObjectContext MR_defaultContext]. | |
// Note, I was going to add unique prefix "jph_" to these category method names, | |
// but currently I've left those out. |
public extension TimeInterval { | |
public var dispatchInterval: DispatchTimeInterval { | |
let microseconds = Int64(self * TimeInterval(USEC_PER_SECS)) // perhaps use nanoseconds, though would more often be > Int.max | |
return microseconds < Int.max ? DispatchTimeInterval.microseconds(Int(microseconds)) : DispatchTimeInterval.seconds(Int(self)) | |
} | |
} |
// TODO: link here to SO post that inspired this | |
// ^ that source worked fine when setting placeholderColor sometime after | |
// placeholder or attributedPlaceholder, but not the other way around. | |
// this is an attempt to fix this, it might work. | |
class ColorPHTextField : UITextField { | |
@IBInspectable var placeholderColor: UIColor? { | |
didSet { | |
applyPlaceholderColor() |