A Book to Live By

Ok, I may have gotten a bit carried away with the title. But really, this book has changed my way of thinking about everyday problems.

Algorithms to Live By is an enlightening read. It helped me look at life through a prism of a problem solver. Suddenly everything we do can be looked at as a problem waiting to be solved. From sorting my collections, to choosing whether to eat at a new restaurant or an old favorite… It can all be mathematically analyzed – and this book helps you reach the answer.

Unlike many algorithm books, this isn’t a heavy read. Quite the opposite. With fun, relatable examples, it pulls you in and gets your brain buzzing. It won’t leave you hanging, either, because the answers are handed to you in a clear way. It almost makes you wish you had a problem you could apply all this new knowledge to.

Sadly, I lost my copy at an airport while traveling. I’m hoping it made for a nice read to somebody else. I’m definitely getting another copy, though. This is one I want on my shelf.

I may get commissions for purchases made through links in this post.

Decisions, decisions…

Quite often, I’m faced with difficult decisions. Choosing our next flat, our next investment, where to take our next vacation (once we can travel again). There are too many factors for me to take into account. I simply can’t reach an educated decision in my head.

Sure, I could do a pros/cons list. But really, that doesn’t work very well. Mostly because some factors are more important than others. So the number of factors in each column isn’t good enough an indicator of the best choice.

Luckily, there’s a solution. It’s called a decision matrix. The business world has been using it for many years to solve difficult dilemmas. You could create one using a simple Excel sheet. You could event jot one on paper. But, since you’re here, you know I have a simpler suggestion.


Allow me to introduce Choice Pro. It’s a free Android app that allows you to leverage the decision matrix in a friendly, accessible way. I developed Choice Pro because I saw the value of decision matrices. Yet, I was not pleased with the overhead involved in setting them up – making them a bit less accessible.

Of course, an app has other advantages: you can check your past decisions; you can make random decisions when all options are as good (or as bad!); finally, you can easily share the results with others.

Give it a spin!

Boil with class

One of my takeaways from Rich Dad Poor Dad was to invest in higher quality products. Note that I’m not saying “invest in expensive products”. Expensive does not always equate better. That’s why I do my homework.

In truth, I learned this lesson the hard way myself. I lost count of the number of cheap kettles I threw away. They short circuited, melted, broke apart… Eventually I switched to premium kettles. I think I only had to buy two in 10 years. I had to buy a second just because I moved countries.

Premium kettles offer more than just longevity. They tend to come with better warranties. They can boil water faster. They let you control the temperature, in case you’re making green tea. They offer a simmer option, so that if you forget you boiled water, the water isn’t cold by the time you remember. Other nice features to have include having a swivel base or greater capacity. To be fair, they also tend to look nicer on the counter.

The model I have is Sage‘s The Smart Kettle (BKE820UK) which I bought for £90.00 back in 2016. It got broken once, potentially by the cleaner drenching it in water. Sage offered fair compensation towards a new Kettle. It’s harder to come by now, but similar, newer models exist.

I may get commissions for purchases made through links in this post.

Work, Droid!

It often feels like our tech no longer works for us. It’s us who are working for it. Charging it up, responding to constant notifications… You get the point.

I’m trying my best to set things right. Technology is a tool and it’s there to make our lives easier.

One way of achieving that is automating tasks. I have tried many apps in the past trying to achieve this goal: IFTTT (now a paid service), Llama (no longer available on the Play Store) and a few others. The one I ended up keeping is Autoroid.

Autoroid is a free Android app that configures your phone based on certain triggers. I have set it up to silence my phone at night, wake it up early on a weekday and late on a weekend.

I don’t leave home much now because of the pandemic and a remote work arrangement. But when I did, and eventually will again, it has other cool features. For example, I had it silence the phone and dim the screen when I’m at the cinema (using my geolocation).

Whatever your routine is, I’m sure there are some menial tasks you do with your phone. See how many of those you can set up once and never worry about again. Then do something cool with all that extra free time.

Small and Mighty

A working computer the size of a credit card? For $35? Sign me up!

The Raspberry PI, if you haven’t heard of it yet, is an amazing machine. Despite its tiny size, it is packed with features. It can run its own Linux version, as well as a few other operating systems, including a limited version of Windows 10.

So what can you do with one? Very cool stuff. I’ve used mine as a media centre, a retro gaming station and most recently, as a magic mirror.

To focus on efficiency, the latter is by far the most valuable for my wife and myself. Our Magic Mirror tells us the time, the weather for the next few days, our upcoming events and even shows us the word of the day. Oh, and it’s a mirror.

I really could not recommend the PI enough. Get one now, figure out what to do with it later. Are you still here? Go!

The small print: you will also need a power supply and a memory card. You can grab each for as cheap as $8. Depending on your project, you may need other accessories, such as a case, a keyboard, a mouse, a wireless dongle and so on.

Take a Note

This one’s dedicated to my wife.

One thing I’m really terrible at is remembering things. I’m just too scattered. So I had to come up with a way to stop forgetting important things. From groceries we’re running out of, to project ideas, to movies I want to watch.

I found two tools that perfectly fit the bill. The first is Google Calendar. Synced across my devices, I always have access to my reminders saved in the calendar. It also helps me by bringing up the reminders when they make sense. If I’m doing my groceries shopping on a Friday, it makes sense to set the reminder to Friday. If I need to call my accountant, Monday morning might be a reasonable time. I even have a calendar shared with my wife that is presented on our magic mirror (more on that in a future post).

The second is Google Keep. Better for general lists, Google Keep is also synchronised across my devices. I can access it from my Windows machine, my Mac and my Android phone. I have a note for each project idea that comes to mind. I have a To Do note. I have a groceries note. I have a note with movies I’d like to watch. Conveniently, Keep lets you take plain, text only notes but also check list notes.

The reason this post is dedicated to my wife is, she took it up a notch for me. I used to lazily postpone adding items to my notes. Why do now what you can procrastinate, right? Wrong! I kept forgetting things despite having these great tools! But my wife won’t let me postpone adding items. She always urges me to note things down right away. And you know what? That really works. I hardly forget anything now. Happy days!

Clean the Lint Out

One of the nicer tools a developer has is the linter. The linter helps you conform to a clean, unified and easy to read format of your code. When I join a project that has no automated lint set up, adding lint to the flow is one of the first steps I take.

In the past, I used to set up lint on the build server. That way, no pull request (PR) would get merged which breaks the formatting rules of the project. However, this had a few flaws. First, unless squashed, your git history had lint fix commits all over. Second, it would really slow you down as a developer. You’d create a PR, and then wait for a few minutes – only for the build server to tell you your formatting is wrong.

It was only fairly recently that I learned about git hooks. In a project I joined, they were using them in the pre-push step to prevent you from pushing code that was not properly linted. Pretty cool. But we could do better. If we moved linting to the pre-commit step, you couldn’t even commit a file that was not linted. Now, you don’t even need a separate commit for the lint fixes.

The linting script on that project was also scanning the whole project. This works really well when your project is already linted. However, if you’re setting this up on an existing project, you could never commit anything without fixing the whole project. To fix that, I rewrote the lint script to only iterate just over the newly staged files. For Macs, the script looks like this:

#!/bin/bash

echo "Running lint..."

git diff --name-only --cached | grep "\.kt" | while read fn; do ktlint "${fn}"; done
RESULT_KTLINT=$?

[ $RESULT_KTLINT -ne 0 ] && exit 1
exit 0

For Windows, it looks like this:

#!C:/Program\ Files/Git/usr/bin/sh.exe

echo "Running lint..."

git diff --name-only --cached | grep "\.kt" | while read fn; do ktlint "${fn}"; done
RESULT_KTLINT=$?

[ $RESULT_KTLINT -ne 0 ] && exit 1
exit 0

The above examples run ktlint, for Kotlin projects. You should be able to port them to any other language fairly easily.

There’s still one problem. Every developer has to copy the relevant script manually to their .git/hooks folder (and name them “pre-commit”). This can be solved by automating the copying task. In gradle, it can be done by updating your app build.gradle like so:

task installGitHook(type: Copy) {
    def suffix = "macos"
    if (Os.isFamily(Os.FAMILY_WINDOWS)) {
        suffix = "windows"
    }
    from new File(rootProject.rootDir, "automation/scripts/pre-commit-$suffix")
    into { new File(rootProject.rootDir, '.git/hooks') }
    rename("pre-commit-$suffix", 'pre-commit')
    fileMode 0775
}

tasks.getByPath(':app:preBuild').dependsOn installGitHook

And voila! The first time a developer builds the project, the appropriate git hook gets installed. Don’t you just love automation?

What is That Bulge in Your Pocket?

For years I’ve walked around with a standard manly wallet. I had two problems with it. The first – it was made of leather. I’m not a fan. I try to avoid leather products when I can. The second – it was bulky. Whether I kept it in my front jeans pocket or the back one – it was absurdly noticeable. So I started looking for alternatives.

The Klips. Why
would you get that?

Kickstarter is the source of many interesting innovations. It is also the source of absurd ideas (in my humble opinion, of course) such as Klips, pictured on the right… Klips was never funded. Not all Kickstarter wallets are bad, though…

And then I came across the Dash wallets. I pledged to their Kickstarter project in October, 2018. It was $18 at the time for an early bird. By late January, 2019 I had my wallet in hand. It was everything I hoped it would be. Extremely slim. With good storage for my cash and cards, I was perfectly happy. Oh, and no leather! Nice. I also liked the pull tab to access the cards and the RFID protection.

Now this is what I’m talking about.

In February this year (2020), I pledged to their second iteration. The price was the same, and at $18 I was happy to have a second wallet. I even bought a couple for my dad and brother. The second iteration introduced silicone grip dots to hold your cash better.

I’m such a fan I even got one of their third iteration models, which arrived late July. This time, they introduced a stacked card mechanism to the pull tab (see below). With the pandemic, I haven’t had a chance to enjoy it much. But I’m looking forward to! Honestly, I could not recommend this wallet enough.

Behold… Stacked cards!

Out of the Darkness Comes Light

One topic I’ll probably be writing about a lot is batteries. I believe I may be a bit obsessed about the matter. I keep my devices charged whenever possible. I’m constantly aware they are living on borrowed time.

I recently switched back from using MacBook Pros to Windows 10 on a Dell XPS. I found out Microsoft removed the option to automatically dim your screen on battery. Since I haven’t used Windows in a while, this was a surprise to me.

I started dimming the screen manually every time I unplugged my laptop. Then setting the brightness back up when plugging in. This did not always work for me. Sometimes I forgot to do it. The rest of the times just felt… Repetitive.

So I thought to myself – surely this could be automated. I did a little bit of digging. Guess what – it CAN be. I’ll save you the trouble of investigating this yourself. You will need a little (very little, I promise) technical knowledge.

  1. Download NirCmd. You probably want the 64 bit version. You can use another command line tool that can toggle the screen brightness if you prefer.
  2. Move the NirCmd files to C:\Program Files\nircmd.
  3. In that folder, create a new text file and name it DimScreenToggle.bat.
  4. Open the new file in NotePad or your favorite editor, and paste the following into it:
@echo off
set DimScreen=""c:\Program Files\nircmd\nircmd.exe" setbrightness 0"
set UndimScreen=""c:\Program Files\nircmd\nircmd.exe" setbrightness 100"
set Scr="%temp%\DimScreenToggler.vbs"
set VB=echo^>^>%Scr%
if exist %Scr% del %Scr%
%VB% Set oWMIService = GetObject("winmgmts:\.\root\CIMV2")
%VB% Set cItems = oWMIService.ExecQuery("SELECT * FROM Win32_Battery")
%VB% For Each oItem In cItems
%VB% iStatus = oItem.BatteryStatus
%VB% if iStatus = 1 then WScript.echo "On battery" Else WScript.Echo "Mains operation"
%VB% WScript.quit iStatus
%VB% Next
cscript //nologo %Scr%
IF %ErrorLevel% EQU 1 (start /b "Dim Screen" "%DimScreen%") ELSE (start /b "Undim Screen" "%UndimScreen%")

The above creates a script that checks the power source and sets the screen brightness accordingly: to 0 if on battery, or to 100 if plugged in. You can adjust these numbers to fit your preference.

  1. Save the file.
  2. Launch your Event Viewer (Windows Key + R, then type in eventvwr, and click OK.).
  3. On the left of the Event Viewer window, expand System.
  4. Next, unplug your laptop. Wait for a second or two, and plug it back in.
  5. From the menu, select Action -> Refresh. You should see two new events at the top. Note the Event ID.
  6. Right click on one of the two events, and then on Attach Task To This Event.
  7. In the new Create Basic Task Wizard window, fill in a name for your task (Toggle screen brightness by power source would work). Click Next.
  8. Click Next again on the following screen (When an event is Logged).
  9. In Action, keep the selection on Start a program. Click Next.
  10. Click Browse, then find the DimScreenToggle.bat file you created earlier. Select it and click Open.
  11. Leave the rest as is, and click Next.
  12. Tick the Open the Properties dialog for this task when I click Finish checkbox. Click Finish.
  13. In the properties window that opened, go to the Triggers tab.
  14. Click on New… to add a new trigger.
  15. In the Begin the task dropdown, select At startup.
  16. Tick Delay task for, and set the time to 5 seconds.
  17. Click OK to dismiss the new trigger window and OK again to dismiss the properties window. You’re done!

To test your new setup, try unplugging your laptop. It should dim the screen almost immediately. Plug it back in to see the screen brighten up.

With this setup, expect a significant boost to your battery life. Let there be light!

Take My Money! (Part 2 of 2)

In my previous post, I mentioned figuring out what I want to buy early helped. In short, it let me wait longer for the right price. There is another reason why figuring it out early helps. It also means I may be able to order it for much less directly from China.

It’s surprising how many products on sale you can find for a fraction the price on AliExpress.com. AliExpress is kind of like a Chinese Amazon. You can find virtually anything there. And it’s CHEAP. The catch? You often have to wait for about a month before you get your order.

Since 2013, we have another alternative. You probably encountered it already. It’s called Wish, and it is American. Similarly to AliExpress, you can find almost anything you can think of there (and something you would never think of!). And similarly, it’s dirt cheap and takes up to a month to ship. If you use my link above, both you and I will receive money in credit.

At some point I’ll highlight some of the more useful products I found on AliExpress. So stay tuned! Oh, and feel free to share your finds in the comments section.

I may get commissions for purchases made through links in this post.