In one of my previous posts I wrote down the impressions about Hanami I’ve had while working on my side project, Flashcard Genius. One of the things I mentioned there was that some features you’d expect from a framework are missing or underdocumented. One of such features I missed in Hanami was unobtrusive javascript.

Rails comes out-of-the-box with helpers that allow developers to do following things without writing a single JavaScript line:

  • Create links to POST/DELETE/PATCH endpoints (link_to "Delete article, @article, method: :delete)
  • Send forms remotely using AJAX just by adding remote: true to your form tag.
  • Show simple confirmation…

I remember hearing about Hanami framework for the first time. It was a few years ago, during a talk on Wroclove.rb conference. It didn’t really catch my attention back then as I was still a newbie in the Ruby world. I was 100% focused on learning Rails and didn’t wanna cognitively overload my brain with concepts from yet another framework.

Now, after all these years spent working with Rails I got a little burnt out and thought that it’s a high time to get my hands dirty with something completely new. Having the old wroclove.rb talk in mind I decided…

A few months ago I’ve read a book by Pat Shaugnessy called Ruby Under Microscope. It taught me a lot about Ruby’s internals and inspired to dive a bit deeper than normally and try building an extension to the language.

As most of Rubyists know Ruby is a language originally written in C language by Yukihiro Matsumoto. The C implementation is called MRI (Matz’s Ruby Interpreter) and it supports writing plugins that can “talk” to any C program of choice. …

If you’ve landed here it means you’ve been hit by this message in your program. In this post I’ll quickly introduce you to what “UTF-8 byte sequences” are, why they can be invalid and how to solve this problem in Ruby.

Short introduction to UTF-8 and other encodings

UTF-8 is, as explained in Wikipedia, is a set of codepoints (in simple words: numbers representing characters). Every character in UTF-8 is a sequence of 1 up to 4 bytes.

Apart from UTF-8 there are also other encodings like ISO-8859–1 or Windows-1252 — you may have seen these names before in your programming career. …

Today I’d like to share with you a solution to a problem that gave me some headache recently, so you can spend your time on something more interesting (have a ☕ or something).

The task

The goal was to write a rake task that’d:
1. Fetch a big (1GB gzipped) CSV file from FTP
2. Ungzip it (18GB ungzipped)
3. Parse each row
4. Insert it into an SQL database

I’ll describe my approach to steps 1–3. Point 4 will is a material for another story 😅

The solution

Of course loading 18 gigabyte file into the memory wasn’t the best idea, so I…

A few months ago my sister told me to check out a website called It introduced a lot of fresh air to my “boring programmer’s life”, so I decided to share some of my feelings with you.

Codewars is a platform for software developers on which people can solve programming puzzles known also as “katas”. The term was introduced to software development world in 1999 by Dave Thomas, the co-author of “The Pragmatic Programmer” — one of the most widely known books in the industry. …

In Leadfeeder we develop our frontend app in Ember.js backed by a Ruby on Rails JSON API. Personally I think it’s a great choice of stack as it lets developers quickly deliver new features without writing tons of code. However, no matter how cool and easy-to-use the stack is, in the course of time you’ll eventually have to face some performance problems.

In our case the problem was that when the frontend app grew we started having lots of views requiring different sets of attributes present in the same models. Of course in the beginning, when the number of model…

While writing Google Data Studio connectors I needed to fire lots and lots of HTTP requests using UrlFetchApp in order to gather all the necessary data for my reports. Initially I used fetch method that allows only one, synchronous request.
Later, when my connector was ready I wanted to speed things up and started experimenting with fetchAll method, capable of sending multiple parallel requests. It really gave my app a boost, but I still needed to tackle one more problem…

Sometimes a single request in the requests batch would fail causing the whole script to fail as well. In many…

TLDR: Use ams_lazy_relationships gem ( to eliminate N+1 queries in ActiveModel::Serializers 🎉

Quick intro to batch loading

A few months ago I came across a post by exAspArk explaining how they built and used the BatchLoader gem to optimize the number of database queries in their apps.

The topic of batch loading was new to me back then, but it sounded like a perfect fit for our Rails app in Leadfeeder, because the recommended Rails way of using includes wasn’t flexible enough for many of our complex endpoints.

Quick explanation for people who just asked “what the hell is batch loading”:
Batch loading is…

You might be already be familiar with a programming-related term “canary releases” or “canary builds”. Do you actually know what it means and what’s the term’s origin?

A canary release is a special version of the product dedicated for a selected group of people (sometimes they’re volunteers and sometimes they’re not aware of being in a test group). The ones with canary build access are often test-drivers of an experimental feature who let developers collect feedback and fix bugs at an early development stage.

One example known to me is Ember.js framework that provides a special build for their beta…

Jan Bajena

Full stack developer @Leadfeeder. Working on random stuff in my free time.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store