Skip to main content

Posts

Decode Morse code from a wave file using SQLite

A recent programming puzzle from Wunderdog caught my interest for one simple reason: it had the word wave file in it. Music and audio-related technology is something close to my heart. Besides, I have not had a DIY project related to music in a while, so why not look into it. The conundrum is straightforward. A wave file contains morse code, and one must decode it to dash and dot letters. The choice of technology is free. A pragmatic developer would look into some popular audio processing library - in my case, something written in go - and write a simple program. I had something different in mind, though. I've recently read The Art of PostgreSQL book and done some exercises in more advanced Postgres features. Why not apply the lessons learned in morse code parsing? The outcome is Endeavour , a no-frills Python wrapper + some exotic SQL window functions. It is neither fast nor pretty, but it proves that analyzing waveform files with SQLite is possible.

A Finnish web developer works as a consultant

If you ask a random Finnish web developer to detail the projects they have worked on, I bet YLE (Finnish public broadcasting company) comes up. If you further ask to rank the projects, it would likely score high. The devs I've talked to and the Yle talks I've listened to have convinced me that taking a gig in Yle is indeed one of the most remarkable things to do in Finland. I'm not sure, but I think a US developer might not see working for the PBS as their career highlight. As a taxpayer, especially working in IT, it is fantastic that Finnish talent works on major, often publicly funded, megaprojects. The digital services are made well, robustly, and rate among the world's best. The developers enjoy working in such places because that all-knowing mentor colleague is sitting next to you. There are few Twitters or other desirable "web-scale" projects available locally. Not incidentally, this means that the barrier of entry is high to get these jobs. The Finnish ...

Best music of 2021

No recap of lessons learned this year. Instead, here is a collection of some of the best music from 2021. Proud to say that I succeeded in my goal of listening to more Finnish records! Shoutout to Radio Helsinki and its feature programs for keeping me on that path. Albums and EPs Handshaking - Garden Clogs Seeing Fedja Kamari perform live was one of the most memorable experiences this summer. The song "Näin kai taas lankesin" even in a formidable seven-and-a-half minute length, is a masterwork in tension-building and incidentally my most listened tune of the year. Richard Dawson, Circle - Henki Dawsons falsetto started to catch my ear while listening to the Finnish indie Spotify list. Slowly it began to grow on me. The rough, unpolished sound of the Circle with its unbridled energy makes me grin. Ichiko Aoba - Windswept Adan The soothing voice of Aoba's gives me the chills. Her impressive upper range combined with a dreamy flute produces a powerful emotional experience. T...

Note to self: use common collection functions

The Advent of Code in Elixir continues to be a humbling experience year after year. One of my weaknesses in programming puzzles and, in general, is a lack of intuition on which common collection operations to use. Or, to be more precise, since I don't know them intimately, I don't know when to apply them in code. It is way too often I get feedback on a code review on  why do you do this thing with a plain map or reduce while you could use this and that helper function . Often, one can replace a custom function with a more expressive composition of well-known "stock" functions. I think a recap is in order. I enumerate in this post the most useful ones for me - or at least those I get the most feedback from. These are indeed useful even in the basic CRUD app!  I took the names from Scala and Elixir standard libraries and checked that functions with similar names exist in Lodash and Ramda JS external libraries Chunk/Group/Split/Partition Make a list of lists based on a f...

Deciphering yet another mystery parameter - camera picture quality

I don't know much about photography and much less about image formats. The little I know comes mostly from web development. There I use images as semi-static assets, and I know how to work around the potential problems.  That experience was of limited use when I worked on end-user-created images on a React Native app I'm working on. I needed a crash course into JPEGs.  We use react-native-camera to take photos. Snapping one has an elusive option called photo quality . It is an integer in a range between zero and one, and in the example code, it was set to 0.5. Zero point five . What does that mean? Is that good? 0.5 does not feel that good. To me, a modern iPhone is more than 0.5? The default value is 1 though, is that better? I wanted to find out what turning that mystery knob entails. Spoiler alert: the JPEG quality is clearly explained in the JPEG Wikipedia article, but obviously, I needed to jump through some hoops to understand that. I want to go through some generic th...

When React state management is not enough, I use atoms

I'm a fan of Kent C. Dodds. He has an excellent blog , he holds office hours on Youtube  and he manages an active Discord community focused on helping developers make maintainable React apps. I especially appreciate the way he thinks about state management in React apps. It does not have to be so reliant on external libraries. React itself is a library for managing state, so why not depend on its built-in abstractions. On a React Native app I'm building, most (> 95%) of the state management is indeed done with the React primitives: useStates, Contexts, and Refs. It is a big pile of hook compositions, and that's the way I like it. If you are familiar with React and can read its documentation, you can understand the code. There are a handful of places where using the primitives fall short, though. In these spots, plain old React hooks would require excessive glue code and would ultimately be confusing. Also, skipping needless renders in components such as forms can be tric...

100% unit test coverage

I write a lot of stupid and useless unit tests. I confess that I'm aiming towards the elusive 100% test coverage. Sure, I'll never get there, and I realize it is not even a desirable goal. After an assessed threshold, we start to get diminishing returns. Why do I keep writing wrong tests then? Which unit tests should I leave out? My case is that it is tricky to write a large codebase with only valuable tests. I dare say that some (minority) of the essential tests might have outright bad practices where they end up testing how well I can mock stuff. The value of the test is not predetermined; hence I keep writing a lot of seemingly poor ones. There is an argument that high test coverage does not strongly reduce bugs and increase maintainability. That is likely true. Nonetheless, it is not so apparent which tests will avoid the most bugs or are the most useful in refactoring in the long term. The clichĂ© is that requirements change, sometimes towards unknown directions.  It is mor...