Fix Apple UK keyboard layout by placing the tilde and backtick key in the correct place

Having your keyboard layout suddenly changed is not a fun experience. Especially if you use the key very frequently whose location has been switched. I recently had the unfortunate experience of having a dead MacBook. But luckily, I got another MacBook from a brother on loan. The problem with this MacBook is that it has UK keyboard layout. I’m not used to the ISO/UK layout. A shorter shift on the left and enter key being in a completely different realm was difficult enough, when I noticed, the (`~) key was not beside 1 which is what I’m used to. But the key was occupied with a key that I think should be retired, especially because, macOS has excellent support for symbols, and (§±) can easily be input with option + 6 and option + + key combination. For these reasons, I was getting super annoyed. And decided to swap out “§” with “`”. After searching for a while, I came across an application named Karabiner.

I knew using this app I could switch the keys, but I didn’t know what the keys are called. So, after a lot of trial and error, I found that § is called, “non_us_blackslash”. So, this blog is basically, for me if I ever need to do this again xD Also, after installing Karabiner the fn key is now called the “globe” key.

In-memory Decompression of gzipped Web-response body Data in Elixir

I was trying to write a web crawler with Elixir and Crawly (A web crawling framework written in Elixir). The website I was trying to crawl had their sitemap gzipped. So, each entry in their main sitemap returned me a file like “sitemap-01.xml.gz” which needed to be gunzipped to get the XML file I was after.

Initially, I thought HTTPoision will handle the decompression. But turns out HTTPoision is just a wrapper around hackney and hackney doesn’t support this. So, I did a few google searches, and being tired, I didn’t use the most effective keywords and ended up with File.stream! which obviously didn’t work. Because, File.stream! needs a file path which should have been a red flag, but I proceeded to go down the rabbit hole anyway.

Then I thought that it might work if I write the response to a file and decompress it with File.stream! but thinking about it gave me the chills, there’ll be a lot of files written, decompressed, and read from. So this wasn’t the solution I was even going to write and try out.

After a whole lot more searches and asking around, I finally found the answer (Huge thanks to Mafinar bhai), which is an Erlang lib called “zlib“. Using this library I could easily get the data I wanted to like the following code block:

response.body
|> :zlib.gunzip()

Now you might be asking why I didn’t use an HTTP client which had compression support like, Tesla? Because, I had HTTPoison free with Crawly, and I didn’t want to explore how to change it to Tesla or Mint due to a deadline. Yes, deadlines are the worst!