<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Developing Enectiva.cz: Energy management service</title>
    <link>https://developing.enectiva.cz/</link>
    <description>Recent content on Developing Enectiva.cz: Energy management service</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 28 May 2021 09:40:03 +0200</lastBuildDate><atom:link href="https://developing.enectiva.cz/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Good test, bad test</title>
      <link>https://developing.enectiva.cz/2021/05/28/good-test-bad-test/</link>
      <pubDate>Fri, 28 May 2021 09:40:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2021/05/28/good-test-bad-test/</guid>
      <description>I ❤ tests! They give me confidence that the code does what it&amp;rsquo;s supposed to do, they document behaviour, they let me discover edge cases when writing the code in the first place. All tests are not created equal, though, and I don&amp;rsquo;t love them all the same.
I&amp;rsquo;d like to put into words what are the properties which make tests good but&amp;hellip; it depends. It depends on many factors: language, type of test, trust in cooperating components, criticality of the code under test, cost of running a test, time pressure and many more.</description>
    </item>
    
    <item>
      <title>Writing custom native Ruby extension in C from scratch</title>
      <link>https://developing.enectiva.cz/2021/01/25/writing-custom-native-ruby-extension-in-c-from-scratch/</link>
      <pubDate>Mon, 25 Jan 2021 18:00:00 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2021/01/25/writing-custom-native-ruby-extension-in-c-from-scratch/</guid>
      <description>You are probably reading this because you have an idea for a useful library for Ruby and you did not find it already implemented on RubyGems.org.
I was in the same boat, implemented it and here is how:
 Quick initialization of a Ruby gem Creating a Ruby module and a Ruby class in C Creating instance methods in C for the Ruby class Publishing the gem to RubyGems.org Adding more C files to the compilation  But first, let&amp;rsquo;s set our goal here Ok, you have your goal set, and we have to do the same here.</description>
    </item>
    
    <item>
      <title>Adding rubocop-rspec to a legacy codebase</title>
      <link>https://developing.enectiva.cz/2020/11/17/adding-rubocop-rspec-to-a-legacy-codebase/</link>
      <pubDate>Tue, 17 Nov 2020 09:40:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2020/11/17/adding-rubocop-rspec-to-a-legacy-codebase/</guid>
      <description>In a recent article I described how to use rspec --bisect tix flaky tests. Apart from the test failures described in that post, we&amp;rsquo;ve also encountered another problem:
#&amp;lt;Double (anonymous)&amp;gt; was originally created in one example but has leaked into another example and can no longer be used. rspec-mocks&#39; doubles are designed to only last for one example, and you need to create a new one in each example you wish to use it for.</description>
    </item>
    
    <item>
      <title>Eliminating order-dependent test failures using `rspec --bisect`</title>
      <link>https://developing.enectiva.cz/2020/11/03/eliminating-order-dependent-test-failures-using-rspec-bisect/</link>
      <pubDate>Tue, 03 Nov 2020 12:40:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2020/11/03/eliminating-order-dependent-test-failures-using-rspec-bisect/</guid>
      <description>Last week, we&amp;rsquo;ve dedicated some time to improving reliability of the Enectiva test suite. Enectiva is a non-trivial application, so its test suite is coming up to 9K test cases and weird stuff can happen.
As with any project older than a few months, there are tests of varying quality and value. Using the scout rule, we try to improve the tests bit by bit, but sometimes more targeted action is called for.</description>
    </item>
    
    <item>
      <title>Binary data series analysis using Postgres window functions</title>
      <link>https://developing.enectiva.cz/2020/01/06/binary-data-series-analysis-using-postgres-window-functions/</link>
      <pubDate>Mon, 06 Jan 2020 15:22:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2020/01/06/binary-data-series-analysis-using-postgres-window-functions/</guid>
      <description>Few releases back, we introduced a new feature in Enectiva: analysis of binary data series. This feature allows our customers to make sense of data coming from sensors monitoring things like lights turned on by motion, gates and doors being open or anything that can be on/off, open/closed. The primary presentation of this data we were working towards looks like:
Each series has its line with intervals when the lights were turned on displayed as wider stripes in dark blue.</description>
    </item>
    
    <item>
      <title>Printing HTML &amp; CSS</title>
      <link>https://developing.enectiva.cz/2019/11/22/printing-html-css/</link>
      <pubDate>Fri, 22 Nov 2019 12:22:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2019/11/22/printing-html-css/</guid>
      <description>To internet people, it makes no sense to print websites. Not all people are internet people though and some time ago a requirement to print a report page landed on our road map. Here are the obstacles we encountered.
Print stylesheet linking and Webpack Print stylesheets are typically a giant list of .menu, .footer, ... { display: none } hiding all navigation and interactive elements. This gets applied on top of the default stylesheet.</description>
    </item>
    
    <item>
      <title>Rails 5 Test Prescriptions: Build a Healthy Codebase - reading notes</title>
      <link>https://developing.enectiva.cz/2019/03/27/rails-5-test-prescriptions-build-a-healthy-codebase-reading-notes/</link>
      <pubDate>Wed, 27 Mar 2019 15:40:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2019/03/27/rails-5-test-prescriptions-build-a-healthy-codebase-reading-notes/</guid>
      <description>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&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>Remote testing with ngrok</title>
      <link>https://developing.enectiva.cz/2019/02/04/remote-testing-with-ngrok/</link>
      <pubDate>Mon, 04 Feb 2019 11:40:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2019/02/04/remote-testing-with-ngrok/</guid>
      <description>Testing websites and web applications across platforms, browsers and operating systems is a nightmare. Browsers&#39; developer tools have made it much more convenient over the years with respect to mobile but still, you can&amp;rsquo;t simulate IE in Firefox or weird “improvements” some OS + browser combinations make (I&amp;rsquo;m looking at you, Safari on an iPhone). There&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>IE, Webpack and strict mode</title>
      <link>https://developing.enectiva.cz/2019/01/21/ie-webpack-and-strict-mode/</link>
      <pubDate>Mon, 21 Jan 2019 15:40:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2019/01/21/ie-webpack-and-strict-mode/</guid>
      <description>Supporting Internet Explorer is one of those phrases which spoken aloud makes a person bang their head against the nearest hard surface if they&amp;rsquo;ve been in web development for longer than two weeks. Don&amp;rsquo;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).</description>
    </item>
    
    <item>
      <title>Multi-caret mode in IntelliJ Idea</title>
      <link>https://developing.enectiva.cz/2019/01/08/multi-caret-mode-in-intellij-idea/</link>
      <pubDate>Tue, 08 Jan 2019 18:51:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2019/01/08/multi-caret-mode-in-intellij-idea/</guid>
      <description>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 + Insertand then hold Shiftand press an up/down arrow key to spread the caret to as many lines as you need, or Press Ctrl, release it, press Ctrlagain 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.</description>
    </item>
    
    <item>
      <title>ActiveRecord model sorting</title>
      <link>https://developing.enectiva.cz/2018/09/24/activerecord-model-sorting/</link>
      <pubDate>Mon, 24 Sep 2018 12:40:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/09/24/activerecord-model-sorting/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>Custom input elements and Elm</title>
      <link>https://developing.enectiva.cz/2018/09/04/custom-input-elements-and-elm/</link>
      <pubDate>Tue, 04 Sep 2018 12:40:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/09/04/custom-input-elements-and-elm/</guid>
      <description>Custom input elements are a lot of hassle and even more with Elm, probably not impossible.
TL;DR
Elm recently [released version 0.19](Elm relase) which brings [many nice things and improvements](release notes) 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.</description>
    </item>
    
    <item>
      <title>Default flag values in Go</title>
      <link>https://developing.enectiva.cz/2018/06/17/default-flag-values-in-go/</link>
      <pubDate>Sun, 17 Jun 2018 12:40:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/06/17/default-flag-values-in-go/</guid>
      <description>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&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>Implementing sharding in a multitenant Rails application</title>
      <link>https://developing.enectiva.cz/2018/06/09/implementing-sharding-in-a-multitenant-rails-application/</link>
      <pubDate>Sat, 09 Jun 2018 10:00:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/06/09/implementing-sharding-in-a-multitenant-rails-application/</guid>
      <description>As Enectiva, an energy management solution, grows, the amount of data we need to store grows as well. We&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>Shortening .ssh/config file with patterns and multiple hosts</title>
      <link>https://developing.enectiva.cz/2018/03/27/shortening-.ssh/config-file-with-patterns-and-multiple-hosts/</link>
      <pubDate>Tue, 27 Mar 2018 13:25:16 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/03/27/shortening-.ssh/config-file-with-patterns-and-multiple-hosts/</guid>
      <description>Recently, I&amp;rsquo;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&amp;rsquo;t require a lot of setup which Go applications tend to be.</description>
    </item>
    
    <item>
      <title>Running Ruby tests with Spring from IntelliJ Idea / RubyMine</title>
      <link>https://developing.enectiva.cz/2018/03/19/running-ruby-tests-with-spring-from-intellij-idea-/-rubymine/</link>
      <pubDate>Mon, 19 Mar 2018 08:15:06 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/03/19/running-ruby-tests-with-spring-from-intellij-idea-/-rubymine/</guid>
      <description>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&#39;: 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.</description>
    </item>
    
    <item>
      <title>Go: to inifinity and beyond</title>
      <link>https://developing.enectiva.cz/2018/01/09/go-to-inifinity-and-beyond/</link>
      <pubDate>Tue, 09 Jan 2018 18:51:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2018/01/09/go-to-inifinity-and-beyond/</guid>
      <description>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&amp;rsquo;t manifested, so I went to check.</description>
    </item>
    
    <item>
      <title>Zonky coderetreat 2017</title>
      <link>https://developing.enectiva.cz/2017/11/12/zonky-coderetreat-2017/</link>
      <pubDate>Sun, 12 Nov 2017 11:01:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/11/12/zonky-coderetreat-2017/</guid>
      <description>Yesterday, I attended a coderetreat organized by Zonky, specifically by Jaroslav Holaň and Dominik Moštěk. It sort of was and wasn&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>EuRuKo 2017 in Budapest</title>
      <link>https://developing.enectiva.cz/2017/10/03/euruko-2017-in-budapest/</link>
      <pubDate>Tue, 03 Oct 2017 18:51:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/10/03/euruko-2017-in-budapest/</guid>
      <description>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&amp;rsquo;d just like to point out few high points.</description>
    </item>
    
    <item>
      <title>Window functions in Postgres with Rails time</title>
      <link>https://developing.enectiva.cz/2017/09/18/window-functions-in-postgres-with-rails-time/</link>
      <pubDate>Mon, 18 Sep 2017 12:15:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/09/18/window-functions-in-postgres-with-rails-time/</guid>
      <description>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&amp;rsquo;t remember if MySQL returns the first or last in each group but it does not complain and it returns something.</description>
    </item>
    
    <item>
      <title>Elm Prague meetup talk</title>
      <link>https://developing.enectiva.cz/2017/09/04/elm-prague-meetup-talk/</link>
      <pubDate>Mon, 04 Sep 2017 16:42:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/09/04/elm-prague-meetup-talk/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>Gokit: HTTP transport</title>
      <link>https://developing.enectiva.cz/2017/07/23/gokit-http-transport/</link>
      <pubDate>Sun, 23 Jul 2017 16:42:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/07/23/gokit-http-transport/</guid>
      <description>In our services written in Go, we quite heavily rely on Go kit. You can build anything with just Go&amp;rsquo;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&amp;rsquo;s great for trying things out or even if you have a single application, but when you develop multiple services in a team, it&amp;rsquo;s useful to have a common baseline for routine tasks and Go kit does exactly that.</description>
    </item>
    
    <item>
      <title>Greedy Elm</title>
      <link>https://developing.enectiva.cz/2017/06/17/greedy-elm/</link>
      <pubDate>Sat, 17 Jun 2017 17:51:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/06/17/greedy-elm/</guid>
      <description>At the end of May, we gave a talk about Elm and JS interop at Prague Elm Meetup. One of the sections naturally talked about native modules and their dangers, so it shouldn&amp;rsquo;t come as a surprise that they came to bite us just a few days later.
The initial manifestation was that some parts of the Elm application were using the wrong copy, more specifically a wrong language of the copy.</description>
    </item>
    
    <item>
      <title>Custom flags decoder in Elm</title>
      <link>https://developing.enectiva.cz/2017/05/31/custom-flags-decoder-in-elm/</link>
      <pubDate>Wed, 31 May 2017 17:51:37 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/05/31/custom-flags-decoder-in-elm/</guid>
      <description>I&amp;rsquo;m preparing a talk about Elm and JS interoperability for Prague Elm Meetup and I got to the topic of flags, i.e. how to initialize an Elm app with data passed in from JavaScript. Looking into it, I realized how much I don&amp;rsquo;t know and had to find out. There was one special question which bothered me from the moment I tried using flags: Elm automatically decodes the data which limits it to elementary types and their combinations.</description>
    </item>
    
    <item>
      <title>Switching on custom types in Golang</title>
      <link>https://developing.enectiva.cz/2017/05/01/switching-on-custom-types-in-golang/</link>
      <pubDate>Mon, 01 May 2017 14:25:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/05/01/switching-on-custom-types-in-golang/</guid>
      <description>Last week I ran into an unexpected behaviour in Go regarding type switching. In the end, it makes perfect sense but the initial reaction was complete confusion.
The algorithm in question needed to perform different types of actions based on incoming messages. Each message could provoke different number of reactions which could take form of different data structures or operations to be performed later. Message handlers therefore returned a slice containing either values of struct A, B or C, or an anonymous function.</description>
    </item>
    
    <item>
      <title>Go race detector</title>
      <link>https://developing.enectiva.cz/2017/03/23/go-race-detector/</link>
      <pubDate>Thu, 23 Mar 2017 15:06:01 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/03/23/go-race-detector/</guid>
      <description>Recently, we developed a web application which involved the use of multiple goroutines. As a result data races were just around the corner. Fortunately, Go comes with go race detector — an incredible tool which makes them easier to detect.
Let&amp;rsquo;s look at a simplified example:
var servedDevices []Device devicesToProcess := make(chan []Device, 1) go func(devicesToProcess chan[]Device) { select { case devices := &amp;lt;- devicesToProcess: for _, device := range devices { go func(device Device) { // Operations on Device  servedDevices = append(servedDevices, device) }(device) } } }(devicesToProcess) A channel for slices of Devices is passed as an argument to a goroutine.</description>
    </item>
    
    <item>
      <title>I said nil, not nil</title>
      <link>https://developing.enectiva.cz/2017/03/07/i-said-nil-not-nil/</link>
      <pubDate>Tue, 07 Mar 2017 08:42:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/03/07/i-said-nil-not-nil/</guid>
      <description>Last week, I was working on extending goworker to use Sentinel, a Redis HA solution, instead of plain Redis. The high level goal was clear enough, but the way there was anything but.
The root problem which made me go through all stages of programming:
 that&amp;rsquo;s easy; huh, strange; WTF?; smashing head agains a wall; and facepalm/double facepalm/n-facepalm  turned out to be that nil != nil. At least not always.</description>
    </item>
    
    <item>
      <title>Flexbugs</title>
      <link>https://developing.enectiva.cz/2017/02/06/flexbugs/</link>
      <pubDate>Mon, 06 Feb 2017 13:40:01 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/02/06/flexbugs/</guid>
      <description>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&amp;rsquo;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&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>Breaking in Go</title>
      <link>https://developing.enectiva.cz/2017/01/08/breaking-in-go/</link>
      <pubDate>Sun, 08 Jan 2017 13:40:01 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2017/01/08/breaking-in-go/</guid>
      <description>One of Go&amp;rsquo;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 &amp;lt; 10; i++ { fmt.</description>
    </item>
    
    <item>
      <title>Capistrano: changing repository URL</title>
      <link>https://developing.enectiva.cz/2016/11/26/capistrano-changing-repository-url/</link>
      <pubDate>Sat, 26 Nov 2016 16:00:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/11/26/capistrano-changing-repository-url/</guid>
      <description>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, &amp;#39;user@domain:repo.git&amp;#39; 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.</description>
    </item>
    
    <item>
      <title>Beginner&#39;s Elm resources</title>
      <link>https://developing.enectiva.cz/2016/11/12/beginners-elm-resources/</link>
      <pubDate>Sat, 12 Nov 2016 10:00:03 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/11/12/beginners-elm-resources/</guid>
      <description>As a newcomer to Elm, I&amp;rsquo;d like to share a list of resources I&amp;rsquo;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</description>
    </item>
    
    <item>
      <title>git branch --merged</title>
      <link>https://developing.enectiva.cz/2016/10/22/git-branch-merged/</link>
      <pubDate>Sat, 22 Oct 2016 12:40:03 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/10/22/git-branch-merged/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>Mocking using interfaces</title>
      <link>https://developing.enectiva.cz/2016/10/02/mocking-using-interfaces/</link>
      <pubDate>Sun, 02 Oct 2016 15:06:01 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/10/02/mocking-using-interfaces/</guid>
      <description>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&amp;rsquo;s look at an example in Go. One of our programs includes a registry of devices represented by a serial number.</description>
    </item>
    
    <item>
      <title>HTTPS in Ruby</title>
      <link>https://developing.enectiva.cz/2016/09/04/https-in-ruby/</link>
      <pubDate>Sun, 04 Sep 2016 17:30:55 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/09/04/https-in-ruby/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>Notes from upgrading Rails</title>
      <link>https://developing.enectiva.cz/2016/08/05/notes-from-upgrading-rails/</link>
      <pubDate>Fri, 05 Aug 2016 14:29:55 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/08/05/notes-from-upgrading-rails/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>When long queries are fast - an SQL optimization</title>
      <link>https://developing.enectiva.cz/2016/07/25/when-long-queries-are-fast-an-sql-optimization/</link>
      <pubDate>Mon, 25 Jul 2016 15:22:01 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/07/25/when-long-queries-are-fast-an-sql-optimization/</guid>
      <description>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?</description>
    </item>
    
    <item>
      <title>Postgres advisory locks</title>
      <link>https://developing.enectiva.cz/2016/07/14/postgres-advisory-locks/</link>
      <pubDate>Thu, 14 Jul 2016 17:23:08 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/07/14/postgres-advisory-locks/</guid>
      <description>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.</description>
    </item>
    
    <item>
      <title>dotGo, microservices &amp; simplicity</title>
      <link>https://developing.enectiva.cz/2016/06/26/dotgo-microservices-simplicity/</link>
      <pubDate>Sun, 26 Jun 2016 19:18:18 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/06/26/dotgo-microservices-simplicity/</guid>
      <description>Recently, I watched all the recorded talks from last year&amp;rsquo;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&amp;rsquo;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.</description>
    </item>
    
    <item>
      <title>Including shared examples in RSpec</title>
      <link>https://developing.enectiva.cz/2016/06/19/including-shared-examples-in-rspec/</link>
      <pubDate>Sun, 19 Jun 2016 21:13:00 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/06/19/including-shared-examples-in-rspec/</guid>
      <description>We&amp;rsquo;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&amp;rsquo;re test files which take it to the extreme. However, there are valid use cases for both shared context and shared examples and it&amp;rsquo;s worth understanding them.</description>
    </item>
    
    <item>
      <title>Postgres column tetris</title>
      <link>https://developing.enectiva.cz/2016/05/15/postgres-column-tetris/</link>
      <pubDate>Sun, 15 May 2016 13:25:00 +0200</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/05/15/postgres-column-tetris/</guid>
      <description>Enectiva deals with non-trivial amounts of data on daily basis. That&amp;rsquo;s not uncommon in any way, in the grand scheme of things it&amp;rsquo;s still nothing. However, it&amp;rsquo;s in the region where you need to think about the data and can&amp;rsquo;t just slap it into the database without performance suffering.
We are not Postgres experts but we take time and effort to learn about it so that we can leverage it efficient.</description>
    </item>
    
    <item>
      <title>Tweaking Capistrano environment</title>
      <link>https://developing.enectiva.cz/2016/04/28/tweaking-capistrano-environment/</link>
      <pubDate>Thu, 28 Apr 2016 09:49:00 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/04/28/tweaking-capistrano-environment/</guid>
      <description>Recently, we&amp;rsquo;ve been playing with our database setup in order to improve its resiliency. During the experimentation, we had multiple versions of the database compiled and running. To test everything, we temporarily needed to run db:migrate and related tasks against the new database.
Our assumption was that it would be taken care of by changing the credentials for the database to the new instance. The migration runs just fine, but at the end, it dumps the schema to a file.</description>
    </item>
    
    <item>
      <title>Duration in Go</title>
      <link>https://developing.enectiva.cz/2016/04/17/duration-in-go/</link>
      <pubDate>Sun, 17 Apr 2016 15:32:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/04/17/duration-in-go/</guid>
      <description>We, lazy developers, like when we don&amp;rsquo;t have to type a lot and things just happen. Naturally, there&amp;rsquo;s a limit to how much should happen and finding this limit is often the hardest thing. Especially because it keeps moving.
Ruby is very friendly in this way and takes care of many things for us, implicit type conversion among them. Go on the other hand requires more guidance from the programmer. Generally, it is a good thing, because it leads to more explicit and predictable code; however, the cost is verbosity.</description>
    </item>
    
    <item>
      <title>Context modifying blocks</title>
      <link>https://developing.enectiva.cz/2016/03/29/context-modifying-blocks/</link>
      <pubDate>Tue, 29 Mar 2016 18:51:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/03/29/context-modifying-blocks/</guid>
      <description>In Ruby code in general and in Rails code especially, there are situations when the global state needs to be modified. Yes, global state is bad and ugly but at the same time it&amp;rsquo;s ubiquitous and we have to deal with it.
Apart from &amp;ldquo;permanent&amp;rdquo; changes, it is often necessary to change the state just for a moment, i.e. a function needs to run in a limited/altered context. A naïve approach (and the only one possible in some languages) of implementing this might look like:</description>
    </item>
    
    <item>
      <title>Hash and an array as a default value</title>
      <link>https://developing.enectiva.cz/2016/03/06/hash-and-an-array-as-a-default-value/</link>
      <pubDate>Sun, 06 Mar 2016 13:01:05 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/03/06/hash-and-an-array-as-a-default-value/</guid>
      <description>Recently, I needed to schedule a set of operations over a fixed number of slots so that the number of operations in each slot is uniform-ish1. Because the number of slots was fixed, it made sense to initialize an array so that each item would have a default empty list of operations (thus avoiding the nil test when adding operations to slots).
schedule = Array.new(number_of_slots) { [] } This worked nicely for a time, but later came in a requirement to split the operations into groups while keeping a single schedule optimizing the total number of operations in each slot regardless of the type.</description>
    </item>
    
    <item>
      <title>Golang build tags</title>
      <link>https://developing.enectiva.cz/2016/02/14/golang-build-tags/</link>
      <pubDate>Sun, 14 Feb 2016 16:03:37 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/02/14/golang-build-tags/</guid>
      <description>Go compiler is capable of compiling source code for different platforms in any development environment (which, apparently, is a big deal and not that common). When your code is targeting multiple architectures, there might be parts of the code tailored for each one of them. Two options exist for defining such alternative code:
 suffixing file names by the targeted architecture (as seen in the os package) or build tags which are essentially just comments at the beginning of a file with a fixed structure.</description>
    </item>
    
    <item>
      <title>The case of case equality operator</title>
      <link>https://developing.enectiva.cz/2016/02/08/the-case-of-case-equality-operator/</link>
      <pubDate>Mon, 08 Feb 2016 20:16:32 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/02/08/the-case-of-case-equality-operator/</guid>
      <description>Ruby is a nice and easy to read language. There are, however, some quirks which might surprise you. Some of them are easy to deal with when you start learning it, because they come up often enough. Certain keywords fall into this category, probably the most common is elsif not being elseif or else if. A little less common is the switch statement. Most languages have switch as a keyword for the whole decision block and case for each branch, default for the default catch-all case.</description>
    </item>
    
    <item>
      <title>Multitenancy and uniqueness</title>
      <link>https://developing.enectiva.cz/2016/01/23/multitenancy-and-uniqueness/</link>
      <pubDate>Sat, 23 Jan 2016 14:51:32 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/01/23/multitenancy-and-uniqueness/</guid>
      <description>Enectiva is a multitenant application which means we take care to separate data of different customers and avoid leaks between them. Luckily, there&amp;rsquo;re are many gems which help with common use cases and augment Ruby on Rails code to restrict queries by default.
We&amp;rsquo;ve been using the multitenant gem since the beginning and it does exactly what we expect it to do. More precisely it did, until we ran into uniqueness validation.</description>
    </item>
    
    <item>
      <title>Go struct tag alignment</title>
      <link>https://developing.enectiva.cz/2016/01/17/go-struct-tag-alignment/</link>
      <pubDate>Sun, 17 Jan 2016 16:24:06 +0100</pubDate>
      
      <guid>https://developing.enectiva.cz/2016/01/17/go-struct-tag-alignment/</guid>
      <description>Over the past few months, we&amp;rsquo;ve been moving several computation heavy components of Enectiva from Ruby to Go. Our initial motivation for this move was performance — Go beats Ruby by orders of magnitude. After finishing that process, we&amp;rsquo;ve started to develop some of the new components of the Enectiva platform in Go from scratch; the most recent addition is API Librarian for collecting readings and other data points from customers.</description>
    </item>
    
  </channel>
</rss>
