KatPadi's Point

Category: Code

Handling Errors Gracefully

Sometimes it makes sense to treat errors as part of an application’s “valid” flow of events. Meaning, expected errors should not necessarily make your code go crazy when random errors are raised. With that in mind, I created a way to implement some kind of “Result Object” by rescuing StandardError instances and handling these errors…

TRS: Toy Robot Simulator

A few weeks ago, I created a basic Ruby gem implementation of the “Toy Robot Simulator” problem. Toy Robot Simulator wuttt??? The scenario is that the application is a simulation of a toy robot moving on a square table of certain dimensions. The robot is free to roam around the surface but must not fall.…

Git: Squash Commits

With git it’s possible to squash previous commits into one before sharing them with others. Step 1 For example you want to squash your last 3 commits: git rebase -i HEAD~3 On the other hand, if you want to just simply squash all the unpushed commits: git rebase -i origin/master If you have many commits and…

TIL: Action Cable x WebSockets

So I finally had time exploring Rails 5 after quite a busy schedule. First order of business– check out Action Cable as it seems to be one of the most promising features to Rails 5. To understand Action Cable, I had to understand WebSockets first. WebSockets…wut?  Clearly, the online world has been largely built around the…

Ruby Gem That Makes Your Model Activatable

Aktibibo is a simple Ruby gem that makes your model activatable. It allows an ActiveRecord model to be declared as “activatable” thus providing scopes for querying and filtering objects. Of course, the module adds convenience methods for setting an instance as active, inactive or deactivated. As an additional feature, it also saves the activation and deactivation dates because it uses datetime DB…