Skip to content

Instantly share code, notes, and snippets.

@jrudolph
jrudolph / dependencies.txt
Created March 18, 2014 08:22
spray-httpx dependencies
[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.typesafe.play:play-json_2.10:2.2.2
[info] | +-com.fasterxml.jackson.core:jackson-annotations:2.2.2 (evicted by: 2.3.0)
@jrudolph
jrudolph / console.txt
Last active August 29, 2015 14:01
for / yield desugaring
> 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
jrudolph / .gitignore
Last active August 29, 2015 14:01
Compiler crash
/.idea*
target/
@jrudolph
jrudolph / UpdateCopyrightHeaders.scala
Last active August 29, 2015 14:01
Simple script to update copyright headers
import java.io.{ FileOutputStream, File }
import scala.io.Source
import scala.util.matching.Regex
object UpdateCopyrightHeaders extends App {
val encoding = "utf-8"
val copyrightLines: Seq[String] = "Copyright (C) 1894-2014 Example Corp. <http://www.example.com>".split("\n")
val srcDir = new File("src/")
def updateCopyright(file: File): Unit = {
@jrudolph
jrudolph / bytecode.txt
Last active August 29, 2015 14:02
Val vs. JVal
public JVal(int);
flags: ACC_PUBLIC
Code:
aload_0
invokespecial
iconst_0
istore_2
A: iload_2
iload_1
if_icmpge B
@jrudolph
jrudolph / Failrec.scala
Last active August 29, 2015 14:02
@tailrec gets short-circuited
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
jrudolph / .gitignore
Last active August 29, 2015 14:02
Using typeOf in macro fails
/.idea*
target/
@jrudolph
jrudolph / test
Last active August 29, 2015 14:03
Test
test
@jrudolph
jrudolph / sets.scala
Created September 8, 2014 11:52
Not so covariant sets
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, _))
| }
@jrudolph
jrudolph / CVE-2014-6271.md
Last active August 29, 2015 14:06
CVE-2014-6271

CVE-2014-6271

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.)