Skip to content

Instantly share code, notes, and snippets.

@mikesname
mikesname / gist:4383741
Last active December 10, 2015 04:48
Neo4j transaction handling, contrived example...
import org.neo4j.graphdb.Transaction;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph;
public class Neo4jTest {
private final String[] testData = {
"foo",
@mikesname
mikesname / gist:4383736
Last active December 10, 2015 04:48
Blueprints nested transaction handling, contrived example.
import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph;
public class BlueprintsTest {
private final String[] testData = {
"foo",
"bar",
@mikesname
mikesname / MyProxyController.scala
Created December 4, 2012 19:20
Basic web proxy with Play 2.0 - example only and not for actual use...
/**
app/controllers/MyProxyController.scala
*/
package controllers
// Basic proxying web service...
// Standard play libs - all the Scala stuff
// is in the play.api package so it doesn't
// conflict with the Java equivalents.
@mikesname
mikesname / gist:3635588
Created September 5, 2012 11:57
Create DocumentaryUnit with Repository and User params...
// Create a doc unit with a repository and a user...
// Glosses over lots of potential errors!
public void createDocumentaryUnit(Long repositoryId, Long userId,
Map<String, Object> data) throws ValidationError,
DeserializationError, PermissionDenied {
// Load the repository this collection will be part of...
Agent repo = graph.getVertex(repositoryId, Agent.class);
@mikesname
mikesname / horrible.py
Created February 20, 2012 21:11
SQLAlchemy, dynamic table creation
def init_i18n_class(cls):
"""Create, via metadata reflection, an I18N class object
for i18n-enabled tables."""
tablename = cls.__tablename__ + "_i18n"
if Base.metadata.tables.get(tablename) is not None:
classname = cls.__name__ + "I18N"
i18nt = Table(tablename, Base.metadata,
Column("id", ForeignKey("%s.id" % cls.__tablename__), primary_key=True),
Column("culture", String(25), primary_key=True),
ForeignKeyConstraint(["id"], ["%s.id" % cls.__tablename__]),