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…
Category: Code
Code
TRS: Toy Robot Simulator
by Kat Padilla • • 0 Comments
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.…
Code
Heartbreaker: Yet Another Space Invaders Clone
by Kat Padilla • • 3 Comments
I created something out of boredom: http://stuff.katpadi.ph. So… obviously it’s a game. It’s not original. It’s nothing amazing. It’s a space invaders clone with a twist. I am still enhancing the “twist” part. There’s a heartbreaker (it’s a pig!). It rips the hearts out. But the hearts still give hearts anyway. It’s silly, I know. There are…
Code, Tech, Thoughts
TIL: Redis Keyspace Notifications
by Kat Padilla • • 0 Comments
For some reason, I was figuring out a way to be able to listen to Redis so I can fire callbacks when the Redis command or event is encountered. I wanted to do something like: When a key gets removed from the sorted set, it will trigger a script that will notify a user. Browsing…
Code
Git: Squash Commits
by Kat Padilla • • 4 Comments
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…
Code
TIL: Action Cable x WebSockets
by Kat Padilla • • 2 Comments
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…
Code
Ruby Gem That Makes Your Model Activatable
by Kat Padilla • • 0 Comments
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…
Code
My First RubyGem Is Called Sorty Sorter
by Kat Padilla • • 0 Comments
In the Ruby world, mixins are very popular. In fact, I’ve created a number of basic mixins (or concerns) in Rails projects and so it came to a point where I wanted to try converting it to a gem. Why? Because why not? Well, just for the experience. Anyway, my first RubyGem is called Sorty Sorter. It sorts AR collection…
Code
Race Condition and Rails with_lock
by Kat Padilla • • 0 Comments
At one point in a dev’s life, race condition will be something that one needs to solve. Race conditions happen when the outcome is dependent on the sequence or timing of other events like saving a record to the database. If two users read a value from a record and then update it simultaneously, one of the…
Code
My Go-To ST3 Packages for Rails Development
by Kat Padilla • • 0 Comments
While most of my officemates use RubyMine, I use ST3. The thing I love most about this editor is the versatile package system – there’s a package for almost everything! Anyway, I decided to list down My Go-To ST3 Packages for Rails Development: Package Control‘s first on the list because it allows me to easily add other…