Quantcast
Channel: EmotiCODE - Snippets and Source Code Search Engine
Browsing all 146 articles
Browse latest View live

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 Article



Ruby - 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 Article

Ruby - 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 Article

Ruby - Ruby: Open a file, write to it, and close it in one line

File.open(local_filename, 'w') {|f| f.write(doc ...

View Article

Ruby - 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 Article


Ruby - 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 Article

Ruby - 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 Article

Ruby - Detect JRuby

if jruby = RUBY_PLATFORM =~ /\bjava\b/ require 'java' end ...

View Article


Ruby - 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 Article


Ruby - 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 Article

Ruby - 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 Article

Ruby - 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 Article

Ruby - Remote Form Tag

{:controller => "controller_name", :action => "action_name"}, :update => {:success => '', :failure => 'ErrorDiv'}, :loading => "Element.show('spinner');", :failure => "", :success...

View Article


Ruby - 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 Article

Ruby - 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 Article


Ruby - 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 Article

Ruby - Pinguin witch different charcters THe besto work

puts"--------" puts" @ @ " puts" *" puts" +++" puts"--------" puts "mmmmmmm" puts " O . O " puts " U " puts " ...

View Article


Ruby - 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 Article

Ruby - 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 Article

Ruby - 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
Browsing all 146 articles
Browse latest View live




Latest Images