raindev | Andrew's Bloghttp://raindev.io/Recent content on raindev | Andrew's BlogHugoen-usTue, 19 Mar 2024 00:00:00 +0000Content-Encoding and Transfer-Encoding HTTP Headershttp://raindev.io/blog/http-content-and-transfer-encoding/Tue, 19 Mar 2024 00:00:00 +0000http://raindev.io/blog/http-content-and-transfer-encoding/<p>An HTTP message comprises a request line (a request method, an URL and a protocol version) or status line (a protocol version and a response status code) followed by a list of headers and a message body separated with an empty line. The request/status line and the headers are plain text, while the message body can be any content (specified by <code>Content-Type</code>), including binary, optionally encoded.</p> <p>How the message body is encoded is described by two headers: <code>Transfer-Encoding</code> and <code>Content-Encoding</code>. Compression and chunked transfer encoding are two main reasons behind encoding the message body. The goal of compression is to improve the performance by reducing the amount of data transferred, although it does impose additional work for the server and the client. With chunked transfer coding a large message body is broken down into chunks transferred separately. This enables piece by piece data transfer, sending messages where the size is not known ahead of time and streaming of large media.</p>The Cycle of Complexityhttp://raindev.io/blog/cycle-of-complexity/Sat, 16 Sep 2023 00:00:00 +0000http://raindev.io/blog/cycle-of-complexity/<p>Complexity can have many different sources. Things do not materialise the way we imagined, experiments fail, new technologies or tools do not prove as useful as advertised. Our understanding of the problem improves overtime, sometimes the problem itself or the direction we want to go changes. Exposing projects to time results in layering of different, even conflicting, ideas. Having more than a single person working on a system only amplifies those effects.</p>Mixing Sync and Async Rusthttp://raindev.io/blog/mixing-sync-and-async-rust/Thu, 15 Sep 2022 00:00:00 +0000http://raindev.io/blog/mixing-sync-and-async-rust/<p>Recently I have read <a href="proxy.php?url=https://openjdk.org/jeps/425">JEP 426</a>, Java enhancement proposal introducing virtual threads - essentially a way to map multiple Java threads to a few operating system threads. I thought it&rsquo;s brilliant, especially the fact that the virtual threads could run <em>unmodified</em> code.</p> <p>Rust take a different approach to overcoming the scalability issues of operating system threads with asynchronous runtimes and async/await language support. One of the issues however is that the code has to be adapted for the asynchronous model. While async/await syntax significantly improves the experience of writing asynchronous code which is still straightforward to understand, mixing both styles of programming is still very annoying. Or is it really?</p>How to not Write Emacs Config in Orghttp://raindev.io/blog/how-to-not-write-emacs-config-in-org/Sat, 30 Jan 2021 00:00:00 +0000http://raindev.io/blog/how-to-not-write-emacs-config-in-org/<p>I have started simple. <code>~/.emacs.d/init.el</code> had just one line:</p> <pre><code>(org-babel-load-file &quot;~/.emacs.d/init.org&quot;) </code></pre> <p><code>init.org</code> was simple too:</p> <pre><code>#+begin_src emacs-lisp (setq org-directory &quot;~/org&quot;) #+end_src </code></pre> <p>After restarting Emacs everything seems to have worked fine <code>C-h v</code> told me that the value of <code>org-directory</code> is indeed <code>~/org</code>. So far so good. I have opened <code>init.el</code> and its content was:</p> <pre><code>(setq org-directory &quot;~/org&quot;) </code></pre> <p>That&rsquo;s right, the same as the code I had in the source block in <code>init.org</code>. Clumsy Emacs beginner, I thought, I must have written the wrong file! I have fixed it quickly to put <code>org-babel-load-file</code> in the right place and restarted Emacs. Right after start <code>*Warnings*</code> buffer popped up and showed me this error:</p>Operability and Rusthttp://raindev.io/blog/operability-and-rust/Wed, 02 Dec 2020 00:00:00 +0000http://raindev.io/blog/operability-and-rust/<p>Most of the discussions of programming languages focuses on development of software. Productivity of getting something up and running on one hand and maintenance costs on the other. Usually proponents of dynamic typing and interpreted languages are focused more on the speed of writing new code. The fans of static typing and compiled languages emphasize maintenance, the ability to change existing software<a id="ref1" class="ref" href="proxy.php?url=#1"><sup>1</sup></a>. This is obviously an oversimplification but in general summarizes my observations of the discussion.</p>Why Intuition Workshttp://raindev.io/blog/why-intuition-works/Wed, 16 Sep 2020 00:00:00 +0000http://raindev.io/blog/why-intuition-works/<p>It&rsquo;s easy to be sceptical of intuition. Making decisions unconsciously without understanding the reasons behind or being able to articulate the way we arrived at them. This seems irresponsible. On the other hand if intuition is something that&rsquo;s characteristic of us as species, there&rsquo;s a good chance it was acquired for a reason and has some value.</p> <p>If you are dismissive about the value of intuition, imagine just for a second why it <em>might</em> work. A plausible explanation is actually very simple: finding an answer is much easier than explaining how to arrive at the answer. If you have tried to explain a problem you are comfortable solving to someone else, you&rsquo;ve probably have experienced this feeling yourself. Our brain can collect countless subtle cues about a problem and construct a way to obtain the result. Understanding of how we have arrived at the solution requires a lot of additional effort, reflective study of ourselves and analysis of our cognitive process. For this reason there are a lot more questions we can answer than we can explain.</p>Taking the First Stephttp://raindev.io/blog/first-step/Thu, 10 Sep 2020 00:00:00 +0000http://raindev.io/blog/first-step/<p>I&rsquo;ll be upfront: the only reason for this post is to resume this blog. It&rsquo;s been almost two years since I have published the last article. And it&rsquo;s not for the lack of things to write about. I had too many ideas over this time. Not for the lack of effort either: there are a few drafts that never made it live. I can ponder about reasons why this has happened but it doesn&rsquo;t really matter. It you want to achieve something, you got to take the first step. It doesn&rsquo;t have to be perfect and you cannot wait for the ideal moment. The life is too short for that. Now go and take <em>your</em> first step.</p>Detecting Java OutOfMemoryError before it happenshttp://raindev.io/blog/detecting-jvm-oome/Tue, 25 Sep 2018 00:00:00 +0000http://raindev.io/blog/detecting-jvm-oome/<p>Is it even possible, you might ask? Well, not really, we can&rsquo;t predict the future. But we <em>can</em> detect the situation leading to <code>OutOfMemoryError</code>, lack of free heap memory, before it actually occurs. Technically there&rsquo;re other causes of OutOfMemoryError <a href="proxy.php?url=https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/memleaks002.html">described in detail here</a> which are outside of the scope of the article and arguably less frequent and interesting.</p> <p>Before moving forward, why can&rsquo;t we handle <code>java.lang.OutOfMemoryError</code> when it actually happens? The error is a <code>Throwable</code>, so we can catch it, right? Not quite. While technically the error can be caught there&rsquo;re very few cases when it&rsquo;s actually useful to do so. Because Java is a garbage collected language allocations of objects on the heap happens all the time as a part of the normal program execution, including when an exception is caught (e.g. to record the stack trace information). When a program runs out of memory all bets are off: any thread of the program can die at any time. You no longer can count on the application being in a sane state. &ldquo;Impossible&rdquo; things can happen. Okay, but at least the error will get logged? Unfortunately, that&rsquo;s not always true. Again, if a program has run out of memory you can&rsquo;t count on any operation to succeed. Writing a log, as everything else, allocates memory and can fail. As well as simply writing a message to the standard error output. This makes the error hard to detect.</p>Granular Git Configurationhttp://raindev.io/blog/granular-git-configuration/Mon, 16 Apr 2018 00:00:00 +0000http://raindev.io/blog/granular-git-configuration/<p>Even though in most cases having a single Git configuration is enough, sometimes more granular control is needed. Let&rsquo;s say you have a common Git configuration you use on your personal server, a laptop and a desktop. You probably want to share that configuration across the machines as part of your <a href="proxy.php?url=https://zachholman.com/2010/08/dotfiles-are-meant-to-be-forked/">dotfiles repository</a>. Also you have a work laptop and you need some special Git configuration for work projects. Occasionally you commit to your personal repositories or some open source repositories from the work laptop and you don&rsquo;t want to have the work configuration applied in those cases. Let&rsquo;s see how you can organize the Git configuration to match the described setup step by step.</p>Build Yourself Arch Linux, Part 3http://raindev.io/blog/build-yourself-arch-linux-3/Wed, 11 Oct 2017 00:00:00 +0000http://raindev.io/blog/build-yourself-arch-linux-3/<h1 id="part-3-lets-get-a-gui">Part 3: Let&rsquo;s Get a GUI</h1> <p>This is the third and the final part of my Build Yourself Arch Linux series (<a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-1">part 1</a>, <a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-2">part 2</a>). In this part I&rsquo;ll finally get to a graphical environment setup.</p> <h2 id="gnome">GNOME</h2> <p>Before settling down on <a href="proxy.php?url=https://gnome.org/">GNOME</a> I&rsquo;ve tried (well installed and played around for 10 minutes) most of <a href="proxy.php?url=https://wiki.archlinux.org/index.php/Desktop_environment#List_of_desktop_environments">the desktop environments supported by Arch</a>. I&rsquo;ve been using GNOME 3 in the past but decided to look what else is out there. The reason I&rsquo;ve settled on GNOME now is HiDPI support. While there&rsquo;re other desktop environments that support HiDPI GNOME gave me the best result with pretty much no configuration. I was really tempted by <a href="proxy.php?url=https://www.kde.org/plasma-desktop">KDE Plasma</a> which looks gorgeous and does support HiDPI. Still on MacBook&rsquo;s screen GNOME was a bit more consistent: I&rsquo;ve got too small icons here and there in Plasma. <a href="proxy.php?url=https://lxqt.github.io/">LXQT</a> is another DE I&rsquo;m interested in. Given the progress towards HiDPI support or possibility of getting an external monitor with ordinary resolution I&rsquo;ll probably be able to reevaluate my choice of desktop environment soon enough.</p>How to Partition an External Hard Drive for macOShttp://raindev.io/blog/hdd-for-macos/Thu, 15 Jun 2017 00:00:00 +0000http://raindev.io/blog/hdd-for-macos/<p>TL;DR macOS expects 200 MB EFI System partition in the beginning of a hard drive, don&rsquo;t like unformatted partitions and creates 128 MB Apple boot partitions after each real partition whenever you format it.</p> <p>I needed to partition an external hard drive to be usable on macOS (for <a href="proxy.php?url=https://en.wikipedia.org/wiki/Time_Machine_(macOS)">Time Machine</a> backups). I&rsquo;ve partitioned the drive using <a href="proxy.php?url=https://en.wikipedia.org/wiki/GUID_Partition_Table">GPT</a> scheme and created one unformatted Apple HFS/HFS+ partition on Arch Linux using <a href="proxy.php?url=https://wiki.archlinux.org/index.php/Fdisk">fdisk</a>. It was not recognized (the inserted disk is not readable dialogue), nor was I able to format the partition (with &ldquo;Media kit reports not enough space on device&rdquo; error) which was shown as full in the Disk Utility. When I have formatted the partition (using mkfs.hfsplus from <a href="proxy.php?url=https://aur.archlinux.org/packages/hfsprogs/">hfsprogs</a>) the partition was recognized but I was unable to initialize it for Time Machine or format with the same error as before. Finally I have partitioned the drive from macOS and created a new partition. Looking at the drive with fdisk I&rsquo;ve discovered that EFI System partition was created in the beginning of the disk with size of 200MB. When I have recreated the same partitioning layout using fdisk it was recognized properly. After setting up Time Machine backups on the created partition I have inspected the disk once more. The partition type was changed to Apple core storage and a 128 MB partition was created after it. When I created another partition for the second MacBook I got one more 125 MB Apple boot partition. The resulting partition table was:</p>What's Wrong with WhatsApp Message Tunnelinghttp://raindev.io/blog/whatsapp-tunneling/Sun, 07 May 2017 00:00:00 +0000http://raindev.io/blog/whatsapp-tunneling/<p>A colleague asked me on Twitter what the problems do I have with the way WhatsApp tunnels all the messages though my phone:</p> <blockquote> <p><a href="proxy.php?url=https://twitter.com/raindev_/status/859872365886545920">@raindev_</a>: I&rsquo;m tired of WhatsApp tunneling all the messages through my phone. Time to look for an alternative?</p></blockquote> <blockquote> <p><a href="proxy.php?url=https://twitter.com/JensRantil/status/861205974933270528">@JensRantil</a>: Also, what part about the tunneling do you find annoying? Very rarely don&rsquo;t I have my phone on same Wi-Fi as computer.</p></blockquote> <p>The answer turned out to be too long for Twitter so I decided to write a short post.</p>Build Yourself Arch Linux, Part 2http://raindev.io/blog/build-yourself-arch-linux-2/Sun, 02 Apr 2017 00:00:00 +0000http://raindev.io/blog/build-yourself-arch-linux-2/<h1 id="part-2-getting-work-done-from-console">Part 2: Getting Work Done from Console</h1> <p>This is the second part of the series of articles (<a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-1">part 1</a>, <a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-3">part 3</a>) about setting up Arch Linux on my MacBook. The main goal of this part is to make the installation actually useful to do some work. In some sense, I want to bootstrap the series to be able to work on the posts under Linux. Disclaimer: I won&rsquo;t get to setting up graphical environment in this part; while it&rsquo;s possible to do everything from this article <em>after</em> installing a graphical environment, I&rsquo;ve decided to try how far can I get without one.</p>Paperhttp://raindev.io/blog/paper/Tue, 21 Mar 2017 00:00:00 +0000http://raindev.io/blog/paper/<p><small><em>(written on December 23, 2016)</em></small></p> <p>After trying almost (hello, org-mode) all digital solutions for organizing my life out there and spending hundreds of dollars and countless hours worth of time I&rsquo;ve bought myself a paper notebook. And I&rsquo;m happy that I did. I used to be a firm proponent of keeping one&rsquo;s life digital as much as possible so it may sound like a strange decision. And indeed it is. Not that I&rsquo;ve never used a paper notebook before. But it never was front and center of organizing my life.</p>Build Yourself Arch Linuxhttp://raindev.io/blog/build-yourself-arch-linux-1/Mon, 21 Nov 2016 00:00:00 +0000http://raindev.io/blog/build-yourself-arch-linux-1/<h1 id="part-1-base-system">Part 1: Base System</h1> <p>This is the first part of a series of articles (<a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-2">part 2</a>, <a href="proxy.php?url=http://raindev.io/blog/build-yourself-arch-linux-3">part 3</a>) on how I set up dual boot Arch Linux on my Mid 2014 MacBook Pro. At the end of this part I&rsquo;ll have a bootable but completely minimal installation of Arch on an encrypted partition without any tuning. Ability to boot to Mac OS will be preserved.-1-1</p> <h3 id="updates">Updates</h3> <p>December 11, 2016: clarify how to customize list of installed base package; add instructions how to start wired network automatically; describe a separate <code>/data</code> partition.</p>Hash Collisionhttp://raindev.io/blog/hash-collision/Sun, 20 Nov 2016 00:00:00 +0000http://raindev.io/blog/hash-collision/<h1 id="or-why-im-leaving-googles-services">Or Why I&rsquo;m Leaving Google&rsquo;s Services</h1> <p>Recently there was a lot of <a href="proxy.php?url=https://news.ycombinator.com/item?id=12972554">talk</a> about Google services on Hacker News. Concerns people have about loosing control over their data prompted me to check out how I use Google.</p> <p>There&rsquo;re a few reasons to worry: loosing your data, giving to much personal information to one company and having someone (or something) reading (or scanning) your private stuff. While I tried to limit my use of Google&rsquo;s services in the past and moved off the major ones like Gmail, Calendar, Contacts there&rsquo;s still a lot of my stuff on Google&rsquo;s servers. Especially given my switch to Android about half a year ago.</p>On Writer's Blockhttp://raindev.io/blog/writers-block/Fri, 11 Nov 2016 00:00:00 +0000http://raindev.io/blog/writers-block/<p>If you&rsquo;ll have a look on <a href="proxy.php?url=http://raindev.io/blog/">timeline</a> of this blog of mine it will be obvious that I&rsquo;m dealing with writer&rsquo;s block. I always wanted to have <em>real</em> blog, to do <code>git push</code> to publish, to build it <em>from scratch</em> myself. And about 9 month ago I got it. I found <a href="proxy.php?url=https://jaspervdj.be/hakyll/">Hakyll</a> which felt awesome, like assembling a model airplane from parts. I&rsquo;ve refined it over couple of weeks and got what I wanted to have. The first post event caught some attention as I&rsquo;ve decided to post it to Reddit. There has been both positive and negative <a href="proxy.php?url=https://www.reddit.com/r/vim/comments/484isa/why_i_use_space_as_my_vim_leader_key/">feedback</a>. But there will <em>always</em> be negative feedback, so it was fine.</p>Space Leaderhttp://raindev.io/blog/space-leader/Sat, 27 Feb 2016 00:00:00 +0000http://raindev.io/blog/space-leader/<p><small><em>(written on December 12, 2015)</em></small></p> <h1 id="why-i-use-space-as-my-vim-leader-key">Why I use space as my Vim leader key</h1> <p>One of the best Vim productivity boosts is to configure your leader key. What leader key does - it gives you a namespace for custom mappings. No default Vim mappings use leader key, so you&rsquo;re free to choose whatever shortcuts you like without worrying about conflicts with some predefined mappings. Considering this it makes sense to define custom mappings using leader key. It also facilitates remembering of shortcuts by providing mental separation for the ones you&rsquo;ve crafted yourself. To activate a shortcut you just press leader key and than a specific mapping, e.g. I use <code>&lt;leader&gt;w</code> to save current file. Configuring such a mapping is quite easy: add <code>map &lt;leader&gt;w</code> to your .vimrc and you&rsquo;re done. Noticing things you do repeatedly working day-to-day in Vim and creating custom mappings for them will allow you to save a little bit of time constantly and will make editing with Vim more effortless.</p>Abouthttp://raindev.io/about/Mon, 01 Jan 0001 00:00:00 +0000http://raindev.io/about/<p>My name is Andrew. Usually you can find me online as raindev. For more frequent posts feel free to follow me on <a href="proxy.php?url=https://bsky.app/profile/raindev.io">BlueSky</a>.</p> <p><a href="proxy.php?url=http://raindev.io/cv.pdf">Here</a> is my CV.</p> <p>The source code of the website is available on <a href="proxy.php?url=https://github.com/raindev/homepage">GitHub</a>.</p>Contacthttp://raindev.io/contact/Mon, 01 Jan 0001 00:00:00 +0000http://raindev.io/contact/<p>The best way to contact me is <a href="proxy.php?url=mailto:[email protected]">email</a>. Feel free to drop me a message on <a href="proxy.php?url=https://bsky.app/profile/raindev.io">BlueSky</a> as well.</p>