Skip to content

Instantly share code, notes, and snippets.

View nlacasse's full-sized avatar

Nicolas Lacasse nlacasse

  • Los Angeles, CA
View GitHub Profile
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));
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"
@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.

@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 / 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();
spire.subscribe('spire.io chat example', {orderBy: 'asc'}, function (messages) {
// We want the oldest message at the top.
messages.reverse();
$(messages).each(function(i, rawMessage){
var message = rawMessage.content
, date = new Date(rawMessage.timestamp)
, mentionedRegex = new RegExp([ '(^|\\s|\\t)'
, currentUser
, '(\\s|\\t|:|-|,|$)'
].join(''), 'gi')
@nlacasse
nlacasse / htmlindex.html
Created January 19, 2012 01:54
simple chat example using spire.io.js library
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>CHAT</title>
<script src="/javascripts/lib/jquery.js"></script>
<script src="/javascripts/lib/jquery.scrollto.js"></script>
<script id="message" type="text/html">
<div class="message {{ type }}" id="{{ cssID }}">
<time datetime="{{ time }}">{{ humanTime }}</time>
<span class="name {{#isYou}} current-user {{/isYou}}">
{{ author }}:
</span>
<span class="body">{{ content }}</span>
@nlacasse
nlacasse / gist:730937
Created December 6, 2010 20:59
asyncFor(each)
exports.asyncFor = function (start, end, eachCallback, endCallback) {
var helper = function (i) {
if (i >= end) {
return process.nextTick(function () {endCallback();});
}
eachCallback(i);
process.nextTick(function () {helper (i+1);});
};
return helper(start);
@nlacasse
nlacasse / gist:730882
Created December 6, 2010 20:21
walnuts
var jerk = require('jerk');
var options = {
server: 'iriecycle.net',
port: 6600,
nick: 'walnuts',
user: {
username: 'walnuts',
hostname: 'walnuts',
realname: 'walnuts',