Three Years in Dubai
Six years ago, on my flight from Bali, where I spent eight years of my life, I had a mixture of feelings—I knew that it was time to move on, but at the same time, I knew I would miss lots of moments. A few days ago, after three years in Dubai, I felt nothing but relief during the boarding. In this post, I gathered the good and the bad parts of the UAE’s most famous emirate.
Watch Your Back
If you have never had back/neck issues, you probably don't realize how destructive it can be to your life. I didn't. In fact, it makes you completely dysfunctional. The nasty bit is that the problem creeps up unnoticed. It can take years to build up, and then one day you’re knocked out without an idea of how to recover.
When I was reading the Rust book for the first time, the chapter regarding error handling was my favorite. For someone who lived for years with exceptions, it was an eye-opener.
Fight for Your Hotkeys
Today I've been overhauling my Xcode setup, including hotkeys. When I attempted to assign ⌘ ⌃ D
to the “Show code review” action, I got a warning that the operating system already uses this combination, hence it wouldn't work. I checked, and indeed it was used to show the definition of the selected word.
Nix Time
Recently, I received my new MacBook Pro with M1 chip, and it was a good time to tackle a long-standing to-do: try out the Nix package manager.
Reconsidered
Honest question: if you could go back in time and reconsider anything, what would you change in your life?
Sending Bytes
If you ever face a task that involves tricky low-level network communication, you have to consider that the network might (and most likely will) partition the data that is being sent over.
Responsive Images and Cumulative Layout Shift
One of the annoying issues this blog had until recently was Cumulative Layout Shift (CLS) caused by responsive images. You probably already encountered a situation when you arrive on a page and start reading its content while it is still being loaded. And all of a sudden, the text jumps. This happens because when an image above the text has fully loaded and the browser has rendered it, the page content below the image gets pushed by an amount equal to the height of the image.
Lazy Loading Images With ReScript
When users visit a web page, they are not necessarily interested in its content. If the page contains a bunch of images and a user navigates away from the first screen, it is essentially a waste of traffic, CPU, time, etc. But it can be optimized.
Error Not Error
I stumbled on a piece of my old code of some CLI utility and remembered what a mess my unawareness of this specificity of UNIX streams caused (I'm not sure if it applies to Windows).
Home Inventory
At the time when I was taking pictures with my phone, I rarely had a problem finding or identifying my stuff. But ever since I went into photography, things got out of hand pretty quickly. Every new piece of gear comes with a number of small accessories that I need once in a lifetime, but when I need them, I have no idea where they are or even what they look like.
After years of working with ReScript (formerly known as BuckleScript), I find its module system to be one of the best. The more I used the language, the more extensively I used its modules. One of the critical parts of the ecosystem that leverages it heavily is ReScriptReact. This post is about the not-so-widely-known advanced feature of the language that helps to build handy abstractions over ReScriptReact components.
A few days ago, while writing the previous post, I needed a PhotoGallery
component to display clickable previews of a set of photos. I wanted it to be zero-API, which means I pass an array of images, and it figures out a pretty layout for previews by looking at the dimensions of the images.
Turkey
It's been more than seven months since the beginning of self-isolation. To be honest, I started to miss the hustle and bustle of travel life. We just did a very cool trip, so I’m bringing back the travel part of my blog.
Safe Routing in ReScript
Once you start using a language with a sound and expressive type system, you should push loosely typed entities to the edges of an application to leverage its advantages fully. One such entity is a URL. As you don’t let raw JSON leak into the internals of your app, the same way, raw URLs shouldn’t leak either.
Safe Identifiers in ReScript
Pretty much every entity in our apps has a special field that uniquely identifies it. Usually, it's called id
. The type of such identifier can be int
or string
(or any other serializable data type). But when we deal with identifiers of these loose types, there are no guarantees that an identifier of one entity is not confused with an identifier of another entity or even some arbitrary int
or string
. In some cases, like handling nested lists, it can cause nasty bugs that the compiler won't catch. But this is fixable.
Eliminating Illegal State in ReScript
The next thing I’d like to share is how ReScript helps in making illegal states unrepresentable in our apps.
ReScript Modules
Recently, I’ve been investing quite a lot in learning ReScript, and TBH, I’m pretty much dead as a JS developer because I’ve seen the better world. Much better one.