Love, Like, Dislike, Hate – Meditations on Gifts Part 1

I tried to make this a 5x5x5x5 but I’m taking so much time on the dislike/hate part.

  1. I enjoy learning new skills by applying them. I learn best when under external pressure (I have billed the client already).
  2. I enjoy explaining things to people because it reassures me the level of knowledge that I have – or don’t have – and it forces me to compose my understanding to something that can be communicated.
  3. I enjoy seeing problems get solved with constructs of my design.
  4. I enjoy creating things as part of the process of learning new skills.
  5. I enjoy seeing my progress in mastery of the skill.
  1. I like considering new point of views, trying to view something based on another level’s perspective. I ponder a lot; chewing upon thoughts like chewing gum.
  2. I like talking with other people if we’re talking about concepts or their informed opinions on things and how they’ve come to that opinion.
  3. I like experiencing new things and learning something about myself in the process.
  4. I like helping other people by giving them opportunities.
  5. I like planning out my day, my finances, my food – even though I need to work on the actual following the plan thing.
  1. I dislike talking about mundane things. Can we just skip the small talk and get on with discussing deep stuff?
  2. I dislike social media because it’s distracting and it is a huge time and attention sink, not just for me, but also for other people.
  1. I hate the feeling of lack of resources.
  2. I hate the feeling of rejection.
  3. I hate traveling.
  4. I hate not being able to keep my promises.
special mentions

I have a love-hate relationship with gaming. I like games because they’re mentally engaging. It triggers my min-max persona a lot. Anyone who’ve played with me will be able to tell you how much I get into games.

But games also triggers a sense of losing control on my part. That I just can’t stop myself. It’s an addiction.

There’s also a sense of waste when I play. I’ve invested so much time and effort into playing and I have nothing to show for my investment.


Deploying NextJS to Heroku

This took me quite sometime to figure out, so I hope this helps:

  1. Follow Heroku’s instructions on Getting Started on Node.js up until “Deploy the app”
  2. At this point, visiting your site via heroku open will only show an error
  3. Modify your package.json to include the following scripts:
  4. "scripts": {
      // ...
      "heroku-postbuild": "next build",
      "start": "next start -p $PORT"
  5. Push to Heroku again, and voila, it should now work.

Retention Hypothesis: Trust and Responsibility

For a company in the service business, especially one as small as us, as cliché as it sounds, our people are our greatest asset.

Retaining talent is very important for us to execute at the level that we do.

My hypothesis are the following:

  • Trust your employees to do what’s right for the company
  • Reduce the impact of mistakes

In a fundamental level, the basis of our retention hypothesis is trust. We provide the vision, the direction and the goals but we trust the employees on the implementation details. This is incredibly hard to do, especially if you’re as big as a control freak as I am.

But trust is a two-way street. Once the trust has been broken, it will be an incredibly long process to get it back.

More details in a future post.

Happy Labor Day!


Making ActiveRecord associations readonly based on state

My use-case:

* Trip has many destinations and travelers
* Trip states are: 
draft -> checked out -> paid
draft -> checked out -> failed (which should allow them to edit again)

* Trip workflow actually is: 
being edited -> for confirmation -> go to payment gateway (set to checked out) -> go back to success/fail
payment gateway sends payment details to system whether payment was success (paid) or failed (failed)

To disable editing on trip:

class Trip < ApplicationRecord
  def readonly?

  def draft?

  def checked_out?
    return false if checked_out_on_changed?
    # this is required, otherwise saving the relations will always fail
    # as draft will always return false even during the saving process

To disable changes on related records (destination/traveler):

class Destination < ApplicationRecord
  validate :trip_is_in_draft

  def trip_is_in_draft
    errors.add(:trip, "should be in draft") if !trip.draft?

Testing Email Deliveries using Cucumber/Capybara/Minitest

# features/support/env.rb
Around('@email') do |scenario, block|
  ActionMailer::Base.delivery_method = :test
  ActionMailer::Base.perform_deliveries = true

  old_adapter = ActiveJob::Base.queue_adapter
  ActiveJob::Base.queue_adapter = :inline
  # ActiveJob::Base.queue_adapter.perform_enqueued_jobs = true

  ActiveJob::Base.queue_adapter = old_adapter

# features/steps/*_step.rb

Then(/^I should receive an email$/) do
  # assuming mailcatcher
  assert_difference -> { ActionMailer::Base.deliveries.length } do
    # do stuff that is supposed to send an email

# features/*.feature

Scenario: Checkout page
  When I press the checkout button
  Then I should receive an email

Removing field name from validation error message

Related to the accepted answer and another answer down the list:

I’m confirming that nanamkim’s fork of custom-err-msg works with Rails 5, and with the locale setup.

You just need to start the locale message with a caret and it shouldn’t display the attribute name in the message.

A model defined as:

class Item < ApplicationRecord
  validates :name, presence: true

with the following en.yml:

              blank: "^You can't create an item without a name."

item.errors.full_messages will display:

You can't create an item without a name

instead of the usual

Name You can't create an item without a name

How to create a PORO model and use it in Rails Form Helpers

First off, I’ll start with our use-case:

We have a fairly simple form for an item with some complexity. It would have default values derived from the current_user‘s attributes but would still have the field on its own. Overriding it in Item model feels like overkill (and starts to be a violation of SRP) so we set out to create a PORO model for it. Full code and explanation below the fold.

Continue reading “How to create a PORO model and use it in Rails Form Helpers”


The same song has been playing for 2 hours now.
It’s sunny outside.
I’ve been working for 2 hours now.
The view of the pool from our window is calming.
We’ve been here for 32 days now.
I kind of like it here.

The plates have shifted.
It has been 10 months now.
But the boiling hot anger and tremors of disappointment are ever stronger.
It has been 5 years for me since I had an idea, though.
I don’t feel anything, because I knew this was coming.

I’ll stay here until I’m 30.
That’s when I plan to revisit my plans.
But now, I’m still 27.
So there’s nothing else to do but to execute.
I had an 8-year head-start.
Why do I feel like I’m so far behind?

Love Gaming. Hate Gaming.

I actually have a love-hate relationship with gaming.

  • I used to steal from my dad’s wallet just to play in the nearest playstation rental place (remember those?)
  • It started me poking around my computer and lead me to my understanding of computer hardware today.
  • Me and my brother have spent upwards of 10,000 pesos over the course of 4+ years on internet cards and ragnarok cards as well as countless hours playing various MMO games (Ragnarok then Khan Online then Flyff then Dekaron and a bunch of other MMOs that I’m forgetting.)
  • It started me into writing scripts for bots and exercised my nascent logic skills (which turned out useful for programming.)

I love playing games. But it just sucks so much of my time and attention, because it’s too interesting and I’m finding out that I’m a really competitive person (even when I claim that I’m not.) Especially if it’s a game that has infinite replayability and a grind component (e.g. most MMORPGs), I’ll be gone for a week.

I’ve been able to stave this off because I play it on a dedicated computer but mobile games are now the bane of my existence. The accessibility makes it hard to compartmentalize and it provides a “good enough” dose to tide me over.

I wish to find the middle ground. Something like, play only games on weekends. Or in the evening. Something like that. But I’m realizing that it _is_ _fucking_ _incredibly_ hard.

It’s either I don’t play at all, or I just play all the time.

And I’m slowly finding out that I might have to give up gaming altogether if I want to be at 100%.
I’m trying to come to terms with this realization.

Game over, huh?