x=1
print "How much password do you want? "
n=gets
print "How much long password do you want? "
l=gets
if l.to_i<4
puts "You can do it your self, you looser!"
exit()
end
if l.to_i>6
y=l.to_i-6
x=x+y
end
n.to_i.times do
pa1=('a'..'z').to_a.shuffle[0..x].join
pa2=('A'..'Z').to_a.shuffle[0..0].join
pa3=['@','#','$','&','^'].shuffle[0..0].join
pa4=(0..9).to_a.shuffle[0..1].join
if l.to_i>=6
a=(pa1+pa2+pa3+pa4).split('')
elsif l.to_i==5
a=(pa1+pa3+pa4).split('')
elsif l.to_i==4
a=(pa1+pa2+pa3).split('')
end
puts a.shuffle.join
end
Monday, April 18, 2011
Tuesday, March 8, 2011
reader and writer / getters and setters methods in ruby on rails
class Car
# A writer method. Sets the value of the @make attribute
def make=(text)
@make=text
end
# A reader method. Returns the value of the @make attribute
def make
@make
end
end
==================
#create object
my_car=Car.new
#read object
my_car.make #=> nil
#write
my_car.make='Toyota'
#read
my_car.make #=> 'Toyota'
--------------
#write
my_car.make='Mazda'
#read
my_car.make #=> 'Mazda
# A writer method. Sets the value of the @make attribute
def make=(text)
@make=text
end
# A reader method. Returns the value of the @make attribute
def make
@make
end
end
==================
#create object
my_car=Car.new
#read object
my_car.make #=> nil
#write
my_car.make='Toyota'
#read
my_car.make #=> 'Toyota'
--------------
#write
my_car.make='Mazda'
#read
my_car.make #=> 'Mazda
Sunday, February 20, 2011
rails error: no such file to load -- libssl
Yesterday I install rails 3 on my pc (Ubuntu 10.10) & create new application
when i run this application i got this error "no such file to load -- libssl"
I spend whole day to fix this error search, read lot of stuff on net & finally
i got simple solution i run only following 4 commands & error gone.
1) $ sudo apt-get install libopenssl-ruby
2) $ cd /usr/local/src/ruby-1.9.2-p0/ext/openssl/
3) $ sudo ruby extconf.rb
4) $ sudo make install
that set
Subscribe to:
Comments (Atom)