This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new_object = OtherDatabase::NewClass1.new | |
... | |
result = OtherDatabase::NewClass1.find(:all) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rake task to export comments from typo to disqus | |
require 'disqus' | |
require 'disqus/api' | |
require 'disqus/author' | |
require 'disqus/forum' | |
require 'disqus/post' | |
require 'disqus/thread' | |
namespace :export do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Stephane Busso based Toby DiPasquale <toby@cbcg.net> Jekyll import and other disqus import | |
require 'fileutils' | |
require 'rubygems' | |
require 'sequel' | |
require 'rake' | |
namespace :import | |
desc "import posts" | |
task :post do | |
# this SQL *should* work for both MySQL and PostgreSQL, but I haven't |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install redis | |
# cp file /etc/redis/redis.conf | |
# create file /etc/init.d/redis | |
# create user and group redis | |
$ sudo update-rc.d redis | |
bundle exec resque-web -e production -s thin -L config/initializers/resque.rb | |
bundle exec resque-web -K | |
rake resque:scheduler INITIALIZER_PATH=config/initializers/resque.rb | |
QUEUE=cron rake environment resque:work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Resque | |
module AsyncJob | |
@@_queue= :default | |
def self.included(base) | |
base.extend(ClassMethods) | |
end | |
module ClassMethods | |
# Set the default queue. chain method | |
def queue(new_queue = nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redis' | |
require 'multi_json' | |
class PubSubRedis < Redis | |
def initialize(options = {}) | |
@timestamp = options[:timestamp].to_i || 0 # 0 means -- no backlog needed | |
super | |
end |
OlderNewer