Skip to content

Instantly share code, notes, and snippets.


Johannes Rudolph jrudolph

View GitHub Profile
jrudolph / dependencies.txt
Created Mar 18, 2014
spray-httpx dependencies
View dependencies.txt
[info] io.spray:spray-httpx:1.3.1
[info] +-com.typesafe.akka:akka-osgi_2.10:2.3.0 [S]
[info] | +-com.typesafe.akka:akka-actor_2.10:2.3.0 [S]
[info] | | +-com.typesafe:config:1.2.0
[info] | |
[info] | +-org.osgi:org.osgi.compendium:4.3.1
[info] | +-org.osgi:org.osgi.core:4.3.1
[info] |
[info] | +-com.fasterxml.jackson.core:jackson-annotations:2.2.2 (evicted by: 2.3.0)
jrudolph / console.txt
Last active Aug 29, 2015
for / yield desugaring
View console.txt
> scala -Xprint:parser
scala> trait A { def getB: Int }
scala> def getA(): A = null
scala> def x = for { a <- Option(getA()); b <- Option(a.getB) } yield b
[[syntax trees at end of parser]] // <console>
[... snip ...]
def x = Option(getA()).flatMap(((a) => Option(a.getB).map(((b) => b))))
jrudolph / .gitignore
Last active Aug 29, 2015
Compiler crash
View .gitignore
jrudolph / UpdateCopyrightHeaders.scala
Last active Aug 29, 2015
Simple script to update copyright headers
View UpdateCopyrightHeaders.scala
import{ FileOutputStream, File }
import scala.util.matching.Regex
object UpdateCopyrightHeaders extends App {
val encoding = "utf-8"
val copyrightLines: Seq[String] = "Copyright (C) 1894-2014 Example Corp. <>".split("\n")
val srcDir = new File("src/")
def updateCopyright(file: File): Unit = {
jrudolph / bytecode.txt
Last active Aug 29, 2015
Val vs. JVal
View bytecode.txt
public JVal(int);
A: iload_2
if_icmpge B
jrudolph / Failrec.scala
Last active Aug 29, 2015
@tailrec gets short-circuited
View Failrec.scala
import scala.annotation.tailrec
object Failrec {
def main(args: Array[String]): Unit = run()
def run() =
@tailrec def rec(count: Long): Boolean =
if (count == 0) true else rec(count - 1)
jrudolph / .gitignore
Last active Aug 29, 2015
Using typeOf in macro fails
View .gitignore
jrudolph / sets.scala
Created Sep 8, 2014
Not so covariant sets
View sets.scala
scala> class MySet[T](elements: Seq[T])(implicit ordering: Ordering[T]) extends scala.collection.immutable.Set[T] {
| // Members declared in scala.collection.GenSetLike
| def iterator: Iterator[T] = elements.iterator
| // Members declared in scala.collection.SetLike
| def -(elem: T): scala.collection.immutable.Set[T] = ???
| def +(elem: T): scala.collection.immutable.Set[T] = ???
| def contains(t: T): Boolean = elements.exists(ordering.equiv(t, _))
| }


Environment variables

On a UNIX system there are two main ways of passing arguments from a parent to a child process when spawning a new process:

  • the command line: a string that is usually given explicitly by the user
  • the environment: a set of key/value pairs that is inherited from the parent process implicitly but that can also be modified explicitly when starting a process

(You can observe the values of the command line and the environment by looking at /proc/<pid>/cmdline and /proc/<pid>/environ.)

You can’t perform that action at this time.