Posts about ruby
6 years ago
Choosing a Ruby gem
Instead of writing yet another list of gems you should be using, i'll try to explain how i choose a gem for a particular task or function. This is by no means a complete checklist, it's just my typical way of going about things.
Rubygems
If you're a...
OCR using the open Google Cloud Vision API
Just create a new api key in the developer console, replace it in the code below and it should work. Then you can call "whatever_you_call_the_file.rb /Downloads/some_image_with_text.jpg" and google will OCR-it and the script will print out the...
8 years ago
Problem starting Sidekiq in development
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...
9 years ago
AES encryption in Ruby and Decryption in Java
This one is precious, as it took me a long time to figure out. As a side-note, Java apparently only supports 128bit AES.
Here's the Ruby code:
def encrypt(string, pwd) salt = OpenSSL::Random.random_bytes(16)
# prepare cipher for encryption...