This file contains 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
// https://www.youtube.com/watch?v=oHVHkkah3MY&t=979s | |
struct DFA<State: Hashable, Symbol: Hashable> { | |
init(delta: [DFA<State, Symbol>.Pair : State], initialState: State, finalStates: Set<State>) { | |
self.delta = delta | |
self.initialState = initialState | |
self.finalStates = finalStates | |
} | |
struct Pair: Hashable { |
This file contains 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
extension Set { | |
private func addCombination(prevCombo: [Element], pivotList: [Element]) -> [([Element], [Element])] { | |
var pivotList = pivotList | |
return (0..<pivotList.count) | |
.map { _ -> ([Element], [Element]) in | |
(prevCombo + [pivotList.remove(at: 0)], pivotList) | |
} | |
} | |
func combinations(m: Int) -> [[Element]] { |
This file contains 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 | |
import XCTest | |
struct Fixture<T: Decodable & Equatable> { | |
let value : T | |
init(url: URL) throws { | |
let actualData = try Data(contentsOf: url) | |
self.value = try JSONDecoder().decode(T.self, from: actualData) | |
} | |
func assert(_ t:T) { |
This file contains 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
private func abbreviation(of sentence:String) -> String{ | |
return sentence | |
.components(separatedBy: CharacterSet.whitespacesAndNewlines) | |
.flatMap{$0.first} | |
.map{String($0)} | |
.joined(separator: "") | |
} |
This file contains 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
# Creat a directory called all-repos, and clone all projects into it. | |
mkdir all-repos | |
cd all-repos | |
git clone THEPROJECT1-GIT-ADDRESS project1 | |
git clone THEPROJECT2-GIT-ADDRESS project2 | |
. | |
. | |
. | |
This file contains 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
protocol Pageable{ | |
var loading:Bool{get} | |
var paginator:Paginator{get set} | |
func fetchWith(paginator: Paginator) | |
} | |
struct Paginator { | |
var page = 0 |
This file contains 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 getURLSchema() -> String?{ | |
guard let schemas = Bundle.main.object(forInfoDictionaryKey: "CFBundleURLTypes") as? [[String:Any]], | |
let schema = schemas.first, | |
let urlschema = schema["CFBundleURLName"] as? String | |
else {return nil} | |
return urlschema | |
} |
This file contains 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 getRandomElements<T:Equatable>(array:[T], count:Int) -> [T] { | |
var randomPicks: [T] = [] | |
var randomIndex = Int.random(array.count) | |
var randomPick = array[randomIndex] | |
while randomPicks.count != count{ | |
This file contains 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
### Keybase proof | |
I hereby claim: | |
* I am erkekin on github. | |
* I am erkekin (https://keybase.io/erkekin) on keybase. | |
* I have a public key whose fingerprint is 7060 F1FD EA9E 6BA7 F657 AA4C 959B 55E6 B416 AC08 | |
To claim this, I am signing this object: |
This file contains 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
✔ |