This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'syslog' | |
| def log(message, level = :warning) | |
| script_name = $0 | |
| syslog_option = Syslog::LOG_PID | Syslog::LOG_CONS | |
| Syslog.open($0, syslog_option) do |s| | |
| s.send(level, message) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # Raffle script. Uses Launchbar and Applescript | |
| # CSV file of attendees was downloaded from EventWax (http://www.eventwax.com/). It needs 2 returns to continue the raffle | |
| # - one to bring focus back to the terminal. | |
| require 'rubygems' | |
| require 'appscript' | |
| require 'yaml' | |
| require 'fastercsv' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if plist['CFBundleVersion'].to_s =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ | |
| #do something | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require "osx/cocoa" | |
| plist = OSX::NSDictionary.dictionaryWithContentsOfFile("Info.plist") | |
| plist['CFBundleVersion'] = "2.0.0" | |
| plist.writeToFile_atomically("Info.plist",true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def raise_riddle_exception_in_template | |
| render :inline => "<%= raise Riddle::ConnectionError %>" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActionController::Routing::Routes.draw do |map| | |
| map.connect "/rescue/:action.:format", :controller => "rescue" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_rescue_handler | |
| get :not_authorized | |
| assert_response :forbidden | |
| end | |
| def test_rescue_handler_string | |
| get :not_authorized_raise_as_string | |
| assert_response :forbidden | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_rescue_handler | |
| get :not_authorized | |
| assert_response :forbidden | |
| end | |
| def test_rescue_handler_string | |
| get :not_authorized_raise_as_string | |
| assert_response :forbidden | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # actionpack-2.3.4/test/controller/rescue_test.rb | |
| # Removed code for simplicity | |
| class RescueController < ActionController::Base | |
| # Omitted the exception declarations such as NotAuthorized | |
| def method_not_allowed | |
| raise ActionController::MethodNotAllowed.new(:get, :head, :put) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def set_all_requests_local | |
| RescueController.consider_all_requests_local = true | |
| @request.remote_addr = '1.2.3.4' | |
| @request.host = 'example.com' | |
| end |