convert between characters and values
?a # => 97 ?\n # => 10
// string to integer: use []
'a'[0] # => 97 'hallo'[1] # => 97
// integer / number to character: use .chr
97.chr # => "a" 10.chr # => "\n"
//more info: "Ruby Cookbook", O'Reilly
11308 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Oliver Haag www.ohcon.de
?a # => 97 ?\n # => 10
'a'[0] # => 97 'hallo'[1] # => 97
97.chr # => "a" 10.chr # => "\n"
<div class="row">
<dl>
<dt>Owner over 18?</dt>
<dd>
<%= radio_button( :guarantor, :over_eighteen.to_s, true )%> Yes
<%= radio_button( :guarantor, :over_eighteen, false )%> No
</dd>
</dl>
</div>
@property = property_type.camelize.constantize.new(params[:property])
<natures> <nature>org.radrails.rails.ui.railsnature</nature> <nature>org.rubypeople.rdt.core.rubynature</nature> </natures>
<buildSpec> <buildCommand> <name>org.rubypeople.rdt.core.rubybuilder</name> <arguments> </arguments> </buildCommand> </buildSpec>
<% page = request.request_uri %> page: <%= page %>
<% page = "/" + request.path_parameters['controller'] + "/" + request.path_parameters['action'] %> page: <%= page %>
rails projectname
ruby script/generate migration migration_name ruby script/generate migration add_price
ruby script/generate model model_name ruby script/generate model user name:string hashed_password:string salt:string
ruby script/generate controller controller_name method_name(s) ruby script/generate controller store index
ruby script/generate scaffold model_name controller_name ruby script/generate scaffold product admin
class ChunkList .. def [](chunk_id) @internal_id_hash[chunk_id] end end
class Singleton private_class_method :new @@singleton = nil def Singleton.create @@singleton = new unless @@singleton @@singleton end end
class Counter def initialize() @characters = Hash.new(0) end def read() @text = IO.read("text.txt") end def count_chars @text.each_byte do |ch| @characters[ch] +=1 end end def report @characters.each do |key, value| puts "#{key.chr} (#{key}) occurs #{value} times" end end end
count = Counter.new() count.read count.count_chars count.report
<style type="text/css"> <!-- option[value=ohcon]:before { content:url("ohc.gif"); } option[value=baerlin]:before { content:url("baer.gif"); } option[value=zendo]:before { content:url("zendo.gif"); } --> </style> .. Select Company <select> <option value="ohcon">Oliver Haag IT consulting</option> <option value="baerlin">Bärlin Partners</option> <option value="zendo">Zendo-Marketing</option> </select>