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 →

dotGo, microservices & simplicity

Recently, I watched all the recorded talks from last year’s (2015) dotGo conference as a way to learn something new about the language and where it is heading. You can watch 17 different talks on many aspects of the language, but there are two talks which stand out. The first one is Peter Bourgon’s talk about microservices and the tooling available for building them. Go is a backend language and often gets applied to the behind-the-scene processing which overlaps with a possible domain of microservices. Read On →

Including shared examples in RSpec

We’ve been using RSpec in testing of Enectiva since the beginning because of hwo expressive it is and how it helps us to structure test cases. One of the features which makes the later possible are shared contexts and shared examples. We use them quite often and, admittedly, there’re test files which take it to the extreme. However, there are valid use cases for both shared context and shared examples and it’s worth understanding them. Read On →