Homepage
Open in app
Sign in
Get started
Sikachu's Blog
Programming, Web Development, Technology, and Gaming.
Follow
Following
Ignore Git revisions in git blame
GitHub recently added support for ignoring revisions in git blame, which should be useful for when you have commits that change code style.
Prem Sichanugrist
Jul 21, 2022
Confirm current database connection in Rails console
Useful when you want to avoid running a big query on your main writer database.
Prem Sichanugrist
Feb 4, 2022
Vim modeline magic
It’s Magic. Modeline Magic.
Prem Sichanugrist
Apr 1, 2020
Trending
Use create_or_find_by to avoid race condition in Rails 6.0
It’s pretty common in Ruby on Rails to use find_or_create_by method when you want to create a new record if the record isn’t already…
Prem Sichanugrist
Feb 20, 2018
Expanded rails routes in Rails 6.0
In Rails 6.0, rails routes command will support --expanded (or -x, the shorthand version). This is similar to \x mode in psql where it will…
Prem Sichanugrist
Jun 7, 2018
Poison Object: An Antidote for Your Nil
Introduction to poison object (a.k.a. a throwaway object) to be use as a default value for method expecting zero or one argument.
Prem Sichanugrist
Nov 10, 2015
Latest
Writing a pass-through method, Ruby 2.7 edition
You may have written a Ruby method which pass all the arguments to the underlying method, and Ruby 2.7 just introduced a new syntax for it.
Prem Sichanugrist
Mar 26, 2020
fetch vs. [] || for default value in Ruby
TL;DR: Use Hash#fetch
Prem Sichanugrist
Mar 23, 2019
Missing translations keys — Gotta Catch ’Em All
`config.action_view.raise_on_missing_translations = true` actually does not apply to direct `I18n.t` calls. Here’s how to make it do so.
Prem Sichanugrist
Oct 22, 2018
Think twice before using double splat in Ruby
As of Ruby 2.5.1, double splat operator (**options, for example) is still considerably slower than accepting a normal argument and sets a…
Prem Sichanugrist
Jul 3, 2018
A new helper to freeze time in Rails 5.2
This one is a simple quality-of-life improvement.
Prem Sichanugrist
Jun 8, 2018
Relation.pick in Rails 6.0
Back in 2012, Rails 3.2.0 added a .pluck method which you can call on a ActiveRecord::Relation or a model class:
Prem Sichanugrist
Jun 6, 2018
No more utf8=✓ in Rails 6.0
I came across this change when I did a talk at Tokyo Rubyist Meetup a few months ago.
Prem Sichanugrist
Jun 5, 2018
Private Attribute Accessor in Ruby is An Artifact from Other Languages
I’ve recently started seeing a trend of defining a private attr_accessor in Ruby code, and I honestly seeing them as an artifact from other…
Prem Sichanugrist
Jun 4, 2018
It’s Better to Write a Thread-Safe Code
I recently having a discussion with my colleague about a class variable in one of the pull request. He proposed a commit which includes a…
Prem Sichanugrist
Jun 3, 2018
Follow Code Convention in Ruby by Turn On Verbose Mode
As a Rubyist, we are obsessed with our code style. That’s why tools like Rubocop exists to make sure that the project’s code style is…
Prem Sichanugrist
Jun 2, 2018
About Sikachu's Blog
Latest Stories
Archive
About Medium
Terms
Privacy
Teams