Skip to content

Instantly share code, notes, and snippets.

View lrytz's full-sized avatar
🦉

Lukas Rytz lrytz

🦉
View GitHub Profile
@lrytz
lrytz / PositionsClassDump.java
Created May 15, 2014 12:50
ASM InnerClass bug
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;
// Invoked with, for example, -Dproject.version=2.11.2-854de2d-nightly
versionWithGit
scalaVersion := version.value
libraryDependencies += "org.scala-lang" % "scala-dist" % version.value
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)

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
#!/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
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
public class A {
public static final int N = 0;
}
class C {
def f() = {
val x = 0
val f = (a: Int) => a + x
f(1)
}
}
@lrytz
lrytz / z-automator.png
Last active February 4, 2023 21:20
Shortcut for Syntax Highlighting in Keynote
// ==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==