Skip to content

Instantly share code, notes, and snippets.

View stephenjudkins's full-sized avatar

Stephen Judkins stephenjudkins

View GitHub Profile
@ {
import shapeless._
import shapeless.nat._
import shapeless.ops.nat._
import shapeless.ops.hlist._
trait Fizz
trait Buzz
trait Match[N <: Nat, FB] { def s: String }
@stephenjudkins
stephenjudkins / .bazelrc
Last active November 7, 2019 17:37
bazel-managed JDK
build --javabase=//:jdk
build --host_javabase=//:jdk
build --java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8
build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_hostjdk8

Keybase proof

I hereby claim:

  • I am stephenjudkins on github.
  • I am stephenjudkins (https://keybase.io/stephenjudkins) on keybase.
  • I have a public key whose fingerprint is 22EE 3CFF 0422 A3BC 7AB6 C844 8C82 B078 346A A229

To claim this, I am signing this object:

sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@stephenjudkins
stephenjudkins / gist:801de2af854245e9f14f
Created May 20, 2014 17:48
Hacky fix to IE11 multiple adjacent text nodes problem for Angular
isText = (node) -> node && node.nodeType == Node.TEXT_NODE
normalizeNode = (node) ->
lastSibling = null
for child in (node?.childNodes || [])
if isText(child) and isText(lastSibling)
combined = lastSibling.nodeValue + child.nodeValue
child.nodeValue = combined
node.removeChild(lastSibling)
trait HListContains[-H <: HList, A] { def apply(h: H):A }
implicit def headContains[A, T <: HList] = new HListContains[A :: T, A] {
def apply(h: A :: T) = h.head
}
implicit def tailContains[A, H, T <: HList](implicit tc: HListContains[T, A]) = new HListContains[H :: T, A] {
def apply(h: H :: T) = tc(h.tail)
}
<stephenjudkins> luft: SBT can do anything, it's turing-complete
<stephenjudkins> there are examples of SBT tasks that generate scala source code
<dobblego> sbt is turing-complete? what does this mean?
<mapreduce> It can use an infinite amount of tape.
<stephenjudkins> luft: see https://github.com/twitter/sbt-scrooge
<dobblego> what does it mean specifically for sbt to be turing-complete?
<stephenjudkins> dobblego: use your imagination, and don't pick fights
<dobblego> jesus christ you are sook
<dobblego> it's a fucking question
<dobblego> can you tell me what it means please?
trait Imp[T] {}
object Imp {
implicit val i = new Imp[Int] {}
}
import Imp._
trait F {
type T
object Sort extends App {
//val toCells = (_: String).trim.split(" +")
//val input = io.Source.stdin.getLines.toList.map(toCells).foreach{line => }
val input = List("car", "truck", "8", "4", "bus", "6", "1")
val (matches, mismatches) = input.partition(_.matches("""\d+"""))
}
scala> @annotation.implicitNotFound("whoa there! ${A} is not ${B}, buddy") trait Equals[A,B]
defined trait Equals
scala> implicit def equals[A,B](implicit e: A =:= B):Equals[A,B] = null
equals: [A, B](implicit e: =:=[A,B])Equals[A,B]
scala> implicitly[Equals[String, Int]]
<console>:16: error: whoa there! String is not Int, buddy
implicitly[Equals[String, Int]]
^