Skip to content

Instantly share code, notes, and snippets.

View werediver's full-sized avatar
💭
🦀

Raman Fedaseyeu werediver

💭
🦀
View GitHub Profile
@werediver
werediver / main.dart
Last active November 1, 2022 14:00
Container types and the `map()` function in Dart
void main() {
print(f(true).map((value) => value + 1));
print(f(false).map((value) => value + 1));
print([1, 2, 3].map((value) => "x ${value + 1}"));
print([].map((value) => value + 1));
}
// Methods like
// map, flatMap / expand, filter / where, firstWhere, reduce, fold
void main() async {
await variant1();
variant2();
print("xxx");
}
Future<void> variant1() async {
final result = await y();
// async gap
print("y: $result");
@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')
@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");
enum AntGrammar: Grammar {
enum Failure: Error {
case invalidCodon
}
static func generate(_ rule: GenotypeIterating) throws -> String {
return try prog(rule)
}

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 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)
@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 / 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 / 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)
}