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 / javascriptsjoin-chat-form-submission.js
Created February 22, 2012 01:43
Initial form of the chat to write your nick
// ## The Initial Overlay Form
//
// The overlay form will be the first thing a person sees when running this
// example, it will ask for the name they will want to use for the chat
// session. After submitting the name a `join` message will be sent and the
// the overlay will be hidden.
$('.overlay form').submit(function(event){
event.stopPropagation();
event.preventDefault();
@nlacasse
nlacasse / javascriptsnew-message-submission.js
Created February 22, 2012 01:44
Form to write your messages
// The footer form is what handles the actual messages going to everyone in
// the room. Anything a person types and submits into the form will be
// displayed to everyone in the room.
$('footer form').submit(function(event){
event.stopPropagation();
event.preventDefault();
var form = this
, message = { author: currentUser
, body: $(form).find('input[name="content"]').val()
@nlacasse
nlacasse / forever.md
Created February 24, 2012 21:00
Forever A Node

Forever A Node

Say you've just had a great idea for a new web app. An app that's never been done before. An app that will improve the quality of life of millions of people. An app that will make you rich and famous.

You spend the weekend coding like crazy, and at 4:30am Monday morning, you have something that runs, barely. Most of the bad crashes are fixed, but you still see some weird bugs every once in a while. You're too sleepy to debug these issues now, but every second that your app isn't online is an opportunity for somebody else to snatch up your great idea.

shred.post({
url: description.resources.session.resources.channels.url,
headers: {
accept: description.schema["1.0"].channel.mediaType,
content_type: description.schema["1.0"].channel.mediaType,
authorization: "Capability " +
description.resources.session.resources.channels.capabilities.create
},
content: {
name: "foo"
TaskManager.prototype.handle = function(result) {
var emitter, emitters, task_id, tm, _results;
tm = this;
if (result.identifier) {
if ((emitters = this.matchatron.take(result))) {
_results = [];
for (task_id in emitters) {
emitter = emitters[task_id];
if (result.error) {
_results.push(emitter.emit("error", result.error, result));
@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.

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 / 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:
@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: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)