Skip to content

Instantly share code, notes, and snippets.

View jroper's full-sized avatar

James Roper jroper

View GitHub Profile
@jroper
jroper / CometAppender.java
Created June 15, 2012 12:19
Play 2.0 Comet log tailing
package util.logging;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.UnsynchronizedAppenderBase;
import play.libs.F;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@jroper
jroper / Schrödinger.scala
Created June 4, 2012 15:59
Scala would be more fun if it had one of these...
final case class Schrödinger[+A, +B](a: A, b: B) extends Either[A, B] {
private var isleft = true
private var isright = true
lazy val actual : Either[A, B] = {
if (new Random().nextBoolean()) {
isright = false
Left(a)
} else {
isleft = false
Right(b)
@jroper
jroper / Html5PushStatePlaceManager.java
Created May 7, 2012 12:32
GWTP HTML5 pushState place manager implementation
package com.gwtplatform.mvp.client.proxy;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.user.client.Window;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
@Singleton
public class Html5PushStatePlaceManager extends PlaceManagerImpl {
@jroper
jroper / ScalaFlectSpec.scala
Created April 22, 2012 15:24
ScalaFlect - The new strongly typed reflection library I'm writing for using in query DSLs
package au.id.jazzy.scalaflect
import org.specs2.mutable.Specification
object ScalaFlectSpec extends Specification {
"ScalaFlect" should {
"be able to look up simple case class properties" in {
val exampleCaseClass = new ScalaFlect(classOf[ExampleCaseClass])
val member = exampleCaseClass.reflect(_.property)
member.toString mustEqual "property"