Skip to content

Instantly share code, notes, and snippets.

@zcox
zcox / gist:3287436
Created August 7, 2012 17:18
Java8 default methods syntax proposal
public interface Foo {
public String bar() {
return "bar";
}
public String baz();
}
@zcox
zcox / gist:4399338
Last active December 10, 2015 07:09
Successful request/response through ELB
2012-12-28 16:18:37,080 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Reading from connection
2012-12-28 16:18:37,083 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Read 274 bytes
2012-12-28 16:18:37,083 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - New connection accepted on /0.0.0.0:5555
2012-12-28 16:18:37,083 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - New connection accepted on /0.0.0.0:5555
2012-12-28 16:18:37,084 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Register(spray.io.ConnectionActors$$anon$1@58e90d6d)
2012-12-28 16:18:37,084 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Register(spray.io.ConnectionActors$$anon$1@2c709cb5)
2012-12-28 16:18:37,082 DEBUG c.p.api.PongrAPI$$anonfun$1$$anon$1 - GET /ping => 200 OK 'pongr' took 0 msec
2012-12-28 16:18:37,085 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Send(spray.io.ConnectionActors$$anon$1@5e9f01e6,List(java.nio.HeapByteBuffer[pos=0 lim=152 cap=160]),None)
20
@zcox
zcox / gist:4399432
Created December 28, 2012 16:35
App at rest. Shows connections being opened & closed. One HTTP request by ELB to /healthcheck.
2012-12-28 16:29:52,380 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - New connection accepted on /0.0.0.0:5555
2012-12-28 16:29:52,381 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Register(spray.io.ConnectionActors$$anon$1@6adb93a2)
2012-12-28 16:29:52,381 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Reading from connection
2012-12-28 16:29:52,381 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Closing connection due to PeerClosed
2012-12-28 16:29:52,382 DEBUG spray.can.server.HttpServer com-pongr-api-PongrAPI-akka.actor.default-dispatcher-4 - Stopping connection actor, connection was closed due to PeerClosed
2012-12-28 16:30:06,693 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Reading from connection
2012-12-28 16:30:06,694 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Closing connection due to PeerClosed
2012-12-28 16:30:06,694 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - New connection accepted on /0.0.0.0:5555
2012-12-28 16:30:06,694 DEBUG spray.can.s
@zcox
zcox / gist:4399573
Created December 28, 2012 16:47
Successful request/response using server directly
2012-12-28 16:45:44,289 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - New connection accepted on /0.0.0.0:5555
2012-12-28 16:45:44,290 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Register(spray.io.ConnectionActors$$anon$1@160851e0)
2012-12-28 16:45:44,291 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Reading from connection
2012-12-28 16:45:44,291 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Read 175 bytes
2012-12-28 16:45:44,294 DEBUG c.p.api.PongrAPI$$anonfun$1$$anon$1 - GET /ping => 200 OK 'pongr' took 1 msec
2012-12-28 16:45:44,295 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Executing command Send(spray.io.ConnectionActors$$anon$1@160851e0,List(java.nio.HeapByteBuffer[pos=0 lim=152 cap=160]),None)
2012-12-28 16:45:44,295 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Writing to connection
2012-12-28 16:45:44,295 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - Wrote 152 bytes
2012-12-28 16:45:44,355 DEBUG spray.io.IOBridge com-pongr-api-PongrAPI-1 - R
@zcox
zcox / gist:6193780
Last active December 20, 2015 20:59
Titan Server 0.3.1 Upstart script for Ubuntu 12.04. Place the content below into /etc/init/titan.conf. Use `sudo start titan` to start the Titan server, and `sudo stop titan` to stop it. Titan will also auto-start if server is rebooted.
#http://upstart.ubuntu.com/cookbook/#introduction
author "Zach Cox <zcox@pongr.com>"
description "Titan+Cassandra+Rexster"
version "0.3.1"
#2=regular running mode, 3,4,5 are aliases for 2
start on runlevel [2345]
#0=shutdown, 1=single-user mode, 6=reboot
@zcox
zcox / RexsterGraphTest.scala
Last active December 21, 2015 11:09
Multiple threads all using the same RexsterGraph instance, each one creates a new vertex then sets many properties on it. Runs against Titan Server (Cassandra) 0.3.2. Exceptions ensue.
package com.pongr
import grizzled.slf4j.Logging
import com.tinkerpop.blueprints.Graph
import com.tinkerpop.blueprints.impls.rexster.RexsterGraph
import java.util.concurrent.CountDownLatch
class CreateVertexAndSetProperties(g: Graph, latch: CountDownLatch, id: String, propetyCount: Int) extends Runnable with Logging {
override def run() {
debug("Starting vertex %s using graph %s..." format (id, g))
@zcox
zcox / gist:6377426
Last active December 21, 2015 22:48
val conf = new BaseConfiguration()
conf.setProperty("storage.backend","cassandra")
conf.setProperty("storage.hostname","127.0.0.1")
conf.setProperty("storage.index.search.backend", "elasticsearch")
conf.setProperty("storage.index.search.hostname", "127.0.0.1:9200")
conf.setProperty("storage.index.search.client-only", true)
conf.setProperty("storage.index.search.local-mode", false)
val graph = TitanFactory.open(conf)
@zcox
zcox / Main.scala
Created August 29, 2013 14:44
titan-server-cassandra-es.properties shows how to set up Titan Server's ElasticSearch to accept remote connections (local-mode=false allows remote connections on port 9300). Main.scala shows how to configure TitanGraph to use the Titan Server's ElasticSearch.
val conf = new BaseConfiguration()
conf.setProperty("storage.backend","cassandra")
conf.setProperty("storage.hostname","127.0.0.1")
conf.setProperty("storage.index.search.backend", "elasticsearch")
conf.setProperty("storage.index.search.hostname", "127.0.0.1")
val graph = TitanFactory.open(conf)
@zcox
zcox / gist:6826931
Last active December 24, 2015 16:19
val talk = Map(
"title" -> "Scala Map Literals are not Syntactic Sugar",
"presenter" -> "Zach Cox",
"twitter" -> "@zcox",
"meetup" -> "iascala",
"date" -> "2013-10-09")
import java.util.*;
Map<String, Integer> m = new HashMap<String, Integer>();
m.put("a", 1);
m.put("b", 2);