Skip to content

Instantly share code, notes, and snippets.

View nlacasse's full-sized avatar

Nicolas Lacasse nlacasse

  • Los Angeles, CA
View GitHub Profile
@nlacasse
nlacasse / connect-resource-nodes.clj
Created January 25, 2013 00:37
connect resource node
(defn connect-resource-nodes!
[inserter node1 node2 label]
(let [relationship (DynamicRelationshipType/withName label)]
(.createRelationship inserter node1 node2 relationship nil)))
@nlacasse
nlacasse / insert-resource-node.clj
Created January 25, 2013 00:09
insert-resource-node
(defn insert-resource-node!
[inserter res]
(if-let [id (get @id-map res)]
; If the resource has aleady been added, just return the id.
id
; Otherwise, add the node for the node, and remember its id for later.
(let [id (.createNode inserter {"resource" res})]
(swap! id-map #(assoc! % res id))
id)))
@nlacasse
nlacasse / dbpedia.clj
Created January 24, 2013 20:35
dbpedia batch inserter
(ns opal.dbpedia
(:use [clojure.tools.logging :only [log]])
(:require [clojure.java.io :as io])
(:import [uk.ac.manchester.cs.owl.owlapi.turtle.parser TurtleParser]
[org.neo4j.unsafe.batchinsert BatchInserters
LuceneBatchInserterIndexProvider]
[org.neo4j.graphdb DynamicRelationshipType]))
;; PARSING METHODS
creeper@ip-10-196-17-120:/mnt$ head -c 1000 dbp.json
{"mode":"EXTENDED","vertices":[{"dbp-resource":{"type":"string","value":"<http://dbpedia.org/resource/Phagophobe>"},"unique-entity-id":{"type":"string","value":"7:11:<http://dbpedia.org/resource/Phagophobe>"},"_id":485247004,"_type":"vertex"},{"dbp-resource":{"type":"string","value":"<http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Volume_ray_casting.png/200px-Volume_ray_casting.png>"},"unique-entity-id":{"type":"string","value":"7:11:<http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Volume_ray_casting.png/200px-Volume_ray_casting.png>"},"_id":182663672,"_type":"vertex"},{"dbp-resource":{"type":"string","value":"<http://dbpedia.org/resource/Knesseth_Israel_(disambiguation)>"},"unique-entity-id":{"type":"string","value":"7:11:<http://dbpedia.org/resource/Knesseth_Israel_(disambiguation)>"},"_id":494210340,"_type":"vertex"},{"dbp-resource":{"type":"string","value":"<http://upload.wikimedia.org/wikipedia/commons/5/59/RamphocaenusCinereiventri
[97] nlacasse@fibonazi:~> mkdir test
[98] nlacasse@fibonazi:~> stat test
File: ‘test’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: 803h/2051d Inode: 12453533 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 1000/nlacasse) Gid: ( 100/ users)
Access: 2012-12-10 17:44:42.579933028 -0800
Modify: 2012-12-10 17:44:42.579933028 -0800
Change: 2012-12-10 17:44:42.579933028 -0800
Birth: -
@nlacasse
nlacasse / gist:4227412
Created December 6, 2012 19:18
SerializationException when reading a vertex property with type clojure.lang.PersistentVector
user=> (g/transact!
#_=> (.getProperty (v/refresh vertex) "test"))
InstantiationException clojure.lang.PersistentVector java.lang.Class.newInstance0 (Class.java:357)
user=> (print-stack-trace *e)
com.esotericsoftware.kryo.SerializationException: Unable to deserialize object of type: clojure.lang.PersistentVector
at com.esotericsoftware.kryo.Kryo.readClassAndObject (Kryo.java:571)
com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.loadRelations (StandardTitanGraph.java:322)
com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.loadRelations (StandardTitanGraph.java:275)
com.thinkaurelius.titan.graphdb.transaction.StandardPersistTitanTx.loadRelations (StandardPersistTitanTx.java:150)
@nlacasse
nlacasse / gist:4069421
Created November 14, 2012 00:38
no more transact!s in tests
diff --git a/src/hermes/vertex.clj b/src/hermes/vertex.clj
index 00920e4..111dc29 100644
--- a/src/hermes/vertex.clj
+++ b/src/hermes/vertex.clj
@@ -9,7 +9,7 @@
"Create a vertex, optionally with the given property map."
([] (create! {}))
([data]
- (set-properties! (.addVertex *graph*) data)))
+ (set-properties! (.addVertex *graph* nil) data)))
@nlacasse
nlacasse / gist:3783427
Created September 25, 2012 17:57
omni errors
[191] nlacasse@fibonazi:~/okcl/omniscience> foreman run bundle exec rspec
..............................................I, [2012-09-25T11:05:18.593617 #2656] INFO -- : 127.0.0.1:11211 failed (count: 0)
F............F
An error occurred in an after(:all) hook.
NoMethodError: private method `delete' called for nil:NilClass
occurred at /home/nlacasse/okcl/omniscience/spec/contexts/facebook.rb:15:in `block (2 levels) in <top (required)>'
...........................*..........................................
Pending:
Hi Kai,
We pushed the ETag fixes this morning. You should now see the requests to '/' come back with 304s, which your browser will handle correctly. Hopefully this will speed things up for you.
Also, I recommend that you try the newest version of spire.io.js javascript library. There were a few poorly optimized requests in there.
Here are answers to your other questions:
> 1. As far as I understand the plans, I don't pay for open connections, but
> only for messages I publish? Or does a "connection" requires bandwidth?
@nlacasse
nlacasse / sub_blog.md
Created April 12, 2012 19:10
subscriptions blog post

Keeping track of channel subscriptions

One feature request that developers often ask for is a way to tell which clients are listening for messages on a channel.

For example, a chat application needs to know what users are in each chat room at any given point in time.

Or, to take a more complex example, say you have a distributed logging setup where log data is generated by various clients and sent to multiple servers (some store the data long-term, others parse the data in real time and send alerts if necessary, etc).

Since log data is important, we would like to know which servers are currently listening for data. Furthermore, we should be notified when servers come online or go offline.