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 →

Go: to inifinity and beyond

When I read and review code, I sometimes come across constructions which seem strange, dubious or generally weird. Before I comment, I like to check my assumptions and understanding of the behaviour first. Go makes this really simples with Playground where you can run short snippets of code and share them with colleagues. Yesterday, I came across a conditional with division which just asked to get zero divisor. I assumed the code would fail but it was strange it hasn’t manifested, so I went to check. Read On →

Zonky coderetreat 2017

Yesterday, I attended a coderetreat organized by Zonky, specifically by Jaroslav Holaň and Dominik Moštěk. It sort of was and wasn’t a part of the Global day of coderetreat. That will take place next Saturday, November 18, 2017, and there are events all over the world. However, the day before is a public holiday here in Czech republic creating a nice extended weekend, ideal to get away from work, programming, city etc. Read On →

EuRuKo 2017 in Budapest

Last weekend, I attended EuRuKo 2017 in Budapest. It was great to see a lot of familiar faces after skipping last year. 700 Ruby developers (and others) flocked to Budapest in order to conference hard for two days, see 14 talks, almost as many lightning talks, chat, and party. There have been many tweets from the conference and people have written about their experiences there. I’d just like to point out few high points. Read On →

Window functions in Postgres with Rails time

Back when Ruby on Rails was moving to use Postgres as its default database, there was a lot of comparison articles and videos. From one of them, I remember a simple query which surprisingly works in MySQL: SELECT category_id, COUNT(*), email FROM users GROUP BY category_id OK, we want to get the number of users is each category identified by its ID and an e-mail. Which e-mail? I don’t remember if MySQL returns the first or last in each group but it does not complain and it returns something. Read On →

Elm Prague meetup talk

Last Wednesday I gave a second talk about Elm at Elm Prague Meetup. This time I talked about a toy project animating SVG bubbles received over a WebSocket inspired by Listen to Wikipedia. The source code for the application is available on GitHub, the slides are available as well.

Gokit: HTTP transport

In our services written in Go, we quite heavily rely on Go kit. You can build anything with just Go’s standard library. It has very little opinions about how to do things and gives you a lot of latitude when architecting your application. That’s great for trying things out or even if you have a single application, but when you develop multiple services in a team, it’s useful to have a common baseline for routine tasks and Go kit does exactly that. Read On →