Skip to content

Instantly share code, notes, and snippets.

@dirkgr
dirkgr / RefCount.scala
Created November 22, 2016 22:36
Reference counting in Scala
case class CountedReference[T <: AutoCloseable](counted: ReferenceCounted[T]) extends AutoCloseable {
counted.inc()
override def close() = counted.dec()
def get = counted.inner
}
case class ReferenceCounted[T <: AutoCloseable](inner: T) {
private val count = new AtomicInteger(0)
@rklaehn
rklaehn / Proxy.scala
Created January 31, 2015 16:29
Minimal akka http proxy
package akkahttptest
import akka.actor.ActorSystem
import akka.http.Http
import akka.stream.FlowMaterializer
import akka.http.server._
import akka.http.marshalling.PredefinedToResponseMarshallers._
import akka.stream.scaladsl.{HeadSink, Source}
object Proxy extends App {
@rednaxelafx
rednaxelafx / PrintThreadIds.java
Created February 25, 2011 10:31
find out the correspondence between the tid/nid of Java threads as shown from jstack/JMX, on HotSpot/Linux
package fx.jvm.hotspot.tools;
import java.util.List;
import sun.jvm.hotspot.tools.Tool;
public class PrintThreadIds extends Tool {
public static void main(String[] args) {
PrintThreadIds tool = new PrintThreadIds();
tool.start(args);