Skip to content

Instantly share code, notes, and snippets.

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
#!/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'
if plist['CFBundleVersion'].to_s =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
#do something
end
#!/usr/bin/env ruby
require "osx/cocoa"
plist = OSX::NSDictionary.dictionaryWithContentsOfFile("Info.plist")
plist['CFBundleVersion'] = "2.0.0"
plist.writeToFile_atomically("Info.plist",true)
def raise_riddle_exception_in_template
render :inline => "<%= raise Riddle::ConnectionError %>"
end
ActionController::Routing::Routes.draw do |map|
map.connect "/rescue/:action.:format", :controller => "rescue"
end
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
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
# 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
def set_all_requests_local
RescueController.consider_all_requests_local = true
@request.remote_addr = '1.2.3.4'
@request.host = 'example.com'
end