Holidays helper in Ruby on Rails

Today, while doing a calendar I found a module on Rails called Holidays. I will use the Rails console to demonstrate: bundle exec rails c Loading development environment (Rails 5.0.1) [1] pry(main)> Holidays.on(Date.tomorrow, :pt) => [{:date=>Wed, 01 Nov 2017, :name=>”Dia de Todos-os-Santos”, :regions=>[:pt]}] [2] pry(main)> Holidays.on(Date.today, :pt) => []

Read More Holidays helper in Ruby on Rails

Solving easy problems with Ruby

I got this problem from here Implement a group_by_owners function that: Accepts a hash containing the file owner name for each file name. Returns a hash containing an array of file names for each owner name, in any order. For example, for hash {‘Input.txt’ => ‘Randy’, ‘Code.py’ => ‘Stan’, ‘Output.txt’ => ‘Randy’} the group_by_owners function should return {‘Randy’ => [‘Input.txt’, ‘Output.txt’], ‘Stan’ […]

Read More Solving easy problems with Ruby

How to remove Docker files

I have been using docker for a while in a project and thank god it exists. There is no need in installing many project dependencies. In this case this is a Ruby on Rails 3 project, yes very old. Everything was fine until my root partition “/” was out of space! I thought to myself […]

Read More How to remove Docker files

The importance of a Backup

Before I started working professionally as a software engineer, I would see a lot of people talking about the importance of backups in the IT industry. A few weeks ago I worked on a project that didn’t have any backups and was in production! The first thing I did was a backup and used the […]

Read More The importance of a Backup

Heroku rollback

A while ago had a problem in a production server in which I used Heroku’s rollback command, which goes back to the previous push/migration. When you run: heroku rollback It goes a step back in your commits/changes but upgrades the version. Current version = v33, after rollback current version = 34. If for any reason rollback […]

Read More Heroku rollback

Ruby cover? instead of include?

Last week I learned that we should use cover? instead of include?. When you ask a range if it includes something, ruby is going to instantiate every object within that range and then check if the object you pass into include? exists in there. If you ask cover? it’s just going to figure out and […]

Read More Ruby cover? instead of include?