Apr 28, 2016 · 2 minute read · Comments
ruby
Recently, we’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.
Read On →
We're looking for developers to help us save energy
If you're interested in what we do and you would like to help us save energy, drop us a line at jobs@enectiva.cz.
Apr 17, 2016 · 3 minute read · Comments
golang
We, lazy developers, like when we don’t have to type a lot and things just happen. Naturally, there’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.
Read On →
Mar 29, 2016 · 2 minute read · Comments
ruby
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’s ubiquitous and we have to deal with it.
Apart from “permanent” 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:
Read On →
Mar 6, 2016 · 3 minute read · Comments
ruby
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.
Read On →
Feb 14, 2016 · 2 minute read · Comments
golang
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.
Read On →
Feb 8, 2016 · 3 minute read · Comments
ruby
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.
Read On →
Jan 23, 2016 · 2 minute read · Comments
rubyruby on rails
Enectiva is a multitenant application which means we take care to separate data of different customers and avoid leaks between them. Luckily, there’re are many gems which help with common use cases and augment Ruby on Rails code to restrict queries by default.
We’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.
Read On →
Jan 17, 2016 · 3 minute read · Comments
golang
Over the past few months, we’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’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.
Read On →