Ruby - Command line Currency converter
#!/usr/bin/env ruby -w unless ARGV.length == 3 puts "\tUsage :\n\t\t#{File.basename($0)} 100 eur usd" exit end require 'ubygems' require 'open-uri' require 'hpricot' url = "http:// ...
View ArticleRuby - conversor,sumar 3 numeros y mayor de edad
def mayorDeEdad(anios) if anios >= 18 puts " ¡Qué mayor!" else puts " ¡Aun no eres mayor de edad!" end end puts " ¿Cuantos anios tienes?" anios = gets.chomp.to_i ...
View ArticleRuby - Juego_edad
intentos = 0 puts "Soy el hombre más sabio del mundo y te propongo que aciertes mi edad." puts "Es entre el 1 y los 100 años , tienes 10 intentos" secreto = rand(100) while (intentos< ...
View ArticleRuby - Ruby: Open a file, write to it, and close it in one line
File.open(local_filename, 'w') {|f| f.write(doc ...
View ArticleRuby - Rake Tasks 2
Here are some handy rake tasks you may not be aware of and a quick description of what they do: Database tasks rake db:create � Will create a database to the settings defined in ...
View ArticleRuby - LETRICAS (EMILIO)
puts "EEEEEEEEE MMMMM MMMMM IIII LL IIII OOOO " puts "EE MM MM MM MM II LL II OO OO " puts "EE MM ...
View ArticleRuby - Regular Expression to Create URL Permutations in Ruby
# return 4 urls, with and without trailing slash, with and without www # useful for matching urls passed as params into some function, # "does this url exist?"... need to make sure you check ...
View ArticleRuby - Ruby One-liner for Restoring One Table from a Huge SQL Dump
ruby -ne '@found=true if $_ =~ /^CREATE TABLE `foo`/i; next unless @found; exit if $_ =~ /^CREATE TABLE (?!`foo`)/i; puts $_;' giant_sql_dump.sql > foo.sql ...
View ArticleRuby - concentration studios 12 Days of Stupid Ruby Tricks
class Array def shuffle n = [] while !empty? n > [1,2,3,4,5].shuffle => [2, 4, 5, 1, 3 ...
View ArticleRuby - trivia
puts "escribe tu nombre" nombre = gets.chomp puts "tu nombre es #{nombre}" puts "¿que numero estoy pensando del uno al diez?" respuesta = gets.chomp respuesta_correcta= "3" puntos ...
View ArticleRuby - otraprueba
def imprimir_menu puts"bienbenido a la calculadora mundial" puts"1.-sumar" puts"2.-restar" puts"3.-multiplicar" puts"4.-dividir" end imprimir_menu puts"elige opcion" ...
View ArticleRuby - Remote Form Tag
{:controller => "controller_name", :action => "action_name"}, :update => {:success => '', :failure => 'ErrorDiv'}, :loading => "Element.show('spinner');", :failure => "", :success...
View ArticleRuby - Test Script
print "What is your first name?: " f_name = gets.chomp print "What is your last name?: " l_name = gets.chomp print f_name + " " + l_name ...
View ArticleRuby - calculadora
usuario_correcto = "cecilia" clave_correcto = "harrypotter" puts "introduce tu nombre de usuario" usuario = gets.chomp while (usuario != usuario_correcto) do puts "ladron deja de husmear en ...
View ArticleRuby - Calculate Standard Deviation in Ruby
#!/usr/bin/ruby -w include Math #Data we are going to calculate stdev arrValues = [ 4.58, 4.53, 4.1, 4.05 ] fMedian = 0 arrValues.each do |fValue| fMedian += fValue end fMedian /= arrValues. ...
View ArticleRuby - Pinguin witch different charcters THe besto work
puts"--------" puts" @ @ " puts" *" puts" +++" puts"--------" puts "mmmmmmm" puts " O . O " puts " U " puts " ...
View ArticleRuby - adivina el numero
secreto = rand(20) puts "introduce tu nombre" nombre = gets.chomp intentos = 1 puts "soy gomis y tengo un numero del 0 al 20 numero hasta ...
View ArticleRuby - Twitter notifier for CruiseControl.rb
gem "twitter4r", ">=0.3.0" require "twitter" require "time" class TwitterNotifier attr_writer :login, :password def initialize(project) @project = project Twitter::Client. ...
View ArticleRuby - Post Data From Ruby
uri = URI.parse(url) req = Net::HTTP::Post.new(url) req.set_form_data({ \'field\' => \'value\' }) res = Net::HTTP.new(uri.host, uri.port).start { |http| http.request(req ...
View Article