Skip to content

Instantly share code, notes, and snippets.

View gabrieloc's full-sized avatar
🅱️

Gabriel O'Flaherty-Chan gabrieloc

🅱️
View GitHub Profile
@gabrieloc
gabrieloc / CGVector.swift
Last active January 25, 2021 16:58
Coerce core graphics types into generic vectors
import UIKit
protocol Vector {
associatedtype Primitive: FloatingPoint
var components: [Primitive] { get }
init(components: [Primitive])
}
extension CGPoint: Vector {
var components: [CGFloat] { [x, y] }
@gabrieloc
gabrieloc / guy.swift
Created October 2, 2020 21:20
Terminal game
import Foundation
import simd
enum Input: String, CaseIterable {
case up = "▴"
case right = "▸"
case down = "▾"
case left = "◂"
var bytes: [UInt8] {
@gabrieloc
gabrieloc / Bash.swift
Last active December 29, 2023 00:26
Utilities for writing command line code in Swift
#!/usr/bin/env swift
import Foundation
struct TerminationStatus: Error {
let code: Int32
}
func run(_ command: Command) throws {
print(command.rendered.joined(separator: " "))
@gabrieloc
gabrieloc / NibLoadable.swift
Last active August 29, 2019 15:26
Conveniences for type-safe instant ion from nibs
//
// NibLoadable.swift
// Reusable
//
// Copyright (c) <2018>, Gabriel O'Flaherty-Chan
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright
@gabrieloc
gabrieloc / Reusable.swift
Last active August 28, 2019 19:48
Typed UITableViewCell/UICollectionViewCell registration and dequeuing
//
// Reusable.swift
// Reusable
//
// Copyright (c) <2018>, Gabriel O'Flaherty-Chan
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright