Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
PENDING=2
NO_STATUS=3
return_txt = ""
loop do
return_txt = `hub ci-status -v`
break unless [PENDING, NO_STATUS].include?($?.exitstatus)
sleep(1)
package com.stripe.danielhfrank
import com.twitter.algebird.Monoid
import scala.annotation.tailrec
import scala.collection.mutable
class OverTimeMonoid[V: Monoid] extends Monoid[ Seq[(Long, V)]] {
override def zero: Seq[(Long, V)] = Seq.empty
@danielhfrank
danielhfrank / pydantic.py
Created December 1, 2020 00:15
Pydantic with Numpy
from typing import Generic, TypeVar
import numpy as np
from pydantic.fields import ModelField
JSON_ENCODERS = {
np.ndarray: lambda arr: arr.tolist()
}
DType = TypeVar('DType')
@danielhfrank
danielhfrank / trio_fib.py
Created December 1, 2020 20:53
Implementations of concurrent fibonacci numbers in vanilla asyncio and trio
import asyncio
import trio
import sys
async def fib(n: int) -> int:
if n < 0:
raise ValueError('boom')
elif n in {0, 1}: