Skip to content

Instantly share code, notes, and snippets.

@michaelminter
Created May 31, 2011 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelminter/1000895 to your computer and use it in GitHub Desktop.
Save michaelminter/1000895 to your computer and use it in GitHub Desktop.
Return a random string of numbers and letters using only characters that read unique.
#! /usr/bin/ruby
class ReadablePin
def new( len = 8 )
pin = ''
chars = ("a".."z").to_a + ("0".."9").to_a
remove_each = ["i", "o"]
remove_each.each do |each|
chars.delete(each)
end
while !finished
1.upto(len) { # len.times { pin << chars[rand(chars.size-1)] }
|i| pin << chars[rand(chars.size-1)]
}
check = User.where(:job_id => @job_id).and(:pin => pin).first
if check
finished = true
end
end
return pin
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment