Skip to content

Instantly share code, notes, and snippets.

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
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|
def set(reg: Reg, literal: byte): Code = {
return new Code() {
// implementation
}
}
// non-id/name attributes are interpreted as cdata
// per: http://www.w3.org/TR/html4/types.html#type-cdata
var s = "<p title=\"&lt;script&gt;alert('TEST')&lt;/script&gt;\">testing 123</p>";
document.body.innerHTML = s;
document.getElementsByTagName('p')[0].getAttribute('title');
// => "<script>alert('TEST')</script>"
document.getElementsByTagName('p')[0].title;
// => "<script>alert('TEST')</script>"

d3.unconf example gist. Fork it here.