Count occurrence of element in array column

Scenario: There is a reviews table contains feedbacks column, which is an array of string. Please count the occurrence of feedback.

Rails support for PostgreSQL array datatype

Since PostgreSQL 9.3, rails support array datatype. It is convenient to store array of data in one column. For example, product has many tags. We can store tags in one column. Let’s create a products table.

API style

I development API with Grape gem. I found a style or said pattern which works great and decide to write it down.

System design

Some system designs I have did:

My development process

As a software engineer, my mission is to provide a technical solution to solve customer’s problem. The article describes the process I used to develop the software.

How to debug

There are many tools to help debug. This post describes the process I solve a bug in grape, #1788. git blame, git log, git diff, gitk are commands I used in the process, and those commands help me familiar with the history of the codebase.

HEAD request

The HTTP HEAD method requests the headers of the specified resource. It is useful to get the information such as content type and content length before deciding to download a large resource.

How to fix randomly failed test

Have you ever met the situation: sometimes continuous integration reports success, but sometimes it reports failure? The tests fail occasionally and it is hard to find the root cause. When running test individually, it seems every thing is all right. But when running all together, result becomes unpredictable. The cause is the order dependent on tests. Let’s see an example.

How to do table partition with activerecord

It is a time to do table partition when the data size of the table cannot fit in memory. Partitioning refers to splitting what is logically one large table into smaller physical pieces. It makes it more efficient to query small amount of data in a large table.

Database indexes and isolation levels

資料庫預設搜尋會 row by row 直到找到目標為止,當有很多筆資料時(很多 rows ),且想搜尋的結果只有少數幾筆時,這是非常沒有效率的做法。Index 的概念可以在書本的目錄看到,目錄分了章節,如此一來想找某個特定主題時,不用一頁頁去翻,可以透過目錄來找到想要的主題。