Skip to content

Instantly share code, notes, and snippets.

View tehbilly's full-sized avatar
🏠
Working from home

William McGann tehbilly

🏠
Working from home
View GitHub Profile
@tehbilly
tehbilly / state-machine.ts
Created February 18, 2021 22:20
Simple TypeScript state machine
export type Supplier<T> = () => T;
export type StateSupplier = string | Supplier<string>;
export interface State {
name?: string;
on: {
[name: string]: StateSupplier;
};
onEnter?: (prev: State) => void;
onLeave?: (next: State) => void;
@tehbilly
tehbilly / ServiceB.java
Created June 13, 2018 18:32
For gpdriver17 on reddit
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.LoadingCache;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class ServiceB {
private static LoadingCache<String, Integer> thumbsUpCache = Caffeine.newBuilder()
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(key -> loadFromCoolGuys(key));
// Could also use full CacheLoader<K, V>, or method reference, whatever
### Witchwood Battlecry Wock
# Class: Shaman
# Format: Standard
# Year of the Raven
#
# 1x (0) Zap!
# 2x (1) Blazing Invocation
# 2x (1) Glacial Shard
# 1x (2) Acidic Swamp Ooze
# 1x (2) Baleful Banker
@tehbilly
tehbilly / ManuallyCancelledJob.kt
Last active April 20, 2018 17:44
Interrupting Job in Kotlin
fun main(args: Array<String>) {
val job = launch(CommonPool) {
for (i in 1..10) {
println("Job starting worky work: $i")
Thread.sleep(100)
if (!isActive) return@launch
println("Job finishing worky work: $i")
}
}

Keybase proof

I hereby claim:

  • I am tehbilly on github.
  • I am tehbilly (https://keybase.io/tehbilly) on keybase.
  • I have a public key ASAgPL_G9KuR9on4J5aaST_idTxbTF80n53z6kDuRVflqgo

To claim this, I am signing this object: