Skip to content

Instantly share code, notes, and snippets.

View spmallette's full-sized avatar

stephen mallette spmallette

View GitHub Profile
@spmallette
spmallette / gist:885165
Created March 24, 2011 14:40
post vertex exception handling
@POST
@Path("/{id}")
public Response postVertex(@PathParam("graphname") String graphName, @PathParam("id") String id) {
Graph graph = this.getRexsterApplicationGraph(graphName).getGraph();
Vertex vertex = null;
try {
vertex = graph.getVertex(id);
} catch (RuntimeException re)
@spmallette
spmallette / gist:885254
Created March 24, 2011 15:32
curl to rexster
## post an edge
curl -d "" -v http://localhost:8182/graphs/dexsample/edges?_outV=1024\&_inV=1025\&_label=friend
curl -v -X POST -H "Content-Type:application/json" -d '{name:"willa"}' http://localhost:8182/graphs/tinkergraph/vertices/100
curl -v -d 'age=(integer,100)' -X POST http://localhost:8182/graphs/tinkergraph/vertices/1
curl -v -d 'age=(list,((i,100)))' -X POST http://localhost:8182/graphs/tinkergraph/vertices/1
curl -v -X POST -H "Content-Type:application/json" -d '{"script":"g.v(1)"}' http://localhost:8182/graphs/tinkergraph/tp/gremlin
@spmallette
spmallette / gist:889740
Created March 27, 2011 23:06
beat up rexster
for i in {1..1000}
do
echo "[graph] fire $i" >> log.txt
curl -v http://localhost:8182/neo4jsample >> log.txt
echo "" >> log.txt
done
for i in {1..1000}
do
echo "[vertices] fire $i" >> log.txt
@spmallette
spmallette / NotTypes.json
Created August 12, 2011 18:27
JSON from GraphJSONWriter
{
"graph": {
"vertices": [
{
"name": "lop",
"lang": "java",
"_id": "3",
"_type": "vertex"
},
{
@spmallette
spmallette / gist:1211265
Created September 12, 2011 13:38
jquery and rexster
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$.ajax({
type: "PUT",
url: "http://localhost:8182/graphs/tinkergraph/vertices/1",
data: "name=John&location=Boston",
@spmallette
spmallette / curl-test.txt
Created September 29, 2011 15:57
rexster performance
# first curl "warms" the service...second curl is the timed test
curl -s http://localhost:8182/graphs/gratefulgraph/{vertices/1,edges/0}
time curl -s http://localhost:8182/graphs/gratefulgraph/vertices/[0-808] http://localhost:8182/graphs/gratefulgraph/edges/[0-8048]
# 0.6
real 0m34.979s
user 0m1.170s
sys 0m0.690s
# 0.7-SNAPSHOT
@spmallette
spmallette / gist:1358006
Created November 11, 2011 13:30
auto-release
1. Make sure all the change Wiki pages are in the form they should be for release (ie. change the main wiki page to have the <dependency> point to the latest version. change the main Wiki page to have the JavaDoc pointer point to where the latest version JavaDoc will be (for library projects only).)
2. bump the pom.xml of the project (requires the bumping of all depended on TinkerPop projects too) - for Gremlin and Rexster the Tokens.java public static String VERSION needs to be bumped
X. ant release -Drelease.version=0.7
@spmallette
spmallette / gist:1419739
Created December 1, 2011 20:48
GraphSON to JIT
var jitJson = _(graphson.graph.vertices).map(function (v, key) {
return {
id: v._id,
name: v[nameKey],
data: v,
adjacencies: _(graphson.graph.edges).filter(function (e) { return e._outV == v._id }).map(function (edge, key) {
return {
nodeTo: edge._inV,
data: edge
};
@spmallette
spmallette / gist:1909604
Created February 25, 2012 17:20
tx in tx
public void testTransactionInTransaction() {
TransactionalGraph graph = (TransactionalGraph) graphTest.getGraphInstance();
for (int i = 0; i < 100; i++) {
final Vertex v1 = graph.addVertex(null);
final Vertex v2 = graph.addVertex(null);
graph.setMaxBufferSize(0);
graph.startTransaction();
@spmallette
spmallette / gist:2013057
Created March 10, 2012 20:34
Parameterized Indices In Rexster
curl -v -X POST http://localhost:8182/graphs/neo4jsample/indices/vft?class=vertex&type=automatic&params.to_lower_case=true&params.type=fulltext&params.provider=lucene
curl -v -d -X POST http://localhost:8182/graphs/neo4jsample/vertices?name=Willy
curl -v http://localhost:8182/graphs/neo4jsample/indices/vft?key=name&value=%25query%25willy