Pedro Assuncao
Software developer/architect and hobbyist game developer. Overall slightly deranged person.
Following up on my last post about Ruby gems, here's a list of some of my typical choices for various tasks in the Ruby and Ruby on Rails world:
If you ever get this error:
can't link outside actor context
Followed by something like:
/Library/Ruby/Gems/2.0.0/gems/celluloid-0.16.0/lib/celluloid.rb:176:in `new_link' /Library/Ruby/Gems/2.0.0/gems/sidekiq-3.3.4/lib/sidekiq/launcher.rb:21:in `initialize' /Library/Ruby/Gems/2.0.0/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:81:in `new' /Library/Ruby/Gems/2.0.0/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:81:in `run' /Library/Ruby/Gems/2.0.0/gems/sidekiq-3.3.4/bin/sidekiq:8:in `' /Lib... ...read more >>
Time.now will give you the current date (and time), like so:
Time.now 2012-11-22 22:35:01 +0000
You can also request all the date parts individually:
Time.now.hour 22 Time.now.min 35 Time.now.sec 01 Time.now.day 22 Time.now.month 11 Time.now.year 2012
Cool (and easy), right? If you want to change a date, you can add seconds to it:
t = Time.now 2012-11-22 22:35:01 +0000 t2 = t + 10 # 10 Seconds 2012-11-22 22:35:11 +0000 t3 = t + 10*60 # 10 minutes 2012-11-22 22:45:01 +0000 t4 = t ...