Skip to content

Instantly share code, notes, and snippets.

Firebase Analytics

Event

Example

{
	"name": "CheckoutComplete",
	"parameters": {
extension SymmetricKey {
init(string keyString: String, size: SymmetricKeySize = .bits256) throws {
guard var keyData = keyString.data(using: .utf8) else {
print("Could not create base64 encoded Data from String.")
throw CryptoKitError.incorrectParameterSize
}
let keySizeBytes = size.bitCount / 8
keyData = keyData.subdata(in: 0..<keySizeBytes)
@ptrkstr
ptrkstr / Camelizer.swift
Created October 13, 2021 02:56 — forked from reitzig/Camelizer.swift
Convert Swift strings to camel case
fileprivate let badChars = CharacterSet.alphanumerics.inverted
extension String {
var uppercasingFirst: String {
return prefix(1).uppercased() + dropFirst()
}
var lowercasingFirst: String {
return prefix(1).lowercased() + dropFirst()
}
@ptrkstr
ptrkstr / Apple_mobile_device_types.txt
Created October 7, 2021 15:18 — forked from adamawolf/Apple_mobile_device_types.txt
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@ptrkstr
ptrkstr / FormDemoApp.swift
Created September 30, 2021 16:21 — forked from marcprux/FormDemoApp.swift
Example of aligning labels in SwiftUI.Form on macOS
//
// FormDemoApp.swift
// FormDemo
//
// Created by Marc Prud'hommeaux
//
import SwiftUI
@main
@ptrkstr
ptrkstr / NSRegularExpression+Split.swift
Created September 19, 2021 08:51 — forked from hcrub/NSRegularExpression+Split.swift
Regular Expression "split" Implementation written for Swift 3.0+.
// NSRegularExpression+Split.swift
//
// Verbatim ObjC->Swift port originating from https://github.com/bendytree/Objective-C-RegEx-Categories
extension NSRegularExpression {
func split(_ str: String) -> [String] {
let range = NSRange(location: 0, length: str.characters.count)
//get locations of matches
@ptrkstr
ptrkstr / URL+Extended.swift
Created December 19, 2016 22:53
URL Extension
extension URL {
/// Converts URL to a "https" scheme
func secure() -> URL? {
guard var comps = URLComponents(url: self, resolvingAgainstBaseURL: false) else {
return nil
}
comps.scheme = "https"
@ptrkstr
ptrkstr / NSColor+Extended.swift
Last active December 19, 2016 22:54
NSColor extension
extension NSColor {
/// Creates a NSColor from "#XXXXXX"/"XXXXXX" format
convenience init(hex: String, alpha: CGFloat = 1) {
// TODO: Validate hex string is in the "#XXXXXX" or "XXXXXX" format
let scanner = Scanner(string: hex)
scanner.scanLocation = hex[hex.startIndex] == "#" ? 1 : 0
var rgb: UInt32 = 0