Skip to content

Instantly share code, notes, and snippets.

Mãtt Freèman sitepodmatt

  • Earth
Block or report user

Report or block sitepodmatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View async_promises_and_for.js
async function sleepAsync(ms) {
return new Promise((r) => setTimeout(r, ms));
}
async function run() {
const numbers = [1,2,3,4,5]
// A - COMPLETE
@sitepodmatt
sitepodmatt / codec.cs
Last active Jul 25, 2019
fsharp union codec
View codec.cs
public static class FSharpUnionCodecBuilder
{
public delegate T Decoder<T>(byte[] bytes, string subType);
public delegate byte[] Encoder<T>(T input);
public static Tuple<Decoder<T>,Encoder<T>> Build<T>(T unionType) where T : class
{
var unionCaseFields = FSharpType.GetUnionCases(typeof(T), BindingFlags.Public)
.ToDictionary(uc => $"{uc.DeclaringType.Name}:{uc.Name}",
uc => new Tuple<UnionCaseInfo, Type>(uc,
View runtimetypes.ts
interface TypeRep<T> {
_UnderlyingType: T
}
class ValidatedType<T extends { [TKey in keyof T] : TypeRep<unknown> }> {
readonly _T!: { [TKey in keyof T] : T[TKey]['_UnderlyingType'] }
constructor(t : T) { }
}
View babysteps.js
class DType<A> {
readonly _A!: { [P in keyof A] : A[P] }
constructor(t : A) {
}
}
const UserModel = new DType({ name: ""})
type Infer<C extends any> = C['_A']
View mapdiff.kt
sealed class MapDiffResult<T : Any,V : Any> {
data class Added<T : Any,V : Any>(val key : T, val v : V) : MapDiffResult<T, V>()
data class Removed<T : Any,V : Any>(val key : T, val oldValue : V) : MapDiffResult<T, V>()
data class Changed<T : Any,V : Any>(val key : T, val new : V, val old :V) : MapDiffResult<T, V>()
}
fun <K : Any,V : Any> Map<K,V>.diffMaps(to: Map<K,V>, isSame : (V, V?) -> Boolean = { v,v2 -> v == v2 }) : List<MapDiffResult<K, V>> {
val from = this
View example.kt
import io.kotlintest.specs.StringSpec
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
class RequestContextTest : StringSpec({
"playing with human context" {
try {
runBlocking {
View example.kt
import io.kotlintest.specs.StringSpec
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
class RequestContextTest : StringSpec({
"playing with human context" {
try {
runBlocking {
View 18march2017.txt
Hello,
In recent weeks, many of our customers have noticed instability, degraded performance, and increased rendering errors from imgix due to a series of ongoing issues. This by itself is unacceptable, and we have been working tirelessly to address it.
However, in the struggle to fix things, we have also failed in our duty to communicate with our customers. I have received complaints that imgix has not been transparent enough about the scope of the issues and when they will be resolved. As CEO, I take full responsibility for this. That is not the kind of company I want imgix to be. You deserve to know when there are issues that could negatively affect you. You deserve to know what we are doing to make it right.
In the spirit of transparency, I have published a blog post about the recent challenges. In this post, I document exactly what is happening, explain why it is happening, and lay out what we are doing to fix it so that it does not happen again. I invite you to read the post, and to contact me or you
@sitepodmatt
sitepodmatt / informer.js
Last active Aug 12, 2017
playing with async
View informer.js
class K8SInformer {
constructor() {
this.listeners = [];
this.queue = [];
}
addListener(listener) {
this.listeners.push(listener);
}
View App.kt
fun main(args: Array<String>) {
println("Foldwhile experiment")
val oneTo100 = 1 until 100
println(oneTo100.fold(0) { acc, v -> acc + v})
println("Stop folding when total is above 2000")
println(oneTo100.foldWhile(0, { acc, v -> acc + v }, { acc, _ -> acc < 2000 }))
You can’t perform that action at this time.