Convert epoch millisecond timestamp to readable datetime

In many cases such as when dealing with API response in JSON format, working on JavaScript assets embedded on websites, and so on, we keep seeing 13-digit long numbers very frequently and we probably know it is epoch timestamp originating from code like new Date().getTime(), however, as a human we just can not quickly tell what date and time it represents. There is a convenient website named Epoch Converter that can help convert it to human-readable format easily but most of the time for developers, there are even quicker ways than opening the website, which is by using the interactive shell that comes with many programming languages.

Upgrade to Ruby 3.0.5

Ruby 3.0 came with a few breaking changes which would cause much hassle for a typical rails app that uses a lot of gems, especially the keyword argument behavior breaking change and the removal of the URI.escape method.

Upgrade rails from 5.2 to 6.0

The main things to handle during upgrading API centric application's rails version from 5.2 to 6.0 include configuration tuning and deprecation warnings fixing.

Upgrade to Ruby 2.7.6

Ruby v2.7.6 is the latest version before v3.0 at the time of this writing and upgrading to v2.7.6 may encounter a breaking issue if the application uses libraries that depend on BigDecimal.

Where is Ruby defined? defined?

Ever wonder where Ruby's defined? is defined? Because it looks so like a method, you might end up trying to check out a bunch of places, such as: Object, Kernel, BasicObject, or even Class or Module, but only to find no luck locating it in any of such places. Well, only until you've realized it, the answer is pretty simple: defined? is not a method but an operator or a keyword.

Switch rails server from unicorn to puma

In rails apps among the commonly-used two popular web servers, unicorn serves requests with worker processes, while puma can do it with both process workers and threads. Therefore, switching to puma from unicorn can not only help improve concurrency but also reduce memory usage. Plus, since rails 5.0, the default web server used is puma.

Upgrade rails from 5.1 to 5.2

Upgrading application rails version from 5.1 to 5.2 is much easier than doing from 4.2 to 5.0 or from 5.0 to 5.1, there are very few changes to handle and chances are there is no test failure.

How to import millions of records into mysql

With a gem called activerecord-import, importing a huge amount of records into mysql table becomes an easier task to do, and this post demonstrates how to achieve it.

Upgrade rails from 5.0 to 5.1

Upgrading application rails version from 5.0 to 5.1 is easier than doing from 4.2 to 5.0, since it's only a minor version update. However, there might still be quite a few things to address either from framework changes or due to outdated gems dependency.

Ruby rspec

Ruby rspec

Rails autoload thread unsafe

Rails framework autoloads constants so that in environments like development or test, the app does not need to load everything into memory before serving requests. However, autoloading is known to be thread unsafe in rails (at least for versions less than 6), and if you happen to be using threaded servers like puma or webrick, it's very easy to step on unexpected issues caused by multiple threads.

Upgrade rails from 4.2 to 5.0

Upgrading rails to a new major version can be tricky because there might be many breaking changes from the framework itself or from many gems used in project that will become either deprecated or unsupported. However, it can also go smooth if done in a right procedural way. This post shares the procedure based on my recent hands-on experience in upgrading rails from 4.2.11 to 5.0.7.2 for our API server. Please be kindly noted that depending on project configuration or dependencies, the upgrading steps might be slightly different for various projects.

Ruby http request with cookie

Ruby http request with cookie.

Ruby parallel gem use cases

Ruby parallel gem use cases.

Ruby rack

Rack is the gem that provides the interface between web frameworks (ruby on rails, sinatra) and web servers (webrick, puma, unicorn) in ruby world.

Ruby rake

Rake is a Make-like task runner in Ruby. First define a list of tasks in ruby syntax in a Rakefile and then invoke the task with rake command.

Ruby bundler

Bundler is for dependency management in ruby projects.

Ruby gems

A ruby gem is a software package that contains a reusable ruby application or library.

Ruby rbenv

rbenv is for managing multiple Ruby versions and here are some of its commonly used commands summarized for quick reference.

Ruby basics

Learn some basics of Ruby.