Skip to content

Instantly share code, notes, and snippets.

View jayrhynas's full-sized avatar

Jayson Rhynas jayrhynas

View GitHub Profile
#include <vector>
#include <unordered_map>
#include <memory>
#include <stdio.h>
typedef enum : int {
TableKindSine, TableKindTriangle, TableKindSaw, TableKindSquare,
TableKindCount
} TableKind;
$ cloc --exclude-ext=json --exclude-dir=Pods,node_modules,3rd\ Party .
6695 text files.
5975 unique files.
5297 files ignored.
github.com/AlDanial/cloc v 1.84 T=3.96 s (354.3 files/s, 59697.4 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
Swift 608 22679 10023 75483
// This simple case works fine
protocol BasicValueProvider {
associatedtype Value
static var value: Value { get }
}
struct False_Basic: BasicValueProvider {
static var value: Bool { false }
}
import Foundation
protocol ValueProvider {
associatedtype Value
static var value: Value { get }
}
@propertyWrapper
struct Default<Provider: ValueProvider>: Codable, Hashable where Provider.Value: Codable & Hashable {
typealias Value = Provider.Value
import AppKit
struct Icon {}
struct Canvas {}
protocol ToolController {
var icon: Icon { get }
var name: String { get }
func apply(/*...*/)
@jayrhynas
jayrhynas / link.sh
Last active May 6, 2020 14:51
Swift & ObjC CLI Linking
import UIKit
class NavigationController: UINavigationController, UINavigationControllerDelegate {
static let enableMasking = true
static let transitionSpeed: Float = 0.1
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .clear
import Foundation
class ThreadQueue {
private var mutex = pthread_mutex_t()
private var cond = pthread_cond_t()
// these are shared variables and should only be modified within a `lock` block
private var threadId: pthread_t? = nil
private var isStopped = true
private var queue: [() -> Void] = []
@jayrhynas
jayrhynas / CustomKeyCodable.swift
Last active February 25, 2021 16:23 — forked from IanKeen/CustomKeyCodable.swift
PropertyWrapper: CustomKeyCodable allows defining the keys for decoding _per property_
protocol CustomKeyCodable: Codable {
static var keyEncodingStrategy: ([CodingKey]) -> CodingKey { get }
static var keyDecodingStrategy: ([CodingKey]) -> CodingKey { get }
init()
}
extension CustomKeyCodable {
init(from decoder: Decoder) throws {
self.init()