Skip to content

Instantly share code, notes, and snippets.

View akbashev's full-sized avatar
🐢
Slowly learning stuff

Jaleel Akbashev akbashev

🐢
Slowly learning stuff
View GitHub Profile
@akbashev
akbashev / VirtualActors.swift
Last active October 25, 2023 12:21
Some naive virtual actors implementation for Swift Distributed Actors
import Distributed
import DistributedCluster
typealias DefaultDistributedActorSystem = ClusterSystem
/// Naive implementation of Virtual Actors
///
/// **Don't overuse it**: this pattern should be used on purpose, e.g. when you have number of dynamic *transparent* actors with some id.
/// If you have limited, already defined set of actors—just create and reference them in a seperate node.
///
@akbashev
akbashev / Playground.hs
Last active October 20, 2022 11:39
Playground
module Main where
combine :: Int -> Int -> Int
combine a b = a + b
increase = combine 1
decrease = combine (-1)
data Optional a =
@akbashev
akbashev / Promised.swift
Last active August 29, 2022 18:50 — forked from rjchatfield/Promised.swift
Promised values in Swift Concurrency
/// Wrapper around a lazily resolved using checked continuation.
///
/// Usage:
///
/// ```
/// let promiseA = Promised<String>()
/// async let a1 = promiseA.value
/// promiseA.resolve(with: "AAA")
/// let a2 = try await promiseA.value
/// print(try await a1, a2)
@akbashev
akbashev / FunctionalDataStructures.swift
Created April 24, 2022 21:19
Experimenting with functional data structures
enum Tree<A> {
indirect case node(A, left: Tree<A>, right: Tree<A>)
case empty
}
extension Tree {
static func singleton(_ a: A) -> Tree {
return .node(a, left: .empty, right: .empty)
}
}
@akbashev
akbashev / IOandAsyncTest.swift
Last active April 24, 2022 21:07
Experimenting with Swift async await and wrapping it into IO and Async structures.
import Foundation
import UIKit // needed for Task in Playgrounds 🤷‍♂️🤔
public protocol Functor {
associatedtype A
associatedtype B: Functor = Self
func map<C>(_ f: @escaping (A) -> C) -> B where B.A == C
}
protocol Monad: Functor {
@akbashev
akbashev / displaysizes.txt
Last active March 1, 2021 08:52 — forked from marcedwards/displaysizes.txt
iPhone, iPad, and Apple Watch display sizes
### Points and display type
PPI is points per inch below, not pixels per inch. Not all models are listed, just the first model with a new display size. Diamond, RGB Stripe and Pentile RGB refer to the subpixel patterns.
iPhone 1 = 320×480 at 163ppi sRGB IPS LCD RGB Stripe
iPhone 4 = 320×480 at 163ppi sRGB IPS LCD RGB Stripe
iPhone 5 = 320×568 at 163ppi sRGB IPS LCD RGB Stripe
iPhone 6 = 375×667 at 163ppi sRGB IPS LCD RGB Stripe
iPhone 6 Plus = 414×736 at 153.5ppi sRGB IPS LCD RGB Stripe
iPhone 7 = 375×667 at 163ppi P3 IPS LCD RGB Stripe