Skip to content

Instantly share code, notes, and snippets.

@espeed
espeed / fluent.py
Created September 4, 2011 22:14
Jython FluentPipeline Example
# Jython FluentPipeline Example
# by James Thornton, http://jamesthornton.com
from com.tinkerpop.pipes.util import FluentPipeline
from com.tinkerpop.blueprints.pgm.impls.tg import TinkerGraphFactory
g = TinkerGraphFactory.createTinkerGraph()
pipe = FluentPipeline()
results = pipe.start(g.getVertex(1)).out("knows").property("name")
@espeed
espeed / gist:1193693
Created September 4, 2011 23:14
Jython AbstractPipeClosure Example
# Jython AbstractPipeClosure Example
# by James Thornton, http://jamesthornton.com
from com.tinkerpop.pipes.util import FluentPipeline
from com.tinkerpop.pipes import AbstractPipeClosure
from com.tinkerpop.blueprints.pgm.impls.tg import TinkerGraphFactory
class StartsWithJ(AbstractPipeClosure):
def compute(self,objects):
@espeed
espeed / trees.groovy
Created September 6, 2011 10:06
Gremlin Trees
// Gremlin user-defined defined tree steps
// inTree() and outTree()
// by James Thornton, http://jamesthornton.com
// see https://groups.google.com/d/topic/gremlin-users/iCPUifiU_wk/discussion
// closure can't have the same name as the defined step
tree = { vertices ->
def results = []
@espeed
espeed / gist:1205327
Created September 9, 2011 02:09
Neo4j write-test compile error
$ mvn compile
/usr/lib/jvm/java-openjdk
[INFO] Scanning for projects...
Downloading: http://repo1.maven.org/maven2/org/neo4j/parent-pom/6/parent-pom-6.pom
[INFO] Unable to find resource 'org.neo4j:parent-pom:pom:6' in repository central (http://repo1.maven.org/maven2)
[WARNING] Skipping jpp repository file:///usr/share/maven2/repository in vanilla mode
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
@espeed
espeed / gist:1208937
Created September 10, 2011 23:18
Rexster Neo4j Config
<graph>
<graph-enabled>true</graph-enabled>
<graph-name>wordgraph</graph-name>
<graph-type>neo4jgraph</graph-type>
<graph-file>/tmp/wordgraph</graph-file>
<properties>
<!-- Memory mapped I/O settings -->
<!-- For high traversal speed it is important to have the nodestore.db and relationshipstore.db files. -->
<neostore.nodestore.db.mapped_memory>285M</neostore.nodestore.db.mapped_memory>
<neostore.relationshipstore.db.mapped_memory>285M</neostore.relationshipstore.db.mapped_memory>
POSTs...
$ httperf --server localhost --port 8182 --uri "/graphs/wordgraph/vertices?element_type=word&name=testing" --method POST --num-conns=1000 --num-calls=1
httperf --client=0/1 --server=localhost --port=8182 --uri=/graphs/wordgraph/vertices?element_type=word&name=testing --send-buffer=4096 --recv-buffer=16384 --method=POST --num-conns=1000 --num-calls=1
httperf: warning: open file limit > FD_SETSIZE; limiting max. # of open files to FD_SETSIZE
Maximum connect burst length: 1
Total: connections 1000 requests 1000 replies 1000 test-duration 7.910 s
Connection rate: 126.4 conn/s (7.9 ms/conn, <=1 concurrent connections)
@espeed
espeed / gist:1213236
Created September 13, 2011 06:12
Neo4j Ordered Writes Branch Build Error
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.765 sec
Running org.neo4j.kernel.impl.index.TestIndexCommand
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.208 sec
Running org.neo4j.kernel.impl.transaction.TestJtaCompliance
Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.79 sec
Running org.neo4j.kernel.impl.traversal.TreeGraphTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.7 sec
Running org.neo4j.kernel.impl.core.TestJumpingIdGenerator
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 sec
Running org.neo4j.kernel.impl.core.TestShortStringProperties
@espeed
espeed / gist:1228266
Created September 20, 2011 03:39
Blueprints/Jython setProperty error when value is of type java.util.ArrayList
>>> from com.tinkerpop.blueprints.pgm.impls.neo4j import Neo4jGraph
>>> from com.tinkerpop.rexster import AbstractSubResource
>>> from com.tinkerpop.rexster import RexsterApplicationProvider
>>> class BatchResource(AbstractSubResource):
... pass
...
>>> class BatchRap(RexsterApplicationProvider):
... pass
...
>>> batch_resource = BatchResource(BatchRap())
@espeed
espeed / gist:1297366
Created October 19, 2011 02:49
Python ZeroMQ Device Blocking -- Why?
# SOLVED, thanks to Chuck Remes -- I was using zmq.QUEUE instead of zmq.STREAMER
pd = ProcessDevice(zmq.STREAMER, zmq.PUSH, zmq.PULL)
pd.bind_in("tcp://127.0.0.1:6000")
pd.bind_out("tcp://127.0.0.1:6001")
pd.start()
def client():
context = zmq.Context()
socket = context.socket(zmq.PUSH)
@espeed
espeed / device.py
Created October 20, 2011 19:32
Python ZeroMQ Streamer Device
import time
import zmq
from zmq.devices.basedevice import ProcessDevice
from multiprocessing import Process, Pool
def create_socket(socket_type,uri):
context = zmq.Context()
socket = context.socket(socket_type)
socket.connect(uri)