Skip to content

Instantly share code, notes, and snippets.

View kaqu's full-sized avatar

Kacper kaqu

View GitHub Profile
@kaqu
kaqu / Specification-to-Code.md
Created June 5, 2025 13:22
Specification-to-Code Framework (S2C)

Specification-to-Code Framework (S2C)

Purpose and Objectives

The Specification-to-Code Framework (S2C) creates software specifications in Markdown format containing complete implementation guidance. All specifications must be written in Markdown using English language exclusively to ensure consistent formatting, version control compatibility, universal readability across development tools and platforms, and clear communication across international development teams.

The objective is eliminating the gap between requirements and code by ensuring specifications include sufficient technical detail for developers to implement software without additional requirements gathering or clarification requests. S2C establishes standards for implementation-complete specifications that enable developers to immediately understand what code to write, which technologies to use, implement all interfaces without guesswork, handle all error conditions, and write validating tests.

Implementation-Ready Criteria

@kaqu
kaqu / Parameters.swift
Created February 26, 2020 21:04
Swift dynamic parameters
internal protocol AnyParameter {
var name: String { get }
var optional: Bool { get }
var type: Any.Type { get }
}
public struct Parameter<Value>: AnyParameter {
public var name: String
public var optional: Bool
public var `default`: Value?
@kaqu
kaqu / AtomicFlag.swift
Created September 28, 2019 19:43
Futures
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS)
import libkern // check on Linux
public enum AtomicFlag {
public typealias Pointer = UnsafeMutablePointer<atomic_flag>
@inline(__always)
public static func make() -> Pointer {
let pointer = Pointer.allocate(capacity: 1)
@kaqu
kaqu / ByteParser.swift
Created September 14, 2019 18:01
BytesParser based on https://pointfree.co parser video series
import Foundation
public extension Data {
func parse<T>(with parser: Parser<T>) -> T? {
self.withUnsafeBytes { (bufferPointer) -> T? in
var slice: Slice<Array<Byte>> = .init(bufferPointer)
return parser.parse(&slice)
}
}
}
@kaqu
kaqu / EntityDecoder.swift
Created September 7, 2019 17:47
CodeData - CoreData from Code
import Foundation
import CoreData
// TODO: FIXME: minimal, naive implementation
internal final class EntityDecoder<EntityType: StorageEntity>: Decoder {
private let managed: NSManagedObject
public var codingPath: [CodingKey] = []
@kaqu
kaqu / Executor.swift
Last active May 25, 2019 21:09
Futures 3.0
import Foundation
public protocol Executor {
func execute(_ task: @escaping () -> Void)
}
extension DispatchQueue: Executor {
@inlinable public func execute(_ task: @escaping () -> Void) {
async(execute: task)
@kaqu
kaqu / Actor.swift
Last active May 15, 2019 20:06
Swift Actor
////////////////////////////////////////////////////////
//// From futura: https://github.com/miquido/futura ////
////////////////////////////////////////////////////////
import Darwin
import libkern
public enum Mutex {
public typealias Pointer = UnsafeMutablePointer<pthread_mutex_t>
@kaqu
kaqu / FluidLayout.swift
Created May 11, 2019 22:06
FluidLayout
public protocol FluidView: UIView {
var id: UUID { get }
}
public protocol FluidViewLayoutModel {
var id: UUID { get }
var prefferedSize: CGSize? { get }
var prefferedInsets: UIEdgeInsets? { get }
var minimumSize: CGSize? { get }
var maximumSize: CGSize? { get }
func prepareView() -> FluidView
@kaqu
kaqu / Coconut.swift
Created May 11, 2019 10:55
CoconutUIKit
import UIKit
// MARK: Corner rounding
public enum CornerRoundings {
case none
case all(CGFloat)
case topLeft(CGFloat)
@kaqu
kaqu / Hex.swift
Created April 17, 2019 18:02
Hex Swift
// from: https://github.com/raywenderlich/swift-algorithm-club
public struct Heap<T> {
/** The array that stores the heap's nodes. */
var nodes = [T]()
/**
* Determines how to compare two nodes in the heap.
* Use '>' for a max-heap or '<' for a min-heap,