Skip to content

Instantly share code, notes, and snippets.

@mikezs
mikezs / generate_package.sh
Created January 12, 2021 09:38
Create a Package.swift from the Package.resolved in an Xcode Project
#!/bin/sh
cat MyProject.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved | python3 package_from_spm_xcodeproj.py > Package.swift && swiftlint --strict ./Package.swift
@mikezs
mikezs / totp.swift
Created April 23, 2024 14:56
totp.swift
import CryptoKit
import Foundation
extension Data {
init?(base32Encoded string: String) {
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
var bytes: [UInt8] = []
var accum = 0
var bits = 0 // # of valid bits in `accum`