Hi everyone
I’m starting in Ruby, and first I would like to translate a fonction php
I made into a ruby one. In php it’s very slow due to the number of
possibilities, the function is :
Any idea? thx
Hi everyone
I’m starting in Ruby, and first I would like to translate a fonction php
I made into a ruby one. In php it’s very slow due to the number of
possibilities, the function is :
Any idea? thx
Avo wrote:
I’m starting in Ruby, and first I would like to translate a fonction php
<?php function boom($value) { $toto = "bbc4d9cb08ddbce591c28effcf6a6120005dc477";
I made into a ruby one. In php it’s very slow due to the number of
possibilities, the function is :
Get PhpUnit, and write unit tests for this function. Start with the
simplest cases, such as ‘A’.
Then write simple unit tests in Ruby that match each input and output.
“Grow” your Ruby function, by adding test cases that fail, then
upgrading your function to pass. With a little perseverance, and a
book on the Ruby language, you will have a rock-solid and bug-free
implementation in no time.
Your design might come out the same, or different. Growing your
function gives you many opportunities, while it is still small, to
discover alternate patterns. The tests will make refactoring to any
different pattern very easy.
–
Phlip
http://c2.com/cgi/wiki?ZeekLand ← NOT a blog!!
Avo wrote:
Hi everyone
I’m starting in Ruby, and first I would like to translate a fonction php
I made into a ruby one. In php it’s very slow due to the number of
possibilities, the function is :
Hi Avo. How about
def boom
puts “why not just ask them what their password is”
end
It’s the pragmatic approach and it stands a greater chance of
succeeding.
Michael H. wrote:
Avo wrote:
Hi everyone
I’m starting in Ruby, and first I would like to translate a fonction php
I made into a ruby one. In php it’s very slow due to the number of
possibilities, the function is :Hi Avo. How about
def boom
puts “why not just ask them what their password is”
endIt’s the pragmatic approach and it stands a greater chance of
succeeding.
lol, we can call it a “challenge”
Michael H. wrote:
puts “why not just ask them what their password is”
endIt’s the pragmatic approach and it stands a greater chance of
succeeding.
LOL!
Much cleaner too.
–
Chris M.
Web D.
Chris M. wrote:
Michael H. wrote:
puts “why not just ask them what their password is”
endIt’s the pragmatic approach and it stands a greater chance of
succeeding.LOL!
Much cleaner too.–
Chris M.
Web D.
http://chriscodes.com
require ‘digest/md5’
require ‘digest/sha1’
aFile = File.open “length7v.txt”, “r”
aFile.each do |line|
md5 = Digest::MD5::hexdigest(line.chomp).reverse
sha1 = “bb” + Digest::SHA1::hexdigest(md5)[2…39]
puts “Testing #{line}”
if sha1 == “bbc4d9cb08ddbce591c28effcf6a6120005dc477”
puts “Found the pass : #{line}”
system “pause”
end
end
easy!!
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs