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
## BAD 1 | |
# | |
# => <p><select label="Language" name="lang"><option val... rather than <label...><select> | |
%p= text_field :title, :label => "Title" | |
%p= select :name => 'lang', :collection => @lang_opts, :label => 'Language' | |
%p= text_area :code, :label => "Code" | |
%p= text_area :explanation, :label => "Explanation (markdown)" | |
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 Merb::BootLoader::MethodLogger < Merb::BootLoader | |
before Logger | |
def self.run | |
# do things | |
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
<script type="text/javascript"> | |
$(document).ready(function(){ | |
// Your code here | |
function councilFocus() | |
{ | |
$("#council_image").hide("fast"); | |
$("#nav1council").css("position", "relative"); | |
$("#lnkAbout").css("position", "relative"); |
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
match(:subdomains => /(.*)/).to(:controller => ":subdomains[1]") |
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
match('/').defer_to do |request, params| | |
sd = request.subdomains.first.capitalize | |
if Object.const_defined? sd | |
redirect url(:controller => sd.downcase) | |
else | |
false | |
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 Exceptions < Application | |
# handle RecordInvalid exceptions (406) | |
def record_invalid | |
@errors = request.exceptions.first.errors | |
rename_error_fields! | |
if content_type == :html | |
render {:template => "#{request.controller}/#{request.params[:action]}"} | |
else | |
render |
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
define_builder(Page) do |klass, overrides| | |
klass.new(:page_title => "foo.com", :page_id => 123) | |
end | |
define_builder(Summary) do |klass, overrides| | |
klass.new(:page_id => new_page.page_id, :user => new_user, :summary => "foobar") | |
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
define_builder(Country) do |klass, overrides| | |
# set up some presets | |
canada = { :iso => 'CA', :name => 'CANADA', :printable_name => 'Canada', :iso3 => 'CAN', :numcode => '124'} | |
usa = { :iso => 'US', :name => 'UNITED STATES', :printable_name => 'United States', :iso3 => 'USA', :numcode => '840' } | |
uk = { :iso => 'GB', :name => 'UNITED KINGDOM', :printable_name => 'United Kingdom', :iso3 => 'GBR', :numcode => '826' } | |
zimbabwe = { :iso => 'ZW', :name => 'ZIMBABWE', :printable_name => 'Zimbabwe', :iso3 => 'ZWE', :numcode => '716' } | |
# set up the default | |
country_attributes = canada | |
# check for a preset | |
overrides.process(:preset) do |preset| |
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 'rubygems' | |
require 'gchart' | |
data = <<HERE | |
Net::HTTPServerException: 14 | |
ActiveRecord::StatementInvalid: 126 | |
no_data: 27814 | |
Errno::EPIPE: 4 | |
ScalaNet::UnknownHostException: 100359 | |
EOFError: 9498 |
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 set(reg: Reg, literal: byte): Code = { | |
return new Code() { | |
// implementation | |
} | |
} |
OlderNewer