Skip to content

Instantly share code, notes, and snippets.

Avatar
🦉

Lukas Rytz lrytz

🦉
View GitHub Profile
@lrytz
lrytz / PositionsClassDump.java
Created May 15, 2014 12:50
ASM InnerClass bug
View PositionsClassDump.java
package test;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.*;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.util.TraceClassVisitor;
View gist:e6daf910fc1a0dbf4ae6
// Invoked with, for example, -Dproject.version=2.11.2-854de2d-nightly
versionWithGit
scalaVersion := version.value
libraryDependencies += "org.scala-lang" % "scala-dist" % version.value
View gist:82e3f9dab4f1afc48c5b
lucmac:sandbox luc$ scalac -version
Scala compiler version 2.11.2 -- Copyright 2002-2013, LAMP/EPFL
lucmac:sandbox luc$ cat Test.scala
package android {
package os {
trait Parcelable {
trait Creator[T]
}
}
}
@lrytz
lrytz / gist:80f3141de8240f9629da
Last active August 29, 2015 14:06
Static fields in Scala (SI-4581)
View gist:80f3141de8240f9629da

Proposal

Fields annotated @scala.static are generated as static fields. The this identifier is not in scope in static field initialization expressions.

A static field x defined in a class C can be referenced as scala.static[C].x. If the field is variable, it can be updated as scala.static[C].x = t.

A static field y defined in a singleton object C can be directly referenced as C.x and updated as C.x = t.

@lrytz
lrytz / gist:8f9969eb0758bc1ab8bf
Created September 20, 2014 12:49
shairport init
View gist:8f9969eb0758bc1ab8bf
#!/bin/sh
### BEGIN INIT INFO
# Provides: shairport
# Required-Start: $remote_fs $networking
# Required-Stop: $remote_fs $networking
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: shairport daemon
### END INIT INFO
View Rapture.scala
import rapture.json._
import rapture.json.jsonBackends.jackson._
case class Fruit(name: String, variants: List[String])
object Rapture extends App {
val a = json"""[
{
"name": "apple",
"variants": ["cox", "braeburn"]
@lrytz
lrytz / A.java
Last active August 29, 2015 14:07
View A.java
public class A {
public static final int N = 0;
}
View gist:81805c460eef3864cc1a
class C {
def f() = {
val x = 0
val f = (a: Int) => a + x
f(1)
}
}
View gist:7fb6cb2cc6c87f0558ff
// ==UserScript==
// @name Typesafe GitHub CLA checker
// @namespace http://typesafe.com/
// @version 1.6
// @description Checks a GitHub committer to see if they've signed the CLA
// @match https://github.com/scala/scala/pull/*
// @require http://code.jquery.com/jquery-1.8.2.min.js
// @copyright 2012, James Roper <james@jazzy.id.au>
// ==/UserScript==
View gist:64141a5af3ad116a6854
lucmac:sandbox luc$ cat Test.java
public interface Test {
default int foo() { return 1; }
int bar();
}
lucmac:sandbox luc$ javac Test.java
lucmac:sandbox luc$ scala
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512M; support was removed in 8.0
Welcome to Scala version 2.11.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.