Skip to content

Instantly share code, notes, and snippets.

@dkim
dkim / pr.md
Created February 7, 2020 12:16 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@dkim
dkim / intellij.adoc
Last active March 24, 2025 17:00
IntelliJ IDEA Keymap

IntelliJ IDEA Keymap

File

@dkim
dkim / GADTs.scala
Created December 15, 2017 20:58 — forked from pchiusano/GADTs.scala
GADT support in Scala
/** GADTs in Scala and their limitations */
/** Background: what is an algebraic data type (ADT) ?
* ADT: (possibly) recursive datatype with sums and products
* In scala - a trait with case classes (case class is product, subtyping is sum)
*/
/** Motivation: untyped embedded DSL doesn't prevent nonsensical expressions */
sealed trait Expr {
def apply(other: Expr) = Ap(this, other)
@dkim
dkim / gist:04a1e0fc8f8abc23b10a91c317878aae
Created September 15, 2017 19:43 — forked from manjuraj/gist:b56e3377d562fdf0d283
generalized type constraints: =:=, <:< and <%<
//
// References
// - http://stackoverflow.com/questions/3427345/what-do-and-mean-in-scala-2-8-and-where-are-they-documented
// - http://stackoverflow.com/questions/2603003/operator-in-scala
// - https://gist.github.com/retronym/229163
// - http://debasishg.blogspot.com/2010/08/using-generalized-type-constraints-how.html#sthash.GKfUGq9p.dpuf
// - http://www.scala-lang.org/old/node/4041.html
// - https://groups.google.com/forum/#!searchin/scala-user/generic$20type$20constraint/scala-user/mgx9-TUapQo/tiN6x818dKsJ
//
@dkim
dkim / PropertyTests.scala
Created September 11, 2017 17:37 — forked from davidallsopp/PropertyTests.scala
Examples of writing mixed unit/property-based (ScalaTest with ScalaCheck) tests. Includes tables and generators as well as 'traditional' tests.
/**
* Examples of writing mixed unit/property-based (ScalaCheck) tests.
*
* Includes tables and generators as well as 'traditional' tests.
*
* @see http://www.scalatest.org/user_guide/selecting_a_style
* @see http://www.scalatest.org/user_guide/property_based_testing
*/
import org.scalatest._

Desugar Scala Expressions

Use the compiler

scala -Xprint:typer -e "class A(val i: Int)" prints the desugarred expression after the typer phase. Use scala -Xshow-phases to get a list of all phases.

Or use a macro in the REPL

Paste this into a REPL session or in a file loaded with the :load command:

@dkim
dkim / example.scala
Created September 10, 2017 03:38 — forked from mpilquist/example.scala
Using scala-reflect to desugar
scala> import scala.reflect.runtime.universe._
import scala.reflect.runtime.universe._
scala> showCode(reify {
| for{
| x <- 1 to 5
| _ = print("hi")
| } print(x)
| }.tree)
res1: String =
@dkim
dkim / Array-In-InferRule.md
Created August 15, 2016 19:42 — forked from lambdageek/Array-In-InferRule.md
LaTeX array within inferrule from mathpartir

Sometimes I want to put an array inside of a mathpartir inferrule.

The straightforward thing doesn't work:

\begin{equation*}
\inferrule{Conclusion}{
  Premiss 1 \and
  \begin{array}{ll}
 1 &amp; 2 \\ % note, this is where the problem happens