Skip to content

Instantly share code, notes, and snippets.

View sbusso's full-sized avatar
🤖
Crafting with AI friends

Stéphane Busso sbusso

🤖
Crafting with AI friends
View GitHub Profile
require 'rubygems'
require 'eventmachine'
require 'em-http' # gem install em-http-request
require 'yajl' # gem install yajl-ruby
module ChatClient
def post_init
@name = "anonymous_#{ChatClient.client_num+=1}"
@sid = ChatClient.channel.subscribe(method(:send_msg))
@buf = ''
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
<!-- This is a Node+WebSocket powered demo to sync videos
across different browsers. This file is the client,
the other one is the Node server. Powered by Node and
http://github.com/miksago/node-websocket-server -->
<style>
.inactive { display: none; }
.active { display: block; }
</style>
<script>
generators = []
puts 'Spinning up a new app, captain!'
devise = yes?('Use Devise? (yes/no)')
jquery = yes?('Use jQuery? (yes/no)')
jquery_ui = yes?('Use jQuery UI? (yes/no)') if jquery
mongoid = yes?('Use mongoid? (yes/no)')
haml = yes?('Use haml? (yes/no)')
rspec = yes?('Use Rspec? (yes/no)')
@sbusso
sbusso / Redis_Pubsub_Client.rb
Created March 31, 2011 19:07 — forked from gautamrege/Redis_Pubsub_Client.rb
Redis Pubsub Client
require 'redis'
require 'multi_json'
class PubSubRedis < Redis
def initialize(options = {})
@timestamp = options[:timestamp].to_i || 0 # 0 means -- no backlog needed
super
end
@sbusso
sbusso / client.js
Created April 28, 2011 10:42 — forked from bcg/client.js
Node + ZeroMQ + Redis
var zmq = require('zeromq');
s = zmq.createSocket('push');
s.connect('tcp://127.0.0.1:15000');
while (true) { // ZOMG he did it again!
s.send(new Buffer("test"));
}
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@sbusso
sbusso / asshole.js
Created May 25, 2011 07:29 — forked from Kilian/annoying.js
How to be an asshole
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php
*
*/
@sbusso
sbusso / .gitignore
Created May 29, 2011 20:17 — forked from karmi/.gitignore
Import your Gmail messages into ElasticSearch and search them with a simple web application.
.DS_Store
*.log
Gemfile.lock
@sbusso
sbusso / gist:1564031
Created January 5, 2012 06:37 — forked from dalibor/gist:1534053
Stop words fr
d'un
à propos
ci-dessus
travers
après
suite
nouveau
contre
tous les
presque