View pod_stats.rb
#!/usr/bin/env ruby | |
require 'json' | |
require 'yaml' | |
require 'open-uri' | |
# [Array<String>] List of iOS/macOS apps | |
app_dirs = ['WordPress-iOS', 'woocommerce-ios', 'simplenote-ios', 'simplenote-macos', 'autoproxxy'] | |
specs_cache = File.join(__dir__, 'pod_stats.cache') |
View git-groom
#!/bin/bash -euo pipefail | |
# | |
# Author: O.Halligon | |
# Jan 2021 | |
# | |
# Help | |
if [ "${1:-}" == "-h" -o "${1:-}" == "--help" ]; then | |
BASENAME=${0##*/} |
View RegEx.swift
// Simple wrapper around NSRegularExpression to provide a swiftier API and, ability to have matches exposing Range instead of NSRange | |
import Foundation | |
struct RegEx<Names> { | |
let regex: NSRegularExpression | |
init(pattern: String, options: NSRegularExpression.Options = []) throws { | |
self.regex = try NSRegularExpression(pattern: pattern, options: options) | |
} |
View 1. Demo.swift
//: ## Demo | |
struct User: CustomStringConvertible { | |
let name: String | |
let age: Int | |
var description: String { "\(name) (\(age))" } | |
} | |
let users = [ | |
User(name: "Bob", age: 22), |
View Demo.swift
struct Contact: Decodable, CustomStringConvertible { | |
var id: String | |
@NestedKey | |
var firstname: String | |
@NestedKey | |
var lastname: String | |
@NestedKey | |
var address: String | |
enum CodingKeys: String, NestableCodingKey { |
View CustomMatcher.swift
struct CustomMatcher<Value> { | |
let closure: (Value) -> Bool | |
static func ~= (caseValue: CustomMatcher<Value>, switchValue: Value) -> Bool { | |
caseValue.closure(switchValue) | |
} | |
static func ~= (caseValue: Value, switchValue: CustomMatcher<Value>) -> Bool { | |
switchValue.closure(caseValue) | |
} | |
} |
View CustomCodable+PropertyWrapper.swift
import Foundation | |
protocol TransformerType { | |
associatedtype BaseType | |
associatedtype TypeForCoding: Codable | |
static var encodeTransform: (BaseType) throws -> TypeForCoding { get } | |
static var decodeTransform: (TypeForCoding) throws -> BaseType { get } | |
} | |
@propertyWrapper |
View RegEx.swift
// Simple wrapper around NSRegularExpression to provide a swiftier API and, ability to have matches exposing Range instead of NSRange | |
import Foundation | |
struct RegEx { | |
let regex: NSRegularExpression | |
init(pattern: String, options: NSRegularExpression.Options = []) throws { | |
self.regex = try NSRegularExpression(pattern: pattern, options: options) | |
} |
View Clamped+PropertyWrapper.swift
// Xcode 11b1 | |
@propertyDelegate | |
struct Clamped<Value: Comparable> { | |
private var storage: Value | |
private var clamp: (Value) -> Value | |
init(min: Value, max: Value, initialValue: Value) { | |
let clampingFunction = { ($0...$0).clamped(to: min...max).lowerBound } | |
self.storage = clampingFunction(initialValue) |
View Enum-Values-v1.swift
enum Demo { | |
case simple | |
case oneValue(Int) | |
case twoValues(String, Double) | |
case threeValues(one: Int, two: Float, [Int]) | |
} | |
//: # Direct exposition in the enum | |
//: ## Sourcery Template |
NewerOlder