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
{"muxer"=>{"__content__"=>"mp4"}, "filters"=>{"scale_width"=>{"__content__"=>"640"}, "scale_height"=>{"__content__"=>"480"}, "frame_rate"=>{"__content__"=>"30.00"}}, "codecs"=>{"codec"=>[{"name"=>{"__content__"=>"H264"}, "bit_rate"=>{"__content__"=>"1200000"}}, {"name"=>{"__content__"=>"AAC"}, "bit_rate"=>{"__content__"=>"128000"}, "channels"=>{"__content__"=>"2"}}]}} | |
# I want to convert the above into | |
{"muxer"=> {"mp4"}, "filters"=> {"scale_width"=> "640", "scale_height"=> "480", "scale_frate_rate"=> "30.00"}, "codecs"=> {"codec"=>[{"name" => "H264", "bit_rate" => "1200000"},{"name" => "AAC","bit_rate" => "128000","channels" => "2"}]}} | |
# Essentially remove the "__content__" place holders. |
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
ActiveResource::Formats::XmlFormat.decode("<a><b></b></a>") | |
=> {"b"=>nil} | |
# Is there any way to to change the xml, such that, we could yeild the following: {"b"=>""} |
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 A < ActiveResource::Base ; end | |
A.site | |
=> nil | |
A.format | |
=> ActiveResource::Formats::XmlFormat | |
ActiveResource::Base.site = "http://abc123.com/" | |
=> "http://abc123.com/" | |
A.site |
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 primary_key(table_name) | |
identity_column(table_name).try(:name) || columns(table_name).first.try(:name) | |
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
CONFIRMATIONS = ["y","yes","sure","yup","why not"] | |
def get_list_of_names | |
puts "Please enter a list of words (one,two,three...):" | |
input = gets.chomp.downcase | |
input.split(",") | |
end | |
def sanitize(names_array) | |
names_array = names_array.uniq | |
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
array1 = [1, 2, 3, 4] | |
array2 = %w{peter piper picked peppers} | |
array3 = [] | |
# You need to write some code in this part | |
# to make the program output "Success" | |
array3 = array1.collect{|i| i.to_s}.zip(array2).flatten | |
if array3 == ['1', 'peter', '2', 'piper', '3', 'picked', '4', 'peppers'] | |
puts "Success" |
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 numeric?(object) | |
true if Float(object) rescue false | |
end | |
def get_user_response(message, validate_is_number = true) | |
valid = false | |
input = nil | |
loop do | |
puts message | |
input = gets.chomp | |
if validate_is_number |
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
# Nirmit Patel | |
MAX_NUMBER = 100 | |
MIN_NUMBER = 1 | |
MAX_NUMBER_OF_GUESSES = 8 | |
computers_number = rand(MAX_NUMBER - MIN_NUMBER + 1) + MIN_NUMBER | |
puts "Hello player. What is your name?" | |
name = gets | |
name = name.chomp |
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
Started POST "/login.xml" for 127.0.0.1 at 2011-01-07 15:17:10 -0800 | |
RuntimeError (route set not finalized): | |
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.7ms) | |
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.6ms) | |
Rendered /usr/local/lib/ruby/gems/1.9.1/gems/actionpack-3.0.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (12.2ms) |
NewerOlder