Skip to content

Instantly share code, notes, and snippets.

@ryanb

ryanb/commands.sh

Created Jan 19, 2013
Embed
What would you like to do?
cd ~/code/rails
railties/bin/rails new ~/code/hello --edge
cd ~/code/hello
echo "gem 'puma'" >> Gemfile
bundle
rails g controller hello index
# fill controller
puma
# separate tab
curl localhost:9292/hello/index
# separate tab
curl localhost:9292/hello/index # waits until first request finishes
class HelloController < ApplicationController
include ActionController::Live
def index
response.headers["Content-Type"] = "text/event-stream"
10.times do |n|
response.stream.write "data: #{n}...\n\n"
sleep 2
end
ensure
response.stream.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment