Skip to content

Instantly share code, notes, and snippets.

Datagrid datagrid = Builder.newDatagrid();
Table table = datagrid.useTable("Table");
Key<String> key = Builder.newKeyMaker().createKey("key");
ColumnFamily cf = Builder.newColumnFamily("ColumnFamily");
Column<String, String> c2 = Builder.newColumn("c-1", "value");
Column<String, String> c3 = Builder.newColumn("c-2", "value");
Column<String, String> c4 = Builder.newColumn("c-3", "value");
Mutation mutation = table.newMutation().prepareInsert(key, cf, c2, c3, c4);
@dehora
dehora / compute_tokens.groovy
Created June 16, 2011 13:23
Cassandra token range generator in Groovy
println("Cassandra Token Range Generator \n")
int nodes = -1
if (args.length >= 1) {
nodes = new Integer(args[0])
}
else {
gets = {
print it
@dehora
dehora / build-scribe-2.2.tar.gz.rst
Created July 7, 2011 20:17
build-scribe-2.2.tar.gz

Did this to build scribe-2.2.tar.gz

Get thrift 0.5.0 instead of 0.6.1/0:

sudo apt-get install php5-dev
sudo apt-get install php-config # *-php=no didn't quite work out for me
sudo ./configure --with-haskell=no  # with-haskell=for-great-good did NOT work

and then configure/make/install thrift and fb303

@dehora
dehora / gist:2008850
Created March 9, 2012 21:44
maven java+scala

Project structure

  mabba/
      pom.xml
      +-/mabba.core #scala 
        pom.xml
      +-/mabba.http #java 
        pom.xml
@dehora
dehora / ServiceMain.scala
Created May 23, 2012 02:24
n resources with dropwizard
object ServiceMain extends ScalaService[ServiceConfiguration]("record-service") {
def initialize(configuration: ServiceConfiguration, environment: Environment) {
val injector: Injector = Guice.createInjector(
new ConfigModule(configuration),
new NotifyModule(),
new AccountModule(),
new CollectionModule()
)
// root resource routing not needed, just add the things in and give them paths
@dehora
dehora / AccountResourceTest.scala
Created May 24, 2012 00:31
Set up Scala test for Dropwizard resources
package net.amadan.example.account
import com.yammer.dropwizard.testing.ResourceTest
import org.mockito.Mockito._
import org.mockito.Matchers._
import org.junit.Test
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers._
import com.codahale.jerkson.ScalaModule
@dehora
dehora / latency.txt
Created May 31, 2012 13:52 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@dehora
dehora / shadok.hs
Created August 1, 2012 11:21
Compile Shadok with haskell 2010
import Shadok.Grammar
import Shadok.StateMachine
import Data.Map (Map, fromList, toList, member, lookup)
import Data.Maybe
import Data.List (intersperse)
import System.Console.GetOpt
--import qualified System
import System.IO
import System.Environment
{
"37345f32656461303266333932313366383933633961386335383363373435366531636636393764326136636636666333306263383735363138366233323835323231": [["Alternate|JPEG_RESULT:true|h:12|mt:image/jpeg|s:173|w:12","sal:c7623eb351d3402bb73df09954eeccfe42cf7e26d946326f0f7169a146fcc70f",1344440054393011], ["Alternate|MAX_WIDTH_JPEG_RESULT:true|h:12|mt:image/jpeg|s:173|w:12","sal:c7623eb351d3402bb73df09954eeccfe42cf7e26d946326f0f7169a146fcc70f",1344440054395003], ["Alternate|MAX_WIDTH_JPEG_RESULT:true|h:600|mt:image/jpeg|s:1884|w:600","sal:b899d412e2d00b1dcb5cd4a0e0505c6711b636dc632a3243d63c7d7199f2fae4",1344440054394003], ["Alternate|THUMBNAIL_MEDIUM_RESULT:true|h:320|mt:image/jpeg|s:723|w:320","sal:d35b7adbae8bb201c58f3f18728c666446e4235c84e5e41e2ce8b2da047b2626",1344440054395008], ["Alternate|THUMBNAIL_MEDIUM_RESULT:true|h:320|mt:image/jpeg|s:726|w:320","sal:7fa25d42cedbe36b17292ecdaf42588b4ac7fb383b6e4e7bd3ff2c40a1e5377c",1344440054395013], ["Alternate|THUMBNAIL_RESULT:true|h:64|mt:image/jpeg|s:209|w:64","sal:2dc66669553f
@dehora
dehora / brew-scala-2.10.0.sh
Last active January 19, 2016 20:36 — forked from fabiofumarola/scala.rb
Install Scala 2.10.0 via brew
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0