start new:
tmux
start new with session name:
tmux new -s myname
| class Player | |
| attr_accessor :warrior | |
| def initialize | |
| @old_health = 20 | |
| end | |
| def play_turn(warrior) | |
| @warrior = warrior |
| var geocoder = new google.maps.Geocoder(); | |
| $("#address").autocomplete({ | |
| //This bit uses the geocoder to fetch address values | |
| source: function(request, response) { | |
| geocoder.geocode( {'address': request.term }, function(results, status) { | |
| response($.map(results, function(item) { | |
| return { | |
| label: item.formatted_address, | |
| value: item.formatted_address, |
| <% flash.each do |type, message| %> | |
| <div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
| <button class="close" data-dismiss="alert">×</button> | |
| <%= message %> | |
| </div> | |
| <% end %> |
| #!/usr/bin/env ruby | |
| # | |
| # Before we start, make sure you have Essex support in Fog | |
| # | |
| # Essex support has not been merged into upstream Fog so you'll need | |
| # a custom ruby fog build to run through the examples | |
| # | |
| require 'fog' | |
| require 'pp' | |
| require 'highline/import' |
| // Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible). | |
| // Tweak the makePrettyJSON_ function to customize what kind of JSON to export. | |
| var FORMAT_ONELINE = 'One-line'; | |
| var FORMAT_MULTILINE = 'Multi-line'; | |
| var FORMAT_PRETTY = 'Pretty'; | |
| var LANGUAGE_JS = 'JavaScript'; | |
| var LANGUAGE_PYTHON = 'Python'; |
| def screenshot | |
| require 'capybara/util/save_and_open_page' | |
| now = Time.now | |
| p = "/#{now.strftime('%Y-%m-%d-%H-%M-%S')}-#{rand}" | |
| Capybara.save_page body, "#{p}.html" | |
| path = Rails.root.join("#{Capybara.save_and_open_page_path}" "#{p}.png").to_s | |
| page.driver.render path | |
| Launchy.open path | |
| end |
The normal controller/view flow is to display a view template corresponding to the current controller action, but sometimes we want to change that. We use render in a controller when we want to respond within the current request, and redirect_to when we want to spawn a new request.
The render method is very overloaded in Rails. Most developers encounter it within the view template, using render :partial => 'form' or render @post.comments, but here we'll focus on usage within the controller.
| def subscription_state_change | |
| begin | |
| account = Account.find(@subscription.customer.reference) | |
| account.subscription_state = @subscription.state | |
| account.subscription_billing_date = @subscription.current_period_ends_at | |
| account.save(:validate => false) | |
| render :nothing => true, :status => 200 | |
| rescue Exception => e | |
| notify_hoptoad(e) #If you use hoptoad... | |
| render :nothing => true, :status => 422 and return |