This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mccv | |
/** | |
* A marker trait indicating an exception that is recoverable. | |
* Note that we could make this a trait as well. | |
*/ | |
class RecoverableException extends Exception | |
/** | |
* Usage of our retryable class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.mccv | |
/** | |
* A marker trait indicating an exception that is recoverable. | |
* Note that we could make this a trait as well. | |
*/ | |
class RecoverableException extends Exception | |
/** | |
* Usage of our retryable class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val c = new Cassidy(StackPool(SocketProvider("localhost", 9160)), Protocol.Binary, ConsistencyLevel.QUORUM) | |
c.doWork { | |
s => { | |
val key = "mccv" | |
println("exercising inserts") | |
s ++| ("Delicious", key, new ColumnPath("Users", null, "name"), "Mark McBride") | |
s / ("Delicious") ++| (key, new ColumnPath("Users", null, "location"), "Santa Clara") | |
s / ("Delicious") / (key) ++| (new ColumnPath("Users", null, "state"), "CA") | |
s/"Delicious"/key/"Users" ++| ("age","34-ish") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GangliaLogger(config: ConfigMap) extends Thread { | |
val frequency = config.getInt("ganglia_frequency", 15000) | |
val gmetricExecutable = config.getString("gmetric_executable", "gmetric") | |
val logJvmStats = config.getBool("log_jvm_stats", true) | |
val logCounterStats = config.getBool("log_counter_stats", true) | |
val logTimingStats = config.getBool("log_timing_stats", true) | |
val logGaugeStats = config.getBool("log_gauge_stats", true) | |
val quit = new CountDownLatch(1) | |
val done = new CountDownLatch(1) | |
val runtime = Runtime.getRuntime() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twitter.jetty | |
object OAuthEncoder { | |
val ALPHA = Set((0x41 to 0x5A):_*) ++ Set((0x61 to 0x7A):_*) | |
val DIGIT = Set((0x30 to 0x39):_*) | |
val HYPHEN = Set(0x2D) | |
val PERIOD = Set(0x2E) | |
val UNDERSCORE = Set(0x5F) | |
val TILDE = Set(0x7E) | |
val UNENCODED = ALPHA ++ DIGIT ++ HYPHEN ++ PERIOD ++ UNDERSCORE ++ TILDE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# need ruby, gems, and the json gem installed | |
function jsonator { | |
ruby -rubygems -r pp -e 'require "json"; ARGF.each {|l| puts JSON.pretty_generate(JSON.parse(l))}' | |
} | |
function jsoncurl { | |
curl -s $@ | jsonator | |
} | |
function jsontwurl { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def timeLoops (loops: Int)(f: => Any) = { | |
val t1 = System.currentTimeMillis | |
for(i <- 1 to loops) | |
f | |
val elapsed = System.currentTimeMillis - t1 | |
println("executed %d loops in %d ms, or %.2f loops/sec".format( | |
loops, elapsed, loops/(elapsed/1000.0))) | |
} | |
val loops = 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import com.twitter.sbt._ | |
class OstrichProject(info: ProjectInfo) extends StandardProject(info) with TartifactoryPublisher with TartifactoryRepos { | |
val specs = "org.scala-tools.testing" % "specs" % "1.6.2.1" | |
val vscaladoc = "org.scala-tools" % "vscaladoc" % "1.1-md-3" | |
val twitterJson = "com.twitter" % "json" % "1.1.2" | |
// we declare a dependencies source location by adding an extra attribute | |
val configgy = "net.lag" % "configgy" % "1.5.5" extra(("source", "../configgy")) | |
val commonsLogging = "commons-logging" % "commons-logging" % "1.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// generate ensime config | |
lazy val genEnsime = task (args => { | |
if (args.length == 1) { | |
genEnsimeConstructor(args(0).toString) | |
} else { | |
task { Some("Usage: gen-ensime <project package name>") } | |
} | |
}) describedAs("Generate a .ensime file for this project") | |
def genEnsimeConstructor(packageName: String) = task { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Method | |
class Sendable(a: AnyRef) { | |
val methods = a.getClass.getDeclaredMethods | |
def wrapByte(b: Byte) = new java.lang.Byte(b) | |
def wrapShort(s: Short) = new java.lang.Short(s) | |
def wrapInt(i: Int) = new java.lang.Integer(i) | |
def wrapLong(l: Long) = new java.lang.Long(l) | |
def wrapFloat(f: Float) = new java.lang.Float(f) |
OlderNewer