Skip to content

Instantly share code, notes, and snippets.

View conikeec's full-sized avatar

Chetan Conikee conikeec

View GitHub Profile
@conikeec
conikeec / AkkaUnfilteredSample.scala
Created April 30, 2012 06:56 — forked from chrsan/AkkaUnfilteredSample.scala
Akka 2.0 unfiltered RESTful sample
package akka.unfiltered
import akka.actor._
import akka.dispatch.Future
import akka.pattern.ask
import akka.util.duration._
import akka.util.Timeout
import unfiltered.Async
import unfiltered.request._
@conikeec
conikeec / EsperUtil.scala
Created May 3, 2012 02:40 — forked from wangzaixiang/EsperUtil.scala
Using Esper with Scala
package demo1
import com.espertech.esper.client.EventBean
import com.espertech.esper.client.EPAdministrator
import com.espertech.esper.client.UpdateListener
import com.espertech.esper.client.EPListenable
import com.espertech.esper.client.EPServiceProvider
object EsperUtil {
@conikeec
conikeec / gist:2582631
Created May 3, 2012 02:40 — forked from takscape/gist:1272336
Scala: Esper
import com.espertech.esper.client.{Configuration, EventBean, UpdateListener, EPServiceProviderManager}
import java.util.HashMap
import scala.collection.JavaConversions._
object Sandbox
{
def main(args: Array[String]) {
val config = new Configuration();
val eventType = new HashMap[String, AnyRef]()
eventType.put("itemName", classOf[String])
@conikeec
conikeec / KafkaEmbedded.scala
Created May 10, 2012 03:19 — forked from mardambey/KafkaEmbedded.scala
Embedded Kafka broker / producer / simple consumer in a single process useful for testing or for persistent queues.
import java.util.Properties
import kafka.server.KafkaServer
import kafka.server.KafkaConfig
import kafka.producer.ProducerConfig
import kafka.producer.Producer
import kafka.message.Message
import kafka.producer.ProducerData
import kafka.consumer.ConsumerConfig
import kafka.consumer.Consumer
import kafka.utils.Utils
@conikeec
conikeec / readme.md
Created May 18, 2012 09:35 — forked from seratch/readme.md
Finagle Developer Guide (December 15, 2011 Draft) の適当な和訳

細かい点で間違いなどあるかと思います。fork して直していただけると助かります。

Finagle is built using sbt. We've included a bootstrap script to ensure the correct version of sbt is used. To build:

Finagle は sbt を使ってビルドしています。私たちは確実に適切なバージョンの sbt を使うようにブートストラップ用のスクリプトを含めています。このように実行します。

    $ ./sbt test

@conikeec
conikeec / readme.md
Created May 18, 2012 09:35 — forked from seratch/readme.md
Finagle Developer Guide (December 15, 2011 Draft) の適当な和訳

細かい点で間違いなどあるかと思います。fork して直していただけると助かります。

Finagle is built using sbt. We've included a bootstrap script to ensure the correct version of sbt is used. To build:

Finagle は sbt を使ってビルドしています。私たちは確実に適切なバージョンの sbt を使うようにブートストラップ用のスクリプトを含めています。このように実行します。

    $ ./sbt test

@conikeec
conikeec / validateanyProduct.scala
Created May 31, 2012 16:01 — forked from wfaler/validateanyProduct.scala
validateanyProduct.scala
// modify to collect errors, use Either or whatever floats your boat, just an example that throws
// IllegalArgumentException on the first null or empty String it encounters, if there is one.
// Works for any case class or collection such as List.
def validateProduct[T <: Product](product: T): Unit = product.productIterator foreach {
case null => throw new IllegalArgumentException("null attributes are not allowed for " + product)
case x: String if x.isEmpty => throw new IllegalArgumentException("Empty strings are not allowed for " + product)
case x: Product => validateProduct(x)
case _ => {}
}
@conikeec
conikeec / AVLTree.scala
Created June 7, 2012 01:17 — forked from songpp/AVLTree.scala
scala版 AVLTree
package org.songpp.structure
object AVLTree {
/**
* 2011-04-03
* 未完成。
* 关键的旋转算法还没实现。
* toy-writing for fun and studying scala
* base on scala collections framework
@conikeec
conikeec / gist:3157335
Created July 21, 2012 21:58
init.d script to launch Play framework under Ubuntu
#!/bin/sh
### BEGIN INIT INFO
## END INIT INFO
# Path to play install folder
PLAY_HOME=/usr/share/play
PLAY=$PLAY_HOME/play
# Path to the JVM
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk
@conikeec
conikeec / MetricsPlugin.java
Created August 5, 2012 18:51 — forked from Peksa/MetricsPlugin.java
Codahale metrics with Play framework
package plugins;
import play.PlayPlugin;
import play.mvc.Http;
import play.mvc.Http.Request;
import play.mvc.Http.Response;
import play.mvc.Router.Route;
import play.vfs.VirtualFile;
import util.MetricsUtil;