Moving to Hugo
If you've been here before you might notice the site looks different. Indeed I moved my content to yet another platform (first it was blogspot -> hakyll). I wanted to publish something but I ran into issues: my toolchain did not work. See, I've been doing less Haskell on my machine lately and negligence led into my setup rotting (as I did upgrade my machine quite a bit). Truth be told the infrastructure was not designed to last the test of time.
Linear time sorting
Did you know that you can sort data in time linear with respect to the lenght of said data? Some people dismiss linear time sorts because they've learned that n log n is the bottom bound for sorting an arbitrary input. But n log n is optimal!? Let's even sketch out a proof. Any function that sorts an array of elements will in fact figure out a permutation of elements into a sorted order.
Integrating Jira into Google Sheets
So I got a (recurring) task to compile some stats from Jira. You now, some filtering and agregation. Possibly a pivot table and a chart. Sounds like a perfect task for spreadsheets. But Jira doesn't have spreadsheets - at least without addons, but that is not an options for me. So I decided to use Google Sheets. And figure out a way to automatically fetch data from Jira because there's no way in hell I'm doing that manually every time.
NixOS install & labor pains
The Back Story My first foray into world of Linux happened with Red Hat Linux 6 (original, not the enterprise one). It was magical but it didn't stick. See, I was a kid who liked video games. So it was back to Windows until I finally got serious about programming and discovered I the development environment on Linux. So I formatted my hard drive and installed Ubuntu. I quickly learned absorbed information and slowly got bored.
Implementing apply on tuples in Scala
One of the first things you learn as a newcomer to Scala is the difference between a list and a tuple: a list must be homogeneous but a tuple can be heterogeneous. That is all elements of a list must have the same types but a tuple can contain things of different types. A direct consequence of this is that a list can define a by-index accessor and a tuple cannot.
Dockerless Services (with Nix)
So you want an “isolated” MySQL “service” but don't want to (or are not able to) run Docker/rkt/LXC/whatever? Here are the tl;dr steps: cd /tmp mkdir mysql-1 cd mysql-1 nix-shell -p mysql mysql_install_db --datadir=$(pwd) mysqld --datadir=$(pwd) --socket=$(pwd)/socket & mysqladmin -uroot -h127.0.0.1 password <REDACTED> mysql -uroot -p<REDACTED> -h127.0.0.1 ... Why? My motivation for this was running a database on a machine with a specially tuned kernel that did not support containers.
TDD-ing a toy sized project
Just recently I was porting a toy sized parser combinator library (a proof of concept) from Haskell to Python. You know, for educational purposes. It turns out I'm not smart enough to keep the complicated types (and explicit laziness) in my head even for such a small project. So my solution was to do TDD. To clarify: I wanted to test happy paths through my functions to make sure at least types fit together.
Repairing a corrupt Git repo using a clone
Quite recently I managed to make myself a corrupt git repository due to a file system failure. See, git stores everything in content addressable blobs - the file name of something is it's hash. Which lends itself nicely to checking repository integrity - it keeps out malicious attackers as well as my file system problems. I already hear you saying: Why not just make a new clone, git is distributed anyway?
Lazy unary numbers
We are used to encoding numbers on computers in binary. Binary is the “simplest” base that yields logarithmic length though it may not be optimal. But can we do simpler? How about unary? Unary is often used with Turing machines where we don't care for efficiency and I will assume this same stance. Let's forget about efficiency and explore what can unary numbers do that binary can't. Specifically lazy unary numbers as otherwise the systems are equivalent.
Cheap tagged types in Scala
Sometimes you want to distinguish between different types that have the same underlying representation. For example both UserId and ProductId could be represented by Long. The usual solution is to introduce wrappers in order to make the distinction safe. case class UserId(id: Long) case class ProductId(id: Long) But this introduces runtime overhead of boxing and unboxing over and over which may add up in some cases. Luckily Scala 2.10 introduced value classes.