Skip to content

Instantly share code, notes, and snippets.

@ryanb
Created January 19, 2013 21:27
Show Gist options
  • Save ryanb/4575312 to your computer and use it in GitHub Desktop.
Save ryanb/4575312 to your computer and use it in GitHub Desktop.

Revisions

  1. ryanb created this gist Jan 19, 2013.
    12 changes: 12 additions & 0 deletions commands.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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
    13 changes: 13 additions & 0 deletions hello_controller.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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