Permalink
Browse files

adding revised episode 150

  • Loading branch information...
1 parent 3d2876f commit 1a06debf811474a53ec6ffc2a659b919f673dc87 @ryanb committed Jan 27, 2012
Showing with 1,568 additions and 0 deletions.
  1. +12 −0 episode-150/revised/README
  2. +15 −0 episode-150/revised/processes-after/.gitignore
  3. +38 −0 episode-150/revised/processes-after/Gemfile
  4. +111 −0 episode-150/revised/processes-after/Gemfile.lock
  5. +9 −0 episode-150/revised/processes-after/README.rdoc
  6. +7 −0 episode-150/revised/processes-after/Rakefile
  7. BIN episode-150/revised/processes-after/app/assets/images/rails.png
  8. +15 −0 episode-150/revised/processes-after/app/assets/javascripts/application.js
  9. +9 −0 episode-150/revised/processes-after/app/assets/javascripts/processes.js.coffee
  10. +87 −0 episode-150/revised/processes-after/app/assets/stylesheets/application.css
  11. +3 −0 episode-150/revised/processes-after/app/assets/stylesheets/processes.css.scss
  12. +3 −0 episode-150/revised/processes-after/app/controllers/application_controller.rb
  13. +8 −0 episode-150/revised/processes-after/app/controllers/processes_controller.rb
  14. +2 −0 episode-150/revised/processes-after/app/helpers/application_helper.rb
  15. +2 −0 episode-150/revised/processes-after/app/helpers/processes_helper.rb
  16. 0 episode-150/revised/processes-after/app/mailers/.gitkeep
  17. +14 −0 episode-150/revised/processes-after/app/middleware/processes_list.rb
  18. 0 episode-150/revised/processes-after/app/models/.gitkeep
  19. +18 −0 episode-150/revised/processes-after/app/views/layouts/application.html.erb
  20. +3 −0 episode-150/revised/processes-after/app/views/processes/index.html.erb
  21. +4 −0 episode-150/revised/processes-after/config.ru
  22. +61 −0 episode-150/revised/processes-after/config/application.rb
  23. +6 −0 episode-150/revised/processes-after/config/boot.rb
  24. +25 −0 episode-150/revised/processes-after/config/database.yml
  25. +5 −0 episode-150/revised/processes-after/config/environment.rb
  26. +37 −0 episode-150/revised/processes-after/config/environments/development.rb
  27. +67 −0 episode-150/revised/processes-after/config/environments/production.rb
  28. +37 −0 episode-150/revised/processes-after/config/environments/test.rb
  29. +7 −0 episode-150/revised/processes-after/config/initializers/backtrace_silencers.rb
  30. +15 −0 episode-150/revised/processes-after/config/initializers/inflections.rb
  31. +5 −0 episode-150/revised/processes-after/config/initializers/mime_types.rb
  32. +7 −0 episode-150/revised/processes-after/config/initializers/secret_token.rb
  33. +8 −0 episode-150/revised/processes-after/config/initializers/session_store.rb
  34. +14 −0 episode-150/revised/processes-after/config/initializers/wrap_parameters.rb
  35. +5 −0 episode-150/revised/processes-after/config/locales/en.yml
  36. +4 −0 episode-150/revised/processes-after/config/routes.rb
  37. +7 −0 episode-150/revised/processes-after/db/seeds.rb
  38. +2 −0 episode-150/revised/processes-after/doc/README_FOR_APP
  39. 0 episode-150/revised/processes-after/lib/assets/.gitkeep
  40. 0 episode-150/revised/processes-after/lib/tasks/.gitkeep
  41. 0 episode-150/revised/processes-after/log/.gitkeep
  42. +26 −0 episode-150/revised/processes-after/public/404.html
  43. +26 −0 episode-150/revised/processes-after/public/422.html
  44. +25 −0 episode-150/revised/processes-after/public/500.html
  45. 0 episode-150/revised/processes-after/public/favicon.ico
  46. +5 −0 episode-150/revised/processes-after/public/robots.txt
  47. +6 −0 episode-150/revised/processes-after/script/rails
  48. 0 episode-150/revised/processes-after/test/fixtures/.gitkeep
  49. 0 episode-150/revised/processes-after/test/functional/.gitkeep
  50. +9 −0 episode-150/revised/processes-after/test/functional/processes_controller_test.rb
  51. 0 episode-150/revised/processes-after/test/integration/.gitkeep
  52. +12 −0 episode-150/revised/processes-after/test/performance/browsing_test.rb
  53. +13 −0 episode-150/revised/processes-after/test/test_helper.rb
  54. 0 episode-150/revised/processes-after/test/unit/.gitkeep
  55. +4 −0 episode-150/revised/processes-after/test/unit/helpers/processes_helper_test.rb
  56. 0 episode-150/revised/processes-after/vendor/assets/javascripts/.gitkeep
  57. 0 episode-150/revised/processes-after/vendor/assets/stylesheets/.gitkeep
  58. 0 episode-150/revised/processes-after/vendor/plugins/.gitkeep
  59. +15 −0 episode-150/revised/processes-before/.gitignore
  60. +38 −0 episode-150/revised/processes-before/Gemfile
  61. +111 −0 episode-150/revised/processes-before/Gemfile.lock
  62. +9 −0 episode-150/revised/processes-before/README.rdoc
  63. +7 −0 episode-150/revised/processes-before/Rakefile
  64. BIN episode-150/revised/processes-before/app/assets/images/rails.png
  65. +15 −0 episode-150/revised/processes-before/app/assets/javascripts/application.js
  66. +9 −0 episode-150/revised/processes-before/app/assets/javascripts/processes.js.coffee
  67. +87 −0 episode-150/revised/processes-before/app/assets/stylesheets/application.css
  68. +3 −0 episode-150/revised/processes-before/app/assets/stylesheets/processes.css.scss
  69. +3 −0 episode-150/revised/processes-before/app/controllers/application_controller.rb
  70. +8 −0 episode-150/revised/processes-before/app/controllers/processes_controller.rb
  71. +2 −0 episode-150/revised/processes-before/app/helpers/application_helper.rb
  72. +2 −0 episode-150/revised/processes-before/app/helpers/processes_helper.rb
  73. 0 episode-150/revised/processes-before/app/mailers/.gitkeep
  74. 0 episode-150/revised/processes-before/app/models/.gitkeep
  75. +18 −0 episode-150/revised/processes-before/app/views/layouts/application.html.erb
  76. +3 −0 episode-150/revised/processes-before/app/views/processes/index.html.erb
  77. +4 −0 episode-150/revised/processes-before/config.ru
  78. +59 −0 episode-150/revised/processes-before/config/application.rb
  79. +6 −0 episode-150/revised/processes-before/config/boot.rb
  80. +25 −0 episode-150/revised/processes-before/config/database.yml
  81. +5 −0 episode-150/revised/processes-before/config/environment.rb
  82. +37 −0 episode-150/revised/processes-before/config/environments/development.rb
  83. +67 −0 episode-150/revised/processes-before/config/environments/production.rb
  84. +37 −0 episode-150/revised/processes-before/config/environments/test.rb
  85. +7 −0 episode-150/revised/processes-before/config/initializers/backtrace_silencers.rb
  86. +15 −0 episode-150/revised/processes-before/config/initializers/inflections.rb
  87. +5 −0 episode-150/revised/processes-before/config/initializers/mime_types.rb
  88. +7 −0 episode-150/revised/processes-before/config/initializers/secret_token.rb
  89. +8 −0 episode-150/revised/processes-before/config/initializers/session_store.rb
  90. +14 −0 episode-150/revised/processes-before/config/initializers/wrap_parameters.rb
  91. +5 −0 episode-150/revised/processes-before/config/locales/en.yml
  92. +4 −0 episode-150/revised/processes-before/config/routes.rb
  93. +7 −0 episode-150/revised/processes-before/db/seeds.rb
  94. +2 −0 episode-150/revised/processes-before/doc/README_FOR_APP
  95. 0 episode-150/revised/processes-before/lib/assets/.gitkeep
  96. 0 episode-150/revised/processes-before/lib/tasks/.gitkeep
  97. 0 episode-150/revised/processes-before/log/.gitkeep
  98. +26 −0 episode-150/revised/processes-before/public/404.html
  99. +26 −0 episode-150/revised/processes-before/public/422.html
  100. +25 −0 episode-150/revised/processes-before/public/500.html
  101. 0 episode-150/revised/processes-before/public/favicon.ico
  102. +5 −0 episode-150/revised/processes-before/public/robots.txt
  103. +6 −0 episode-150/revised/processes-before/script/rails
  104. 0 episode-150/revised/processes-before/test/fixtures/.gitkeep
  105. 0 episode-150/revised/processes-before/test/functional/.gitkeep
  106. +9 −0 episode-150/revised/processes-before/test/functional/processes_controller_test.rb
  107. 0 episode-150/revised/processes-before/test/integration/.gitkeep
  108. +12 −0 episode-150/revised/processes-before/test/performance/browsing_test.rb
  109. +13 −0 episode-150/revised/processes-before/test/test_helper.rb
  110. 0 episode-150/revised/processes-before/test/unit/.gitkeep
  111. +4 −0 episode-150/revised/processes-before/test/unit/helpers/processes_helper_test.rb
  112. 0 episode-150/revised/processes-before/vendor/assets/javascripts/.gitkeep
  113. 0 episode-150/revised/processes-before/vendor/assets/stylesheets/.gitkeep
  114. 0 episode-150/revised/processes-before/vendor/plugins/.gitkeep
@@ -0,0 +1,12 @@
+Railscasts Episode #150: Rails Metal (revised)
+
+http://railscasts.com/episodes/150-rails-metal-revised
+
+Commands used in episode
+
+ rake middleware
+ rails s -e production -d
+ ab -n 100 -r http://localhost:3000/processes/old_list
+ ab -n 100 -r http://localhost:3000/processes/list
+
+Requires Ruby 1.9.2 to run code.
@@ -0,0 +1,15 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+#
+# If you find yourself ignoring temporary files generated by your text editor
+# or operating system, you probably want to add a global ignore instead:
+# git config --global core.excludesfile ~/.gitignore_global
+
+# Ignore bundler config
+/.bundle
+
+# Ignore the default SQLite database.
+/db/*.sqlite3
+
+# Ignore all logfiles and tempfiles.
+/log/*.log
+/tmp
@@ -0,0 +1,38 @@
+source 'https://rubygems.org'
+
+gem 'rails', '3.2.1'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+ gem 'sass-rails', '~> 3.2.3'
+ gem 'coffee-rails', '~> 3.2.1'
+
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+ # gem 'therubyracer'
+
+ gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+# To use ActiveModel has_secure_password
+# gem 'bcrypt-ruby', '~> 3.0.0'
+
+# To use Jbuilder templates for JSON
+# gem 'jbuilder'
+
+# Use unicorn as the web server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
@@ -0,0 +1,111 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ actionmailer (3.2.1)
+ actionpack (= 3.2.1)
+ mail (~> 2.4.0)
+ actionpack (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.1)
+ activesupport (= 3.2.1)
+ builder (~> 3.0.0)
+ activerecord (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ arel (~> 3.0.0)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.0)
+ builder (3.0.0)
+ coffee-rails (3.2.1)
+ coffee-script (>= 2.2.0)
+ railties (~> 3.2.0.beta)
+ coffee-script (2.2.0)
+ coffee-script-source
+ execjs
+ coffee-script-source (1.2.0)
+ erubis (2.7.0)
+ execjs (1.3.0)
+ multi_json (~> 1.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.1)
+ jquery-rails (2.0.0)
+ railties (>= 3.2.0.beta, < 5.0)
+ thor (~> 0.14)
+ json (1.6.5)
+ mail (2.4.1)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.0.4)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.1)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.1)
+ actionmailer (= 3.2.1)
+ actionpack (= 3.2.1)
+ activerecord (= 3.2.1)
+ activeresource (= 3.2.1)
+ activesupport (= 3.2.1)
+ bundler (~> 1.0)
+ railties (= 3.2.1)
+ railties (3.2.1)
+ actionpack (= 3.2.1)
+ activesupport (= 3.2.1)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sass (3.1.12)
+ sass-rails (3.2.3)
+ railties (~> 3.2.0.beta)
+ sass (>= 3.1.10)
+ tilt (~> 1.3)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.31)
+ uglifier (1.2.2)
+ execjs (>= 0.3.0)
+ multi_json (>= 1.0.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ coffee-rails (~> 3.2.1)
+ jquery-rails
+ rails (= 3.2.1)
+ sass-rails (~> 3.2.3)
+ sqlite3
+ uglifier (>= 1.0.3)
@@ -0,0 +1,9 @@
+= RailsCasts Example Application
+
+Run these commands to try it out.
+
+ bundle
+ rake db:setup
+ rails s
+
+Requires Ruby 1.9.2 or higher.
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Processes::Application.load_tasks
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -0,0 +1,9 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
+jQuery ->
+ if $('#processes').length
+ update = ->
+ $.get '/processes/list', (list) -> $('#processes').text(list)
+ setInterval(update, 3000)
+ update()
@@ -0,0 +1,87 @@
+/*
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= require_self
+ *= require_tree .
+*/
+
+body {
+ background-color: #4B7399;
+ font-family: Verdana, Helvetica, Arial;
+ font-size: 14px;
+}
+
+a img {
+ border: none;
+}
+
+a {
+ color: #0000FF;
+}
+
+.clear {
+ clear: both;
+ height: 0;
+ overflow: hidden;
+}
+
+#container {
+ width: 75%;
+ margin: 0 auto;
+ background-color: #FFF;
+ padding: 20px 40px;
+ border: solid 1px black;
+ margin-top: 20px;
+}
+
+#flash_notice, #flash_error, #flash_alert {
+ padding: 5px 8px;
+ margin: 10px 0;
+}
+
+#flash_notice {
+ background-color: #CFC;
+ border: solid 1px #6C6;
+}
+
+#flash_error, #flash_alert {
+ background-color: #FCC;
+ border: solid 1px #C66;
+}
+
+.fieldWithErrors {
+ display: inline;
+}
+
+.error_messages {
+ width: 400px;
+ border: 2px solid #CF0000;
+ padding: 0px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+ font-size: 12px;
+}
+
+.error_messages h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 10px;
+ font-size: 12px;
+ margin: 0;
+ background-color: #c00;
+ color: #fff;
+}
+
+form .field, form .actions {
+ margin: 12px 0;
+}
+
+label.required {
+ font-weight: bold;
+}
+
+form h2 {
+ font-size: 16px;
+ margin-top: 20px;
+}
@@ -0,0 +1,3 @@
+// Place all the styles related to the processes controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
@@ -0,0 +1,8 @@
+class ProcessesController < ApplicationController
+ def index
+ end
+
+ def list
+ render text: `ps -axcr -o 'pid,pcpu,pmem,time,comm'`
+ end
+end
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
@@ -0,0 +1,2 @@
+module ProcessesHelper
+end
@@ -0,0 +1,14 @@
+class ProcessesList
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ if env["PATH_INFO"] == "/processes/list"
+ list = `ps -axcr -o 'pid,pcpu,pmem,time,comm'`
+ [200, {"Content-Type" => "text/plain"}, [list]]
+ else
+ @app.call(env)
+ end
+ end
+end
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Processes</title>
+ <%= stylesheet_link_tag "application", media: "all" %>
+ <%= javascript_include_tag "application" %>
+ <%= csrf_meta_tag %>
+ </head>
+ <body>
+ <div id="container">
+ <% flash.each do |name, msg| %>
+ <%= content_tag :div, msg, id: "flash_#{name}" %>
+ <% end %>
+ <%= yield %>
+ <div class="clear"></div>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,3 @@
+<h1>Processes List</h1>
+
+<pre id="processes"></pre>
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run Processes::Application
Oops, something went wrong.

0 comments on commit 1a06deb

Please sign in to comment.