This basic principle has worked for me many times, so I figured it might be worth to share the process. In this instance I wanted to write a label printer driver in Go. A barebones implementation exists in Python that works to print a test image. The idea If I can reach parity with the Python-based implementation (from now on referred to as the reference implementation), I can build on top of a…
I recently bought a Drop CTRL mechanical keyboard. (am not sponsored & I actually dislike the company) I debated myself for a long time whether to buy the keyboard, due to these problems: it has ANSI layout (I’m used to ISO layout), and the keycap labels don’t match either so some keys' labels won’t match what actually comes on screen when I press them. Keycaps can be changed, so…
I have recently been writing system-level software that needed many steps with filesystem mounting etc. - things you generally need to do as root. For security I wanted to make the program enter root only for the steps that actually need it. Starting situation In pseudo it started like this: func logic() error { mountFoo() mountBar() return nil } func mountFoo() { dropPrivileges := enterRoot()…
What is SAML? Security Assertion Markup Language (SAML) is an open standard for exchanging authentication and authorization data between parties. Source: Wikipedia SAML is often used for single-sign on (“Sign in with Google”, “Sign in with Twitter” etc.). It means when you want to log in to example.com, example.com can trust & use an external authentication provider to…
The problem /sys/class/hwmon/hwmon2/temp1_input reports your CPU temperature. But the next time you reboot, the path might be /sys/class/hwmon/hwmon1/temp1_input. => The path is not stable, so you cannot easily refer to it. Example use case where you might need stable paths is use in i3status (it’s the status bar in the animation on top of this article). The solution Let’s write a udev…
I wanted to see latency graphs for my internet connection, as well as to some various servers/devices: Why? Having multiple ping targets gives you a pretty accurate view of the health of your internet connection, and also any networking issues for the target devices themselves. If all the lines go up (latency increases), the problem is in your internet connection. However, if only one target…
The use of 0-results-as-a-loading-indicator is really prevalent. It is horrible UX, as it is directly lying to the user. Why is this a problem? “0 results” and “data is being loaded” are two different things, so we shouldn’t collapse them as the same message to the user. Just today I opened Google Drive on Android and the data loading took so many seconds I had time…
Multi-arch image means that you can run the same $ docker run joonas/cool-app command on different hardware platforms like PC (amd64) and Raspberry Pi (arm). Recently when publishing said style images for Varasto, I learned quite a lot about the tooling and some tricks. But I was really frustrated about the shortcomings, so I want to share my findings to make it easier for others! Tip: lots of…
My blog has been running on Jekyll since early 2015. I am very grateful for how easy and out-of-the-way it has made running my blog. I haven’t touched (= updated/maintained) my Jekyll installation even once over that six years and it has just chugged on - letting me focus on content. However, I’ve built other static sites with Hugo for years, and I knew I wanted to migrate my blog to…
Recently I learned a lot more about UEFI/BIOS than I would’ve liked to, when I was configuring my new exotic system’s boot process. It just goes to show you that when you step away from the well-traveled path, you’re going to run into stupid problems and have to understand deeper about how things work. So I’m sharing what I learned. Legacy BIOS To better understand UEFI, we…
I recently bought a MIDI controller / keyboard / drumpad combo thingie. Not because I wanted to make music - but because of the pads and knobs that I can use to control things like jump between workspaces adjust the audio volume in my PC etc. What can I do with it? Lots of things! I’ve already got implemented: Piano keys Various key mappings to: Toggle audio between speakers and headphones…
I recently got a surprisingly large AWS bill which had me immediately realize something was wrong, because I did not host anything that should consume dramatically more resources month-over-month. Happy AWS billing day: Why is S3 costing so much? The overview just points at S3. The cost explorer had some breakdown options: This revealed that it is the (S3) outbound data transfer that is causing…
I wanted to connect a keyboard-mouse-combo to a virtual remote desktop running inside a Docker container. My use case I have a wall-mounted Android tablet displaying always-on content (“info screen”) in my home: For security reasons the tablet can’t reach the internet and actually has a VNC viewer that displays a virtual framebuffer from inside a Docker container on my server.…
I wanted to get Spotifyd working in a Docker container. Turns out, audio and containers can be tricky. In this post I’ll share what I learned on Linux audio subsystems and considerations on container audio. If all you want is to see “how to get Spotifyd to work with Docker”, see the accompanying Spotifyd Docker image that I released. What is spotifyd? Spotifyd is a headless…
Lately I’ve been fascinated with the concept of “quantified self”. What does it mean? The quantified self refers both to the cultural phenomenon of self-tracking with technology and to a community of users and makers of self-tracking tools who share an interest in “self-knowledge through numbers.” (source: Wikipedia article on “Quantified self”) tl;dr: record numbers…
I wanted to display news in my Home Assistant dashboard. Home Assistant has “Feedreader” integration which supports getting data from an RSS feed into HA’s event bus, but it doesn’t mention a way of displaying the entries (or storing them as sensor attributes that would be accessible from UI). There’s 3rd party integration and an UI component to do the job, but I…
I compiled Turbo Bob (a build system) with a bug that prevented entering a build container, and since Turbo Bob is built with itself, I could not build a working binary again - chicken-egg problem. (Of course I could download an old release, but I had some unreleased work I was benefiting from that the old binary included, and while Bob builds fine with just Go compiler, I didn’t want to…
I was improving performance for Varasto and there was one unit of work that was easily parallelizable (= run on all CPU cores) to gain some speed. I’ll share my learnings in graphical tooling to help measure/debug how efficiently your parallelization works. go tool trace The graphs I’m about to show, Go actually has internal tooling for - go tool trace, to generate (and even show)…
When I started making documentation for Varasto, I thought about the numerous times I’ve seen projects with links to documentation that have resulted in a 404. I think I came up with a cool way to help with the issue. tl;dr: typesafe documentation links are checked by the compilers on backend and frontend! Motivation To build motivation first, let’s first look at the benefits and…
SVG, or Scalable Vector Graphics, is a file format for vector drawings. I had a problem to solve - I wanted to animate an SVG from JavaScript. I’ll describe how and what I learned on how SVG paths work to solve my problem. The problem I wanted to animate Varasto’s vector logo - to make the “hard drive LEDs” (the circles on the right) toggleable on/off individually: The path…
Kernel probes allow you to dynamically attach debug points to the kernel (or even to extend it to some extent with persistent hooks). You can attach not just to syscalls, but also to many functions inside the kernel (they have to be exported functions though). Dynamically means, that you don’t have to recompile the kernel and/or restart your computer - it’s pretty cool! Disclaimer:…
I didn’t really want to write about politics in my blog - in fact I wrote a lengthy, critical post about Trump before his election victory and just wound up leaving it unpublished because I didn’t want my blog to be about politics. But this situation really grinds my gears to see the world pump out a continuous stream of news articles and individuals discussing about the coronavirus…
I still love Go and it’s the best language I’ve used - but like in mature relationships, I’ve aware of both the good and bad parts of the relationship. Go is still, compared to many popular languages, simpler language - but many times when people claim Go is a simple language what is being implied is that Go is minimalistic & it scoffs at unnecessary features. This post is about…
My issues are rare enough to warrant switching to another modem, so I just hacked around it by writing a small piece of software that reboots the modem to try to get the connection back up. It pings a few known IPs to see if the internet is up, and if it’s done for a defined duration, it’ll reboot the modem. There are drivers for a few different types of modems (since I’m using…
Last year I discovered a serious security vulnerability (path traversal) that enabled me to read any file on the server GunDB runs in - I was even able to steal AWS credentials from the demo server. Discovery I was having a chat with a buddy of mine about how much I dislike JavaScript, and I mentioned someone even built a database product with it. I also remember GunDB having let’s say.
I’ve got so many good automation ideas from other people, so it’s fair that I pay it forward by listing my own automations so other people can get ideas! I also describe my setup, gear and my no-cloud policy etc. My automations A lazy dump of my automations: When nobody’s home and I open the apartment door (door/window sensor) and it’s dark, a hallway light turns on. When…
Summary: PayPal suspended my account without warning and didn’t efficiently tell what’s wrong or give me tools to fix it, causing me trouble with different vendors, and PayPal’s process for resolving this had many conflicting advice and everything was unacceptably confusing. In the end I found out they just needed to fulfill some “Know your customer” EU regulation and…
I’ve been quite vocal about my distaste for most things Microsoft before, and here comes another rant, so buckle up.. This morning, my old Win7 computer with a 64 GB C:\ drive was almost out of space. I had like 60 MB left, so it wasn’t out just yet. So I went to fire up the Disk Cleanup tool. Upon running it, I discovered that my drive filled up entirely - 0 bytes left.
.. from a perspective where you are not running your VM on a Google datacenter - if you would be, then this would be a bit simpler because the logging driver autodiscovers credentials and more options automatically for you. I wrote this because there were bits of advice scattered around, but no single “do this to get it working” anywhere. Terms: gcplogs - the built-in plugin of Docker…
I find this to be highly annoying: Is plain old “if” ambiguous? Is “if and only if” (abbreviated to “iff”) more powerful than a plain “if”? Consider this statement: Joonas is happy if he slept well and ate food Translated to code: if (sleptWell && ateFood) { happy = true } Why isn’t there an operator in programming languages for…
TL;DR; control all Zigbee devices (Philips Hue, Xiaomi smarthome, IKEA Trådfri etc etc.) more securely, more cheaply, more creatively, more robustly, more privately and be in total control! You still need some hardware to interface with Zigbee, but using something like Texas Instruments' CC2531 brings a lot of benefits. More on this very closely below! Why & overview Why would I want a custom…
Continuing the series of “Microsoft sucks” rants. Windows 10 update bullshit Windows 10 just updated itself, and once again restarted my computer without asking for permission. I thought I disabled the automatic restarting, (which even requires pro version because, well, M$FT decided home users don’t deserve autonomy even for advanced users through registry tweaks) but apparently…
I believe I have came up with an acceptable compromise for the logger mess in Go. This is an approach that embraces the Unix philosophy of pipes and plaintext streams. TL;DR: If you want to see the end result as a demo, scroll to the “Demo code” section! TL;DR 2: The standard log.Logger is enough, just use it everywhere as pipes and we’ll compose more on top of it! Defining the…
Your periodic reminder that strace is awesome.. On Windows you basically know which partition a file is hosted on by looking at the drive letter. On Linux there’s just a global namespace and it is more difficult to know the partition of a given file (although I think the indirection in the Unix design is better). I remembered that $ df can show me this info: $ df /home/vagrant Filesystem…
For quite some time, I’ve been having lots of problems with GMail spam detector’s false positives. Loads of legitimate mail going in spam folder. I’m glad I remembered to check the folder, because the above kind of mail is really fatal if you miss it (credit card expiration => service suspension => VMs going offline). Lately these kinds of mail have gone to spam: eBay “Help…
Backstory Recently I purchased some Unifi gear, and I installed the controller software mainly as a test, and thus I did not immediately save the username and password in a password manager but instead I probably wrote it down in Windows Notepad, and Windows 10 being a total dick, just one day restarted losing what I had in notepad. Some time passed, and I forgot not only the password, but also…
.. well I’m more like “soft-deleting” Facebook. I just deleted my Facebook app from my Android phone, and still plan use Facebook on my desktop. But this will decrease my Facebook use significantly: Wake up: check Facebook on phone Waiting on something: check Facebook on Phone Going to sleep: check Facebook on phone Why? I want to do this, even if just symbolically because…
What is chaining? jQuery at least popularized this pattern: $('.someElement') .attr('title', 'Changing some title') .text('here is content for you') .on('click', () => { alert('clicked'); }); The above code could also be written like this: $('.someElement').attr('title', 'Changing some title'); $('.someElement').text('here is content for you') $('.someElement').on('click', () => {…
Perkele! Finland just turned 100 years. Growing up, I was never quite patriotic. I used to think that Finland is an insignificant country with shitty weather. I still think we have a shitty weather. But the more I’ve grown up, the more I’ve realized that in the grand scale of things Finland is actually pretty awesome! I used to idolize the USA, I think because it’s a powerful and…
Why Slack is inappropriate for open source communications A Keepass-like project I’m working on My woodworking hero Matthias Wandel made me have an epiphany: how CPU works on the lowest of levels. Addition is basically just chained XOR gates, and a XOR gate is basically just transistors anyway. All this can be explained with wood and marbles! And in the end all higher constructs like 2D, 3D…
I got a newsletter from Toggl (a time-tracking app) that they are hiring and that they had a coding quiz. I decided to take the quiz just for shits and giggles. They had two tests I took: backend dev frontend dev I failed both tests. First test: backend dev Here are the questions and my answers: I later checked this as correct. I think I got most of those right, except for maybe the concurrency…
Have this innocent looking code in Golang: func incrementWithoutLocking() int { counter := 0 incrementCounter := func(done chan bool) { for i := 0; i < 1000000; i++ { counter++ } done <- true } // create a channel to synchronize when both goroutines are finished done := make(chan bool) // run two goroutines in parallel, both incrementing the shared counter go incrementCounter(done) go…
UPDATE, IMPORTANT Some of the claims in this post are inaccurate. The ACKed-but-undelivered problem lies either in my router or ISP - not Azure’s fault. Until I research this topic more and update the article, these problems still stand: Azure has a forced artificial limit, disconnecting session with >= 4 minutes of radio silence. There is no technical requirement for this as the IP should…
For lack of a better term, I call this “cute coding”: { ... weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'), ... } That is essentially the same as: weekdaysShort : [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ], Sure, it’s a bit longer BUT: It’s cleaner, because it’s not a hack. It does NOT incur runtime performance penalty. Intent is 100 % clear, while…
I still see this confusingly often, even with Twitter’s timeline embedding feature. Protocol relative URLs look like this: <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script> There is absolutely no reason to do that (anymore)! Take a look at the following table (perspective = the URL over which user the user opens the page) of the results: Scheme in URL Browsed…
Every website will get hacked? Yes. It is starting to look like every website - even the major ones, will get hacked. It is not a question of “if”, but “when”. Just now in the news is that Yahoo was compromised and the result was a leak of names, usernames, passwords and other personal data of 500 million accounts - almost twice the United States population. Here are…
There are so many reasons that I cannot just let this go anymore, and instead I’ll spend my precious time to write this blog post that gives me absolutely nothing in return, except the fact that writing this feels therapeutic. Windows 10 bloatware, forced apps When I got my laptop with ~120 GB SSD, these weigh in: C:\Windows 17.4 GB C:\Program files + C:\Program files (x86) ~ 0.8 GB (this is…
Now that I’ve been actively messing around with Docker for more than 6 months, and run production software on top of it, it’s a good time to share my findings. tl;dr: Docker has some disgusting warts, but the sum of positive and negative points is clearly on the positive side. I fucking love Docker for the problems it solves, as I get to focus on the actual problems I’m solving…
Unfortunately, redirecting to m. prefix for mobile browsers is quite popular. The downside of this is that when people share a link to the content, and if another person follows the link on a desktop or a laptop, the view is horrible: If you want to use separate domain for mobile, at the very least make sure the “desktop” link takes you to the same content: After clicking it, it only…
I love to travel, and have tried to visit at least a couple of destinations each year. Yesterday for fun I prototyped an interactive map that shows the destinations I’ve been to: It helps to have a tool with which you can pan+zoom and visually see the places you have yet to visit.