Skip to content

Instantly share code, notes, and snippets.

View travisbrown's full-sized avatar
In hiding

Travis Brown travisbrown

In hiding
View GitHub Profile
salcoast /
Last active November 9, 2022 05:47
Deleted tweets for MrAndyNgo
kyhwana /
Last active June 21, 2023 11:41
Block RMS support letter signers
#replace "<PAT TOKEN>" with your github PAT token, tested with "Update ALL user data" PAT token.
curl -q | grep "href" | grep "" | grep -v "\/\[" | awk -F "" '{ print $2 }' | awk -F "\"\>" '{ print $1 }' | sed 's/\///g' | sed '/^$/d' | xargs -I USER curl -i -X PUT -H "Authorization: token <pat token here>" -H "Accept: application/vnd.github.v3+json"
gkossakowski /
Last active June 19, 2018 18:27
Understand Scala's core typechecking rules

Scala's "type T in class C as seen from a prefix type S" with examples


Recently, I found myself in need to precisely understand Scala's core typechecking rules. I was particulary interested in understanding rules responsible for typechecking signatures of members defined in classes (and all types derived from them). Scala Language Specification (SLS) contains definition of the rules but lacks any examples. The definition of the rules uses mutual recursion and nested switch-like constructs that make it hard to follow. I've written down examples together with explanation how specific set of rules (grouped thematically) is applied. These notes helped me gain confidence that I fully understand Scala's core typechecking algorithm.

As Seen From

Let's quote the Scala spec for As Seen From (ASF) rules numbered for an easier reference:

alexandru /
Last active April 1, 2018 14:57
Task: A diverging design from Future and Scalaz Task
djspiewak /
Created March 22, 2015 19:55
Introduction to scalaz-stream

Introduction to scalaz-stream

Every application ever written can be viewed as some sort of transformation on data. Data can come from different sources, such as a network or a file or user input or the Large Hadron Collider. It can come from many sources all at once to be merged and aggregated in interesting ways, and it can be produced into many different output sinks, such as a network or files or graphical user interfaces. You might produce your output all at once, as a big data dump at the end of the world (right before your program shuts down), or you might produce it more incrementally. Every application fits into this model.

The scalaz-stream project is an attempt to make it easy to construct, test and scale programs that fit within this model (which is to say, everything). It does this by providing an abstraction around a "stream" of data, which is really just this notion of some number of data being sequentially pulled out of some unspecified data source. On top of this abstraction, sca

milessabin / gist:11244675
Created April 24, 2014 07:17
Lens inference in shapeless 2.0.0
View gist:11244675
import shapeless._
import ops.record.{ Selector, Updater }
import record.{ FieldType, field }
trait PathLens[T, P] {
type Elem
def get(t : T) : Elem
def set(t : T)(e : Elem) : T
channingwalton / shapelessy.scala
Last active August 29, 2015 14:00
Replacing boilerplate with shapeless
View shapelessy.scala
case class Foo[T](x: T) {
def map[B](f: T => B) = Foo(f(x))
object OldWay {
def combineLatest[T1, T2](e1: Foo[T1], e2: Foo[T2]): Foo[(T1, T2)] = Foo((e1.x, e2.x))
def combineLatest[T1, T2, T3](e1: Foo[T1], e2: Foo[T2], e3: Foo[T3]): Foo[(T1, T2, T3)] =
combineLatest(combineLatest(e1, e2), e3) map {
View gist:8549878
import shapeless._
import record._
import syntax.singleton._
object ScaldingPoC extends App {
// map, flatMap
val birds =
"name" ->> "Swallow (European, unladen)" :: "speed" ->> 23 :: "weightLb" ->> 0.2 :: "heightFt" ->> 0.65 :: HNil,
folone / gist:6258410
Last active April 27, 2018 14:09
Ackermann function
View gist:6258410
def ackermann(m: Int, n: Int): Int = {
(m, n) match {
case (0, _) n + 1
case (m, 0) if m > 0 ackermann(m - 1, 1)
case (m, n) if m > 0 && n > 0 ackermann(m - 1, ackermann(m, n - 1))
import scalaz._, Scalaz._, Free.{suspend _, _}, Trampoline._
def ackermannTramp(m: Int, n: Int): Trampoline[Int] = {
milessabin / gist:6140251
Created August 2, 2013 14:25
HLists and singleton types encode records in Scala
View gist:6140251
scala> import shapeless._; import SingletonTypes._; import Record._
import shapeless._
import SingletonTypes._
import Record._
scala> val r = ("foo" ->> 23) :: ("bar" ->> true) :: ("baz" ->> 2.0) :: HNil
r: (String("foo"), Int) :: (String("bar"), Boolean) :: (String("baz"), Double) :: HNil =
(foo,23) :: (bar,true) :: (baz,2.0) :: HNil
scala> r.head // r is an HList of pairs of singleton-typed Strings and values ...