Rails 5 Test Prescriptions: Build a Healthy Codebase - reading notes

I finished reading Rails 5 Test Prescriptions: Build a Healthy Codebase - reading notes by Noel Rappin. It contains exactly what it claims in its lengthy title. It discusses testing in more general terms (but doesn’t go deep into motivation for testing as many books do), describes different categories of tests and puts them into practice with Rails 5 approach. Compared to other books, this is actually pretty hands-on text. Rappin uses a simple project management app as an example to demonstrate the various approaches throughout the book. Read On →

Remote testing with ngrok

Testing websites and web applications across platforms, browsers and operating systems is a nightmare. Browsers’ developer tools have made it much more convenient over the years with respect to mobile but still, you can’t simulate IE in Firefox or weird “improvements” some OS + browser combinations make (I’m looking at you, Safari on an iPhone). There’s no getting around of running the browser on an actual device. However, getting the website/app running somewhere accessible can be a bit of a problem. Read On →

IE, Webpack and strict mode

Supporting Internet Explorer is one of those phrases which spoken aloud makes a person bang their head against the nearest hard surface if they’ve been in web development for longer than two weeks. Don’t get me wrong, it used to be much much worse back in the day of IE6 and IE7 and supporting Edge is several orders of magnitude less stress inducing (and Microsoft did a good job of branding Edge to put some distance between Edge and IE). Read On →

Multi-caret mode in IntelliJ Idea

After seeing it used very effectively in several screencasts I finally decided to learn the keyboard shortcuts to for multi-line/multi-caret selection and editing in IntelliJ Idea. There are two ways how to go about it: Switch from line-selection mode to column-selection mode, by default Alt + Shift + Insert and then hold Shift and press an up/down arrow key to spread the caret to as many lines as you need, or Press Ctrl, release it, press Ctrl again and hold it and press an up/down arrow key again as much as you need Personally, I like the first one even though it seems bit more cumbersome. Read On →

ActiveRecord model sorting

Ruby on Rails comes with ActiveRecord for persistence of data. It provides a powerful querying interface every developer working with Rails is familiar with. The methods are chainable and the most common queries can be expressed in a pretty readable way. For the others, you can drop one level lower and write Arel queries which is the library powering ActiveRecord under the hood. Basic sorting One of the tips for performance when fetching data is to rely on the database to do the sorting and not do it in Ruby. Read On →

Custom input elements and Elm

Custom input elements are a lot of hassle and even more with Elm, probably not impossible. TL;DR Elm recently released version 0.19 which brings many nice things and improvements but it is also removes support for native modules. While Elm 0.18 is still alive it can be safely expected that new packages or new versions of existing packages will target only the new version forcing an update. What are native modules Elm 0. Read On →

Default flag values in Go

In contrast to many languages, Go has a very nice built-in package for parsing arguments passed to an application called flag. There are many libraries which build on top of it, e.g. kingpin, but as long as your application’s requirements for arguments are simple enough the standard library package is completely satisfactory. The API is pretty simple: you define your flags by calling functions flag.Int, flag.String or flag.Duration which take three arguments, the name of the flag, default value and a usage guide, and return a pointer to a variable which will be populated by the actual value passed by the user. Read On →

Implementing sharding in a multitenant Rails application

As Enectiva, an energy management solution, grows, the amount of data we need to store grows as well. We’re definitely not in terabytes but some of the tables are becoming pretty hefty so we decided to implement sharding. Our biggest pain point are pre-calculated consumption data so we naturally started there. Basic concept Due to the nature of the data and the access patterns, we decided to go with traditional sharding by customer. Read On →

Shortening .ssh/config file with patterns and multiple hosts

Recently, I’ve been digging into Sup which is a very simple deployment tool written in Go. It allows to declare named clusters of servers (called networks), Bash commands to be performed and sequences of commands (targets) in a YAML config file so that you can run things like: sup production deploy # or sup production rollback Sup is a very handy tool for deployment of applications which don’t require a lot of setup which Go applications tend to be. Read On →

Running Ruby tests with Spring from IntelliJ Idea / RubyMine

IntelliJ Idea is my IDE of choice for all development across multiple languages. Support for different languages varies and improves at different rate but I find it useful most of the time. Suddenly, last week my Ruby tests stopped running. Whenever I wanted any Ruby test to run, the execution failed with: .../spring-2.0.2/lib/spring/sid.rb:39:in `getpgid': No such process (Errno::ESRCH) I run Ruby tests with Spring preloader which has been the default for Rails applications for last few versions and Idea integrates nicely with it. Read On →