This file contains 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
use Rack::Bug | |
map '/my_sweet_rack_app' | |
run MySweetRackApp.new | |
end | |
map '/' | |
DenyAccessAndRecordRetinaApp.new | |
end |
This file contains 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
class MySweetRackApp | |
def initialize | |
Proc.new { |env| [200, {'Content-Type' => 'text/html'}, ['success']] } | |
end | |
end |
This file contains 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 anon_access_denied | |
respond_to do |accepts| | |
accepts.html do | |
store_location | |
redirect_to login_path | |
end | |
accepts.xml do | |
headers["Status"] = "Unauthorized" | |
headers["WWW-Authenticate"] = %(Basic realm="Web Password") | |
render :text => "Could't authenticate you", :status => '401 Unauthorized' |
This file contains 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 can_checkout_movie? | |
account_is_current? && | |
available_rental_slots? && | |
late_fees_within_limit? | |
end |
This file contains 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
#Just be careful. Safest to properly end color sequence, so instead of this | |
#export PS1="\[\033[01;32m\]\u\[\033[00m\]\[\033[01;31m\]\$(git_br)\[\033[01;32m\]\[\033[00m\]:\[\033[01;36m\]\$(git_pwd)\[\033[00m\]\$ " | |
#do this | |
USER_GREEN='\[\e[01;32m\]' | |
#NO_COLOR='\[\e[00m\]' | |
REPO_RED='\[\e[01;31m\]' | |
PATH_BLUE='\[\e[01;36m\]' | |
END_COLOR='\[\e[m\]' |
This file contains 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
#http://github.com/ahoward/open4 is an alternative that handles pid and exit status | |
#http://github.com/ahoward/session a more fleshed our shell utility | |
require 'open3' | |
Open3.popen3("dc") do |stdin, stdout, stderr| | |
t = Thread.new(stderr) do |terr| | |
while (line = terr.gets) | |
puts "stderr: #{line}" | |
end | |
end |
This file contains 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
class Wizard | |
# class << self | |
# self.class_eval do | |
# define_method :convene_council do | |
# puts "The council is in session!" | |
# end | |
# end | |
# end | |
def self.metaclass |
This file contains 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
public class HelloWorld { | |
public String hello() { | |
return "Hello cruel world"; | |
} | |
} |
This file contains 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 in config/environment.rb before init starts | |
#require 'config/add_explicit_path_to_config_gem' | |
#Rails::Initializer.run do |config| | |
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "#{RAILS_ROOT}/vendor/local_gemfiles/my_gem-0.0.1.gem" #or | |
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "http://github.com/myname/myrepo/raw/master/mygem.gem" #or | |
module Rails | |
class GemDependency < Gem::Dependency | |
def initialize(name, options = {}) | |
require 'rubygems' unless Object.const_defined?(:Gem) |
This file contains 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
#a variation of this:http://ozmm.org/posts/z_cache_bang.html | |
#def rankings | |
# @rankings ||= rankings! | |
#end | |
#def rankings! | |
# # compute expensive rankings | |
#end | |
def rankings |