Skip to content

Instantly share code, notes, and snippets.

View andrey-zakharov's full-sized avatar

Andrey Zakharov andrey-zakharov

View GitHub Profile
@vishna
vishna / suspend_var.kt
Last active January 23, 2022 15:49
Suspened Variable in Kotlin - works kinda lateinit but if your variable is late, it will make you wait rather than crash
class SuspendedVariable<T>(var scope: CoroutineScope? = GlobalScope) {
private var actor = scope?.actor<Op<T>> {
var value : T? = null
val deferrals = mutableListOf<CompletableDeferred<T>>()
try {
for (message in channel) {
when (message) {
is Op.Set -> {
anonymous
anonymous / hover.ks
Created November 21, 2016 20:11
clearscreen.
sas on.
stage.
lock distance to ship:altitude + ship:body:radius.
lock weight to ship:mass * ship:body:mu / distance / distance.
lock twr to ship:availablethrust / weight.
lock atwr to twr / max(0.00001, cos(vang(ship:facing:vector,ship:up:vector))).
lock vspeed to 5 - alt:radar.