Kartones Blog

Be the change you want to see in this world

Book Review: System Design Interview

In the past I failed one job interview because I didn't asked enough critical questions and designed a system wrongly, so I decided to strengthen my knowledge about the topic and recently read the following book.

Review

System Design Interview book cover

Title: System Design Interview – An Insider's Guide

Author(s): Alex Xu

At more than 300 pages, it is not a small book but one that you can easily get absorbed by and read fast (even taking notes). It contains lots of scalability advices and tips, distributed among 15 (simplified) real-world scenarios. Each one is presented as a one-liner sentence with the exercise, like "Design a rate limiter", "Design a web crawler" or "Design Youtube". Then details the critical pillars to define, goes on details with each one, sometimes iterating adding complexity and features on each iteration (e.g. high availability, insane scalability, multiple devices, ...), and finally wrapping up with some closing details, extra points to maybe discuss if enough time, and the like.

There are many diagrams, the text is clear but direct to the point, most times not digging into unimportant details (and a few times leaving as homework checking them), and the structure and general discussion is great. The book also includes a handy back-of-the-envelope chapter to learn to do some calculations and estimations of storage, speed, capacity, scalability, bandwidth...

If I had to mention something to improve, it'd be the depth of some of the topics. While some scenarios get insane amounts of detail, others are very shallow, just mentioning pieces in my humble opinion way more important than others that are indeed extensively detailed. Doesn't happens often, and you can always go dig deeper by yourself.

Overall I'm really happy with the book, I summarized all scenarios and added additional details and a few new ones to practice, and now stands as a very valuable reference to me.


A new chapter awaits

Today was my last day at Worklytics. I'm really really grateful for the past 15 months. I could not only learn to write proper Java and get to know Google BigQuery, but also, after all the pandemic-originated not always good events, being able to have big blocks of deep focused work due to the remote nature of the job was very reinvigorating. I've also had quite some fun working with around a dozen different APIs while building new data connectors and improving existing ones.

There wasn't time to see my final creature/project, platform-wide pseudonymization, fully deployed in production, but most if not all of the remaining big parts are already at pull requests waiting to be merged, so at least I'm happy to leave with a feeling of having done my homework. Although we faced additional challenges due to asynchronous and potentially concurrent data ingestion jobs, our approach is similar to how Shopify recently did their PII tokenization project.


Now comes a very interesting new chapter... but first there's going to be a small break. We need to pack our things and clear some pending tasks, as in the following weeks we're moving outside of Spain. The destination and next gig will be known in time (sorry for the cliffhanger!), but both place & company are amazing and I couldn't be more excited about the upcoming future.


Zombie Infection Simulator mini-game

Over the last few days I've picked an hour here and there to build another entertaining small project. A zombie infection simular game.

Zombie Infection Simulator game screenshot

It is a port of a Java + Processing framework game with the same name by Kevan Davis to Javascript + HTML 5 <canvas> component for rendering.

I wanted to start practising some Javascript and play with canvas scaling so adapted the code and then made some small tweaks. There are a few changes and improvements that I would like to do, like more clear separation of entities and layers, or the fact the game doesn't runs at a fixed framerate (just enqueues another game loop iteration when current one finishes + optional delay), and probably many optimizations can be applied, but at least now I have a fully working version to use as the base. I'd like for example to try creating a version with graphics (also as an excuse to try Phaser.io), even if the amount of humans/zombies needs to shrink. But as I said, I now have the foundations and now can improve both the Javascript code itself and the game features whenever I can and want.

It is fun and relaxing to watch the little pixel humans panic from seeing zombies, and how the undead slowly but inexorably infect all the population (most times, the random city layout a few times creates isolated areas).

You can find the source code at my Github, or play it online from https://kartones.net/demos/026/.


Book Review: Buffettology

As part of my recent quest for reading and learning a bit about economics of our world, and by recommendation of a friend who knows at least more than me about the topic, I went for a totally different read this time.

Review

Buffettology book cover

Title: Buffettology: The Previously Unexplained Techniques That Have Made Warren Buffett The World's Most Famous Investor

Author(s): Mary Buffet, David Clark

What to buy? At what price? Seek the highest predictable annual compounding rate of return possible with the least amount of risk; benefit from the compounding effect of retained earnings, taking care about inflation and taxes; The price you pay determines your rate of return.

Previous paragraph was a small yet very relevant fragment of advices given in the book if you want to invest in a company. There are more, but these highlights provide a good summary. Written by a Buffet family member in the late nineties, explains in plain terms the basics of Warren Buffet's thinking, some of his investing techniques and a small framework to categorize, evaluate and judge if a company is worth an investment or not.

As another example, it suggests avoiding commodity business, trying to find consumer monopolies or "toll bridges", but more than 20 years later almost everyone will agree that this is not always clear to find. For example, when Google appeared wasn't a search and advertisement monopoly (and as of 2021 is losing ground on the advertisement business to Facebook and Amazon), and even companies that become part of a duopoly or oligopoly do so via insane amounts of invested money and are not yet profitable, so at least in the technological area Warren's concepts of searching for a company "with clean financials, good earnings and that is a monopoly" feels more of a holy grail (tell that to the venture capitals all over the world!).

Sorry, diverging outside of the book itself. In general, it is an interesting read, but parts of it are clearly obsolete. The listing of 54 interesting companies is a good example, despite still being interesting to read through. The authors tend to remark once and again and again a few topics, which isn't bad but becomes a bit repetitive, but even with that there are good general concepts to learn.

In my case, I'd choose the sentence "invest in companies that make products you understand" as something you can extrapolate to other areas.


Toggling Firefox dark mode via bash script

It might be just me, but all this dark theme trend, while really nice and an advancement over past attempts (I used Windows with a black theme long ago and was hard for anything other than a gaming-only computer), feels still not perfect: My Ubuntu 20.04's dark theme has an almost white notifications & calendar widget, some applications don't support it, but where I find it still inconsistent is regarding browser support; MS Edge will use the same operating system setting, and Firefox allows fine-tuning for the theme (window borders, etc.) but for the actual browsing it's a config setting of either on or off.

The property I'm talking about, as of Firefox v89 is "ui.systemUsesDarkTheme", with integer values 0/1 for disabled/enabled. And you can only change it from the advanced settings, from about:config.

That this is what I desire:

  • Operating System: Always dark theme ✓
  • Browser theme: Always dark theme ✓
  • Browser tabs dark theme detection/preference: Switchable on demand ✗

If I could have one of the following regarding the last point, I'd be happy:

  • A button to toggle ui.systemUsesDarkTheme values (enabling/disabling it whenever I want)
  • A way to create a javascript bookmarklet to toggle the value (AFAIK for security reasons you cannot change about:config settings via JS scripts)
  • A way to access the property from an extension, to build a "toggle pages dark theme" one (browserSettings looks very limited)

As none of those are available options right now, I did an alternative approach: creating a bash script that will run upon login (and on demand whenever I want), to automatically set the property at my Firefox profile preferences file (prefs.js), depending on the time of the day. It is not perfect, as you have to have Firefox closed or not only won't detect the change, but will also override when closing the value you set with whatever value it had while running, but at least works for me if I set it to run when I login.

Anyway, this is the script:

PROFILE="<your-profile-folder-name-here>"
HOUR=$(date +%H)

DARK_MODE_SETTING=0
if [ $HOUR -gt 20 ] || [ $HOUR -lt 8 ]
then
    DARK_MODE_SETTING=1
fi

sed -i "s/user_pref(\"ui.systemUsesDarkTheme\",.*);/user_pref(\"ui.systemUsesDarkTheme\",$DARK_MODE_SETTING);/" ~/.mozilla/firefox/$PROFILE/prefs.js

Previous entries