Get it from the App Store.
In XCode's Preferences > Downloads you can install command line tools.
| # 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 | |
| # |
| require 'sinatra/base' | |
| require 'eventmachine' | |
| require 'thin' | |
| EventMachine.run do | |
| class Dude < Sinatra::Base | |
| get '/' do | |
| 'oh hai' | |
| end |
| def run_in_background(&block) | |
| Process.fork do | |
| Process.fork do | |
| puts "Launching Background Process" | |
| Daemons.call &block | |
| puts "Background Process has been Launched" | |
| end | |
| exit | |
| end | |
| end |
| set :uid => "123" | |
| set :token => "kljkl26adFGGHHklfha77676sdHHTYklfj" | |
| use OmniAuth::Builder do | |
| provider :twitter, 'XXX', 'XXXX' | |
| end | |
| helpers do | |
| def admin? | |
| session[ settings.uid ] == settings.token |
| #!/usr/bin/env rackup | |
| # encoding: utf-8 | |
| # This file can be used to start Padrino, | |
| # just execute it from the command line. | |
| require File.expand_path("../config/boot.rb", __FILE__) | |
| require File.join(PADRINO_ROOT, "app/sockets.rb") | |
| map "/sockets" do |
| #!/usr/bin/env ruby | |
| # == Synopsis | |
| # This is a sample description of the application. | |
| # Blah blah blah. | |
| # | |
| # == Examples | |
| # This command does blah blah blah. | |
| # ruby_cl_skeleton foo.txt | |
| # |
| namespace :deploy do | |
| desc "Hot-reload God configuration for the Resque worker" | |
| task :reload_god_config do | |
| sudo "god stop resque" | |
| sudo "god load #{File.join(deploy_to, 'current', 'config', 'resque-' + rails_env + '.god')}" | |
| sudo "god start resque" | |
| end | |
| end | |
| # append to the bottom: |
| # coding: utf-8 | |
| require 'sinatra' | |
| set server: 'thin', connections: [] | |
| get '/' do | |
| halt erb(:login) unless params[:user] | |
| erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
| end | |
| get '/stream', provides: 'text/event-stream' do |
| # Usage: redis-cli publish message.achannel hello | |
| require 'sinatra' | |
| require 'redis' | |
| conns = Hash.new {|h, k| h[k] = [] } | |
| Thread.abort_on_exception = true | |
| get '/' do |