My Programming Escapades
Andraz Bajt
Rename rebase with git
Want to perform a git rebase in which you rename a file without pesky conflicts? tl;dr git filter-branch -f --tree-filter "git mv ORIGINAL_FILE_NAME NEW_FILE_NAME || true" -- $(git merge-base origin/master HEAD)..HEAD git rebase origin/master Ever wanted to rename a file you created/modified in a pull request but also wanted to keep the pristine history you worked hard for? Well tough luck you can either push a new commit to rename it (and keep old commits with the old file name) or resolve a bunch of pointless conflicts.
2020-04-20
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.
2020-01-15
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.
2018-05-25
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.
2018-01-25
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.
2018-01-24
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.
2017-09-01
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.
2017-08-30
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.
2016-09-21
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?
2016-02-24
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.
2015-05-03