Skip to content

Instantly share code, notes, and snippets.

Raman Fedaseyeu werediver

Block or report user

Report or block werediver

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View AntGrammar.swift
enum AntGrammar: Grammar {
enum Failure: Error {
case invalidCodon
}
static func generate(_ rule: GenotypeIterating) throws -> String {
return try prog(rule)
}
View keybase.md

Keybase proof

I hereby claim:

  • I am werediver on github.
  • I am werediver (https://keybase.io/werediver) on keybase.
  • I have a public key ASDVl2sxFUxEvo7PVGoMPO5s152IjIIoS-f3PkJ284jUJAo

To claim this, I am signing this object:

@werediver
werediver / CurryBench.swift
Created Jan 25, 2017
Type inference impact on Swift 2.2 code compile time.
View CurryBench.swift
// CurryLight.swift
func curry<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, U>(f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25) -> U) -> (T1) -> (T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U {
return { (x1: T1) -> (T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U in { (x2: T2) -> (T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10) -> (T11) -> (T12) -> (T13) -> (T14) -> (T15) -> (T16) -> (T17) -> (T18) -> (T19) -> (T20) -> (T21) -> (T22) -> (T23) -> (T24) -> (T25) -> U in { (x3: T3) -> (T4) -> (T5) -> (T6) -> (T7) -> (T8) -> (T9) -> (T10)
@werediver
werediver / GenerateCurry.swift
Last active Jan 24, 2017
Generating `curry` function in Swift 2.2
View GenerateCurry.swift
// Swift 2.2
enum AccessLevel {
case Default
case Private
case Internal
case Public
var asPrefix: String {
switch self {
@werediver
werediver / StylingConcept2.swift
Last active Oct 19, 2016
A concept of UI styling for iOS
View StylingConcept2.swift
//: Playground - noun: a place where people can play
import UIKit
// MARK: - Skeleton
protocol StyleProtocol {
func apply(to some: Any)
}
@werediver
werediver / PipeOperators.swift
Created Jul 15, 2016
F# forward pipe operator in Swift
View PipeOperators.swift
infix operator |> { precedence 95 associativity left }
infix operator <| { precedence 95 associativity right }
infix operator ?> { precedence 95 associativity left }
/// Forward pipe operator.
func |> <T, U>(arg: T, @noescape f: T -> U) -> U {
return f(arg)
}
@werediver
werediver / ViewTransition.swift
Last active Feb 22, 2019
View Transition mechanism for MVVM pattern (Swift, iOS)
View ViewTransition.swift
import UIKit
// MARK: - Specification
protocol ViewType {
associatedtype ViewModel: ViewModelType
var viewModel: ViewModel { get }
@werediver
werediver / WiFiSsid.swift
Created Jul 14, 2016
Get the connected Wi-Fi network SSID on iOS (in Swift).
View WiFiSsid.swift
import Foundation
import SystemConfiguration.CaptiveNetwork
func getWiFiSsid() -> String? {
var ssid: String?
if let interfaces = CNCopySupportedInterfaces() as NSArray? {
for interface in interfaces {
if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? {
ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String
break
@werediver
werediver / FatalError+Ext.swift
Last active Jul 3, 2017
Better `fatalError()`.
View FatalError+Ext.swift
import Foundation
func fatalError<T>(@autoclosure message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> T {
fatalError(message(), file: file, line: line)
}
// Demo
protocol ResultType {
@werediver
werediver / concurrency.swift
Last active Jul 3, 2017
Limiting concurrent tasks.
View concurrency.swift
import Foundation
func dispatch_async_batch(tasks: [() -> ()], limit: Int, completion: (() -> ())?) {
if tasks.count > 0 || completion != nil {
let q = dispatch_queue_create("dispatch_async_batch", DISPATCH_QUEUE_CONCURRENT);
let sema = dispatch_semaphore_create(limit);
dispatch_async(q, {
for task in tasks {
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
You can’t perform that action at this time.