This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func longZip<S1: Sequence, S2: Sequence>(_ seq1: S1, _ seq2: S2) -> AnyIterator<(S1.Iterator.Element?, S2.Iterator.Element?)?> { | |
var (iter1, iter2) = (seq1.makeIterator(), seq2.makeIterator()) | |
return AnyIterator { () -> (S1.Iterator.Element?, S2.Iterator.Element?)? in | |
let (l, r) = (iter1.next(), iter2.next()) | |
switch (l, r) { | |
case (nil, nil): | |
return nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let digits = Array("1234567890".characters) | |
let identChars = Array("_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".characters) | |
let opChars = Array("<>+-=*/!%^&?|".characters) | |
struct Lexer: IteratorProtocol { | |
var scanner: BufferedScanner<Character> | |
init(_ string: String) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Curly.swift | |
// Curly | |
// | |
// Created by Adolfo Rodriguez on 2014-11-04. | |
// Copyright (c) 2014 Wircho. All rights reserved. | |
// | |
// NOTE(vdka): Taken from https://github.com/wircho/Curly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Date { | |
static var now: Date { return Date() } | |
} | |
func curtime() -> Double { | |
var tv = timeval() | |
gettimeofday(&tv, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hehehe | |
struct { | |
var : String | |
} | |
let : = (: "Invisble characters should not be acceptable identifiers.") | |
print() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vapor | |
import Darwin.C | |
func curTime() -> Double { | |
var tv = timeval() | |
gettimeofday(&tv, nil) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Darwin | |
struct UUID { | |
var storage: (UInt64, UInt64) | |
var bytes: UnsafeBufferPointer<UInt8> { | |
var `self` = self | |
let pointer = withUnsafeMutablePointer(to: &self) { pointer in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hashMemory<T>(of input: T) -> Int { | |
// make a copy beacuse we *might* mutate input when getting an UnsafePointer to the value. Dammit. That sucks. | |
// *should* be no cost provided the compiler sees we are not actually mutating the value in there. But it sure | |
// would be nice to have a way to tell the compiler I would like to just *look* at the memory. | |
var input = input | |
return withUnsafePointer(to: &input) { pointer in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "name": "bug", "color": "#e34424" }, | |
{ "name": "feature", "color": "#6cc644" }, | |
{ "name": "ready", "color": "#EAC04B" }, | |
{ "name": "in progress", "color": "#56d1f3" }, | |
{ "name": "on hold", "color": "#7d59c3" }, | |
{ "name": "regression", "color": "#fe9a00" }, | |
{ "name": "discussion", "color": "#7d59c3" }, | |
{ "name": "weight: 1", "color": "#ededed" }, | |
{ "name": "weight: 2", "color": "#ededed" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct Key { | |
private let rawValue: UInt8 | |
private init(_ rawValue: UInt8) { | |
self.rawValue = rawValue | |
} | |
public let somePublicCase = Key(0) | |
private let somePrivateCase = Key(1) | |
private let anotherPrivateCase = Key(2) |