See our books for programmers (Rails, React.js, blogging, remote)

Jakub Kosiński

How to store emoji in a Rails app with a MySQL database

Suppose you have a Rails app and you are storing your data in a MySQL database. You were requested to add emoji support to your application. Probably you are thinking:

Oh, that’s simple, it’s just unicode, isn’t it?

The answer is: no. Unfortunately, MySQL’s utf8 character set allows to store only a subset of Unicode characters - only those characters that consist of one to three bytes. Inserting characters that require 4 bytes would result in corrupted data in your database.

continue reading →

Beautiful confirm window with React

When designing your web application, you would like the user to confirm some actions sometimes. For example, you may want the user to confirm deletion of his data. There is window.confirm JavaScript method that might be useful in this case but it could not be styled and just displays native browser’s dialog window. In this article I would like to show you how to create React component as a replacement for window.confirm that can have similar behaviour and your application’s look & feel. It has similar API to window.confirm so migration should be really easy.

continue reading →

Use your gettext translations in your React components

Photo remix available thanks to the courtesy of miguelb. CC BY 2.0

In one of our projects, we are using gettext for i18n. We were putting Handlebars x-handlebars-template templates directly in Haml templates to provide translated views for frontend part - all translations were made on backend. Recently we have rewritten our frontend to React and decided not to use ruby for translations anymore.

continue reading →