Skip to content

Instantly share code, notes, and snippets.

View conikeec's full-sized avatar

Chetan Conikee conikeec

View GitHub Profile
@conikeec
conikeec / avgkvsz.scala
Created March 28, 2012 03:22 — forked from tsuna/avgkvsz.scala
Get average size of a KeyValue from HBase using asynchbase in Scala with the Finagle compatibility layer
import java.util.ArrayList
import scala.collection.JavaConversions._
import com.stumbleupon.async.{Callback, Deferred}
import org.hbase.async.{HBaseClient, KeyValue, Scanner}
import com.twitter.util.{Future, Promise, Return, Throw}
/** Converts a Deferred into a Future. */
implicit def futureFromDeferred[A](d: Deferred[A]): Future[A] = {
val promise = new Promise[A]
@conikeec
conikeec / gist:2142635
Created March 20, 2012 23:47 — forked from nono/gist:1600053
autocomplete with tire
#encoding: utf-8
require 'tire'
require 'json'
require 'active_support/core_ext/object/to_query'
require 'active_support/core_ext/object/to_param'
conf = {
settings: {
number_of_shards: 1,
number_of_replicas: 0,
@conikeec
conikeec / README.txt
Created February 23, 2012 06:50 — forked from andreisavu/README.txt
An Apache Whirr recipe that can be used to start a single virtual machine running HBase on EC2
Hi :)
Here are some quick instruction on running the hbase-ec.properties recipe.
1. Download Whirr 0.7.0 RC0 from here. We are going to publish this as an official release soon.
http://people.apache.org/~asavu/whirr-0.7.0-candidate-0/whirr-0.7.0.tar.gz
2. Extract the archive
@conikeec
conikeec / pipeTo.scala
Created February 19, 2012 02:20 — forked from rkuhn/pipeTo.scala
Futures and Resizers
import akka.dispatch.Future
import akka.pattern.pipe
import akka.actor.Actor
case class Work(s: String)
case class Result(s: String)
object MyActor {
// put here to avoid closing over actor’s state
def doWork(work: String): String = {
@conikeec
conikeec / build.sbt
Created February 18, 2012 07:23 — forked from durgeshm/build.sbt
Finagle 1.9.7 with Scala 2.9.1
scalaVersion := "2.9.1"
resolvers += "durgeshm repo" at "http://durgeshm.github.com/releases/"
libraryDependencies ++= Seq(
"com.twitter" %% "finagle-core" % "1.9.7",
"com.twitter" %% "finagle-http" % "1.9.7")
@conikeec
conikeec / AkkaUnfilteredSample.scala
Created February 17, 2012 17:40 — 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 / ParseLines.scala
Created February 17, 2012 00:14 — forked from seanparsons/ParseLines.scala
Useful code snippet to use when parsing large files in the Scala REPL
import scala.io.Source
def parseLines[T](file: String, transform: (Iterator[String]) => T): T = {
val log = Source.fromFile(file)
val logLines = log.getLines()
try { transform(logLines) } finally { log.close }
}
// Example usage.
// parseLines("verybigfile.txt", iterator.take(100).foreach(println))
@conikeec
conikeec / ParseLines.scala
Created February 16, 2012 19:24 — forked from seanparsons/ParseLines.scala
Useful code snippet to use when parsing large files in the Scala REPL
import scala.io.Source
def parseLines[T](file: String, transform: (Iterator[String]) => T): T = {
val log = Source.fromFile(file)
val logLines = log.getLines()
try { transform(logLines) } finally { log.close }
}
// Example usage.
// parseLines("verybigfile.txt", iterator.take(100).foreach(println))
@conikeec
conikeec / mapreduce_akka.scala
Created February 14, 2012 07:12 — forked from gertjana/mapreduce_akka.scala
MapReduce example using Akka Actors
package net.addictivesoftware.scala.akkaactors
import akka.actor.{Actor, PoisonPill}
import Actor._
import akka.routing.{Routing, CyclicIterator}
import Routing._
import collection.mutable.{HashMap, Map}
import java.util.concurrent.CountDownLatch
@conikeec
conikeec / EsperUtil.scala
Created February 12, 2012 08:06 — 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 {