Skip to content

Instantly share code, notes, and snippets.

View nickaknudson's full-sized avatar

Nick Knudson nickaknudson

View GitHub Profile
@nickaknudson
nickaknudson / application.html.haml
Created June 20, 2012 18:03
Default Rails views/layouts/application.html.erb to haml
!!!
%html
%head
%title ElectionsoftServer
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
%p.notice
= notice
@nickaknudson
nickaknudson / faye_redis_queue.js
Last active September 29, 2015 19:38
a faye hack to provide a simple message queue upon channel subscription
Faye.extend(Faye.Engine.Redis.prototype, {
subscribe: function(clientId, channel, callback, scope) {
var current_key, self;
self = this;
this._redis.sadd(this._ns + '/clients/' + clientId + '/channels', channel, function(error, added) {
if (added === 1) return self.trigger('subscribe', clientId, channel);
});
this._redis.sadd(this._ns + '/channels' + channel, clientId, function() {
self.debug('Subscribed client ? to channel ?', clientId, channel);