Skip to content

Instantly share code, notes, and snippets.

View pk11's full-sized avatar

Peter Hausel pk11

  • Silicon Valley, CA
View GitHub Profile
@pk11
pk11 / gist:3707286
Created September 12, 2012 15:14
scala 2.10.0-M7 compiler crash
source file:
-----------
https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/play/api/libs/json/Util.scala
trace:
------
Good news, I've found the problem, a simple race condition.
The issue was in Promise.scala, the test was finishing before the thread
that had initialised the promise subsystem had had a chance to set the
underlyingSystem Option, so when the test
shutdown code went to shut down the promise system, it found no system to shutdown.
Synchronizing all access to that global var solved the problem.
@pk11
pk11 / gist:3975910
Created October 29, 2012 19:23
oops
at scala.sys.package$.error(package.scala:27)
at scala.Predef$.error(Predef.scala:123)
at sbt.Tests$.showResults(Tests.scala:192)
at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:296)
at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:294)
at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
@pk11
pk11 / gist:4258783
Created December 11, 2012 14:03
iteratee impl
package boo {
object Iteratee {
import Implicits.internal
//clientAPI does not take an implicit, so the closest in scope is resolved
def clientAPI(): Unit = println(Future.future)
}
object Future {
def future(implicit ex: String): String = ex
@pk11
pk11 / mvn2sbt.scala
Created December 14, 2012 16:25
mvn2sbt - generates an sbt file based on a simple (java) pom.xml
import scala.xml._
import java.io._
/**
* based on https://gist.github.com/388334
*/
object mvn2sbt {
private def printToFile(f: java.io.File)(op: java.io.PrintWriter => Unit) {
@pk11
pk11 / binding.ts
Last active December 19, 2015 14:08
typescript - binding
class B {
boo: string = "yay!";
foo(): string {
return this.boo;
}
}
var b = new B();
console.log(b.foo()); // prints boo
var ref = b.foo;
<html>
<body>
<!-- Send text to websocket -->
<input id="userInput" type="text">
<button onclick="ws.send(document.getElementById('userInput').value)">Send</button>
<h1>Websockets demo</h1>
<!-- Results -->
@pk11
pk11 / gist:6179319
Last active December 20, 2015 18:58
//imports excluded for brevity
var websocket = new BaseWebSocketHandler() {
connectionCount: 1,
//note: webbit is single-threaded
//you may need to change this to ConcurrentHashMap
//if `connections` is accessed from worker threads
connections: new HashMap(),
onOpen: function (connection) {
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/>
</head>
<body>
<script data-model="rest">
var Server = function() { this.name = ''; };
</script>
@pk11
pk11 / gist:6755555
Last active December 24, 2015 06:09
var avatar = require("org/glassfish/avatar");
var getTime = function() {
var result = new Date();
return {
time: result.toISOString(),
h: result.getHours(),
m: result.getMinutes(),
s: result.getSeconds(),
d: result.getDate(),