While updating styles for Enectiva to make it more responsive I came across a problem with flexbox — there are some restrictions in particular browsers. For instance, one issue I encountered was that some HTML elements can’t be used as flex containers. For instance, we wanted to use fieldsets because of their semantics both alone and combined with legends and make them flex containers. This, however, doesn’t work in Chrome. The following example shows that using the same CSS properties (display: flex; flex-flow: row nowrap) the elements inside the fieldset are in a row in Firefox but not in Chrome. Read On →

Breaking in Go

One of Go’s advantages is its familiar syntax and vocabulary. Parentheses, brackets, and braces have the meaning you expect. Programs are composed of well known keywords like var, const, for, or return. This familiarity, however, means that one might forget that Go might have slightly different semantic for those terms. One such example is the keyword break. Recently, we wrote a program which boiled down to an equivalent of: for i := 0; i < 10; i++ { fmt.Println("Line:", i) switch i { case 5: break } } The desired output was to terminate the loop when a condition was reached inside the switch statement. Read On →

Capistrano: changing repository URL

Last week, we moved our git repositories to GitLab so we needed to change all deployment scripts. We deploy using Capistrano and looking at deploy.rb file the task looks simple. Right at the top is something like: set :repo_url, 'user@domain:repo.git' Having learnt from experience, I consulted the docs to verify my assumptions. It was exactly as I thought, I changed the URL, ran a deploy to make sure everything is ok and all permissions are set up properly. Read On →

Beginner's Elm resources

As a newcomer to Elm, I’d like to share a list of resources I’ve found helpful while learning this interesting programming langauge: Official Elm guide - introduction to Elm, detailed, strongly recommended for beginners to understand basics of Elm language, explanation of terms and function Official example applications- very helpful from the beginning too, interactive examples show how the code works in preview, possibility to change the code and see changes on the page Elm community links - very positive to see that you are not alone with Elm. Read On →

git branch --merged

One can explore git and discover something new every day. One of my recent discoveries is the --merged option of git branch. As the name suggests, it allows you to list all branches which have been merged as of a specified commit. Conveniently, it defaults to the current commit, so by running: git branch --merged you can list all the branches which have already been merged up to the current commit. Read On →

Mocking using interfaces

Nearly every piece of software is composed of multiple components which work together to provide a set of functions. The division into components has many benefits, one of which is smaller scope of tests, but to fully leverage it we need to be able to isolate the components in the test environment. Every programming language provides different tools to accomplish this isolation. Let’s look at an example in Go. One of our programs includes a registry of devices represented by a serial number. Read On →

HTTPS in Ruby

Recently, we switched communication between our internal backend services to use SSL/TLS. In cases when have Go talking to Go the switch from HTTP to HTTPS proved very simple. There are, however, instances where Go talks with Ruby. After the success with Go, we prepared everything, set up parallel HTTP and HTTPS endpoints to ease the transition and limit the downtime. Everything went well until we switched Ruby code to use the HTTPS endpoint. Read On →

Notes from upgrading Rails

Since Rails 5 was released a month ago, we took some time to upgrade to Rails 4.1.x to not be so far behind. Upgrading Rails is always a pain because it is connected to almost every bit of the application and you never know what will happen. Changes between 4.0.x and 4.1.x are documented and make for a good starting point, although, not everything is covered and there were three significant surprises. Read On →

When long queries are fast - an SQL optimization

As the amount of data Enectiva.cz handles grows, we need to find better ways to manage it. After auditing our database, we discovered a pattern which allowed us to reduce the amount of data stored by tens of percent. In order to take advantage of these potential savings, we had to change SQL queries used to access the data. This entailed a set of performance tests for various prototypical scenarios. One such scenario is: when was the consumption data last updated? Read On →

Postgres advisory locks

Postgres employs various types of locks to control shared access to data. Most often, Postgres takes care of using the correct lock on its own, but the API is public and application developers can leverage them as well. There is, however, one type of locks not used by Postgres itself: advisory locks. They are intended only for applications and Postgres does not enforce their use — it only provides functions to manipulate them and automatically cleans them up at the end of the session. Read On →