Skip to content

Instantly share code, notes, and snippets.

View werediver's full-sized avatar
💭
🦀

Raman Fedaseyeu werediver

💭
🦀
View GitHub Profile
@werediver
werediver / WiFiSsid.swift
Created July 14, 2016 12:47
Get the connected Wi-Fi network SSID on iOS (in 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 / ViewTransition.swift
Last active July 8, 2020 10:19
View Transition mechanism for MVVM pattern (Swift, iOS)
import UIKit
// MARK: - Specification
protocol ViewType {
associatedtype ViewModel: ViewModelType
var viewModel: ViewModel { get }
@werediver
werediver / PipeOperators.swift
Created July 15, 2016 12:51
F# forward pipe operator in 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 / StylingConcept2.swift
Last active October 19, 2016 16:14
A concept of UI styling for iOS
//: Playground - noun: a place where people can play
import UIKit
// MARK: - Skeleton
protocol StyleProtocol {
func apply(to some: Any)
}
@werediver
werediver / GenerateCurry.swift
Last active January 24, 2017 08:59
Generating `curry` function in Swift 2.2
// Swift 2.2
enum AccessLevel {
case Default
case Private
case Internal
case Public
var asPrefix: String {
switch self {
@werediver
werediver / CurryBench.swift
Created January 25, 2017 09:20
Type inference impact on Swift 2.2 code compile time.
// 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)

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:

enum AntGrammar: Grammar {
enum Failure: Error {
case invalidCodon
}
static func generate(_ rule: GenotypeIterating) throws -> String {
return try prog(rule)
}
@werediver
werediver / resample_rlen.vex
Created October 10, 2020 15:22
Houdini VEX code to resample a (two point) curve into segments of random length (with restrictions)
// Resample into segments of random length
// Run over primitives
float seed = chf("seed");
float seg_len_min = chi("seg_len_min");
float seg_len_max = chi("seg_len_max");
float seg_padding = chf("padding");
if (seg_len_min <= 0 || seg_len_max < seg_len_min || seg_padding < 0) {
error("Make sure 0 < seg_len_min <= seg_len_max and 0 <= seg_padding");
@werediver
werediver / default.yaml
Last active February 18, 2022 13:33
Lima/Podman configuration allowing connections to ports 80, 443 through non-loopback interfaces
# Based on https://github.com/lima-vm/lima/blob/943c90b13e38be32777b8f25be17c2491bb1421f/examples/podman.yaml
#
# Allows connections to ports 80, 443 through non-loopback interfaces.
# Example to use Podman instead of containerd & nerdctl
# $ limactl start ./podman.yaml
# $ limactl shell podman podman run -it -v $HOME:$HOME --rm docker.io/library/alpine
# To run `podman` on the host (assumes podman-remote is installed):
# $ export CONTAINER_HOST=$(limactl list podman --format 'unix://{{.Dir}}/sock/podman.sock')