Squadrick Whatever works


Things I want to remember \(\cap\) Things I don’t mind the internet knowing

30th November 2023, 12:45AM

I’ve been medidating a lot more lately, and a technique I really enjoy is box breathing. It’s a pattern of holding your breath between inhaling and exhaling. To make it easier to follow along, I made a simple website: boxbreathe.cc

I learnt and built this entirely in CSS.

26th October 2023, 04:12PM

The system we’ve built for wealth distribution is so absurb. I’m in Melbourne, an extremely wealthy city in an extremely wealthy country, and there’s a homeless woman sitting in the prime business district with huge empty buildings all around.

30th June 2023, 11:00 PM

If using LLMs to generate code, prefer using sampling over beam search. This paper was the starting point of my discovery, which lead to two more papers.

The general gist is that when picking new candidates, beam search only compares against complete outputs of differing lengths or incomplete outputs of the same length as the current candidate being generated. It does not compare against incomplete outputs of differing lengths. For some reason, this is okay for generating language not for code, it results in degenerate outputs. Why?

3rd November 2022, 12:13 AM

It’s been a hot minute since I’ve updated this feed. Here’s what I’ve been up:

  1. I’m implementing PBRT in Rust.
  2. I’m making my way through Malazan again, along with a coworker.
  3. I’ve been working out a lot more, and trying to be more healthy.
  4. I’m moving to USA soon, to work with the ThoughtSpot Bay Area team.

23rd January 2022, 11:30 PM

I recently read about games that one can play in their head. Here’s a game I’ve played when outside for as long as I can remember. This game has kept me occupied through several hours of traffic, both as a passenger and a driver.

The game is to recursively add up vehicle numbers till you’re left with a single digit.

If the vehicle number is KA 51 AA 5678, recursively apply the sum reduce rule on 515678 till there’s a single digit:

  1. 5 + 1 + 5 + 6 + 7 + 8 = 32
  2. 3 + 2 = 5

So the anwser is 5. I’ve found a faster way to compute this answer than the brute force sum: To eliminate 9s. Consider 0019, I can either do 1 + 9 = 10, then 1 + 0 = 1, or just remove the 9 leaving 001 and the answer is trivial. This also works if a subset of numbers adds up to 9, like 1245 (=3) or 4333 (=4). This also applies to multiples of 9.

Another speed-up is memoization. Since I’ve played this so much, I remember the result for all pairs and some trios/quartets of numbers which makes applying the 9-elimination rule faster. For 4378: I recall that 78 reduces to 6, 6 + 3 = 9, so it can be eliminated, which leaves 4.

I can compute the answers extremely quickly now. If I can had to guess, maybe half a second on average.

12th January 2022, 02:10 AM

It is the end of 2021. It was a mediocre year, through both my external and internal lens. 7/10. At the start of 2021 I wrote that I had hoped for some Mediocre Swings, so I got what I asked for.

The positive highlights:

  1. Exercise.
  2. Love.
  3. Travel.

The negative highlists:

  1. Death.
  2. Covid.

2021 did not annul us from the problems of 2020, thanks to d̷̨̗̟͎̝̏̒̇e̶̪̹̬̍l̶͎͓̪̗̹̾̽͑̏̑̚t̷̢̤̣̯̺͚̍́̊ă̷̧͍̒̾̉͛̉Δ̸̝͗͗̃. I have no hope for 2022. No swings.

Happy new year. Death to Covid.

21st November 2021, 07:00 PM

Code blasphemy: If you can’t fix a CI test, disable it.

23rd July 2021, 12:30 AM

I hadn’t worked on Shadesmar for nearly a year. I was looking at the code as reference for a tricky race condition at work. Not to brag, but the code was pretty neat, so I decided revist the project and I’ve been working on it over the last couple of weeks.

I stumbled into a very tricky bug, and spent a good couple of hours debugging it. It was a wonderful experience. I once read somewhere that a nice bug is like intellectual comfort food, and this bug qualified handily. Here’s the fix along with a very nice commit message.

30th May 2021, 06:50 PM

Milestone in SummaryDB: It works!

22nd May 2021, 02:43 AM

I took an off from work today with the hope of enjoying a nice birthday weekend. I spent the day listening to Neil Gaiman’s The Sandman on Audible, and hacking on SummaryDB and I just hit 100 commits. I thought it was worthy of a tweet.

25th April 2021, 04:44PM

Feynman’s Nobel Ambition.

18th April 2021, 12:45 AM

Large software engineering systems are shockingly broken compared to systems from other engineering disciplines. Other disciplines have a strong constraint of having to adhere to physics, while infinite layers upon layers of abstraction allows software to be really divorced from a strong foundational tether. It usually ends up being the sprawlings of diseased minds.

3rd February 2021, 12:15 AM

Instead of using reference counts to keep track of liveness of a pointer, instead use a dynamic graph to track all reference pointing.

Referce counting wouldn’t work too well when there’s cycles in the pointer:

A --> B --> C --> A

This usually requires a workaround using weak pointers that don’t increase the reference count.

Using a reference graph instead would fix this problem, by denoting liveness as an edge to an eternal sentinel node. Every time a node is deleted (pointer is deallocated), we delete it’s edge to sentinel and retrieve the list of nodes no longer connected to sentinel.

Implementing the underlying dynamic graph to make it fast while being thread-safe would be a challenge. Some looking around leads to this paper which would be perfect.

1st January 2021, 03:25 AM

It is the end of 2020. It was a catastrophic year for the global community. On a personal front, it was a year of massive changes; a solid 6.5/10.

Some of the positive highlights of my year:

  1. Education.
  2. Profession.
  3. Family.

Some of the negative highlights:

  1. Death.
  2. Friendships.
  3. Time.

I’ve never been one for resolutions, but I was looking forward to 2020. To quote Pirate Wires,

Big swings only.

With that hope ending in a fiery pile of pandemic shit, I tried to make the best of the hand that was dealt. I like to think that all the negative highlights from above were exogenous, but in highsight I could’ve handled them better, with a bit less haze.

The zeitgeist is that the end of 2020 will also annul us from the problems of 2020, while concurrently recognizing that 2021 will be a bleak, unchanging continuation. This juxtaposition reflects my personal outlook, but I side more with the former. I’m not hoping for big swings, but some Mediocre Swings would be scenic.

Covid didn’t just leave it’s mark on humanity, it french kissed it. I’m a witness to its gross, sloppy pervasiveness. I have spent my New Year’s Eve quarantined in a room waiting for my RT-PCR test, with the gregarious company of the dull hum of my PC’s fan, some bright lit screens, a bottle of red wine, and an uncomfortable sense of dreadly anticipation.

Update: I have tested negative. One more to the list of positive highlights.

Happy new year. Death to Covid. Long live enlightenment.

4th December 2020, 10:18 PM

The best advice I can give anyone is to never buy a snow-white keyboard. If you do, you’ll spend two hours each month cleaning each key-cap only for it to be grimy within the week.

28th November 2020, 03:35 AM

I was coding something in C++ and required sum types, and reached for the evergreen std::variant and life was great. Until I realized C++ doesn’t have type-based pattern matching (à la Go’s Type Switch), but after a little digging I discovered std::visit.

What should’ve been a simple piece of code ending up being monstrous boilerplate, so I figured I was doing something wrong. A quick google search for std::visit usage landed me in this blog aptly titled:

std::visit is everything wrong with modern C++

I strongly agree with the author. It is ridicously complex, and the addition of make_visitor as part of the standard would’ve been great. To be perfectly fair, I really don’t understand their implementation that uses recursive overload. For now, I’m going with the constexpr if solution.

I have half a mind to just roll my own union and enum based sum type. But experience has taught me that rolling my own alternative to a thing that exists in the C++ standard is good way to burn coding time.

This aversion to writing code from scratch, and reusing clunky existing solutions is a sign that I’m on the road to become a Software Developer™.

24th October 2020, 02:50 AM

I have such a tough time wrapping my head around the whole Kubernetes, Docker, Docker-compose jargon. It requires prerequisite knowledge that is unfamiliar to me. It makes me wish I spent a bit more time doing backend web-dev during my undergrad.

5th October 2020, 10:30 PM

It’s a Monday, and I’m already mentally and physically drained. This week is going to be rough.

21st September 2020, 01:05 AM

Previously, my resume was a built using Latex, and I had a PDF in the GitHub repo. This had three problems:

Since this website is built using Jekyll, I can generate the resume while the site is being deployed. The data is stored in a YAML file along with some code to generate the appropriate HTML webpage.

You can check it out here. One issue is that it uses more pages (2 vs. 1), but that’s a trade off I’m willing to make.

2nd September 2020, 11:50PM

Fall Guys is fun. I think the last time I found a game this enjoyable with friends was RuneScape in 2010.

RIP AzzuTheBoss.

28th August 2020, 6:10 PM

I’ve recently started working with Java during my day job, and I was reminded of a quote from a blog I read long ago:

“Dependency Injection” is a 25-dollar term for a 5-cent concept. – James Shore

I think Java programmers made up a bunch of jargon to make their jobs feel cooler than it really is. Java seems to favour verbosity over cleverness; perhaps, an averse reaction to the preceeding era of C++’s cleverness (read: pain).

Update, 1st September: Honestly shocking that Java didn’t get an equivalent of C++’s auto till Java 10. This is especially annoying when using for-each loops.

17th August 2020, 1:35 AM

I’ve really fucked up my sleep cycle. I’m currently alternating between 10AM - 5PM or 3PM - 10PM depending on the day. The past week has been a random sequence of working, coding, watching YouTube, and trying to live my life in-between. The lack of a proper schedule is a clean 3/10. Would not recommend.

29th July 2020, 11:50 PM

Picturing slice/concat/reshape operations on high-dim arrays gives me the same feelings as ASMR for some weird reason.

Here’s one I was just thinking about:

[4, 5, 3] -> SLICE@0, 4 * [1, 5, 3] -> concat@2 -> [1, 5, 12]

is not the same as

[4, 5, 3] -> RESHAPE(1, 5, 12)

To put it into words: Slicing + concat along different dimensions can’t be replaced by a single reshape, unless the slicing + concat operate on subsequent dimensions. So that means:

[4, 5, 3] -> SLICE@0, 4 * [1, 5, 3] -> concat@1 -> [1, 20, 3]

is the same as

[4, 5, 3] -> RESHAPE(1, 20, 3)

Update, 17th August: If the dimension of slicing is after the concat dimension, the output of the fused slice will need to be tranposed along the concat/slice dimensions and then concatenated.

24th July 2020, 01:20 AM

Although C++ is a powerful language, it’s quite easy to write ugly code. An example of the contrary is Glow. The graph optimizer code is a joy to read. Going to use this as an example of steller C++ code.

3rd July 2020, 2:16 AM

Graphs are amazingly useful structures. Wanted something that could generate a single C++ header file given my project’s include and src folders.

Went around looking at pre-existing tools, but they either were not compatible with my build system (good ol’ CMake) or too complex to set up. quom looks promising as a general purpose tool.

Wrote my own shadesmar-specific single header generator. It’s called simul. The core logic is embarrassing simple:

  1. Parse all the header files to find all its includes and its source file.
  2. Build a DAG of include dependencies.
  3. Repeatedly paste the header file and source file in topological order.

But as usual, the string handling (which is most of the code) was annoying. There’s a little bit more code to deal with file-specific include guard removal.

1st July 2020, 7:20 AM

I recently got a new PC. To play games I installed Windows. I hate Windows. Read a blog post that encapsulates why I hate it. This is similar to another video by Jonathon Blow. That’s not to say Windows is the only thing guilty of this, there’s plenty of inefficient, janky softwares I use of a regular basis.

After playing games like Red Dead Redemption 2 over the last couple of days, I’m gobsmacked by people who write game engines. They are far less guilty of the above.

I’m going to try Proton now, and try to get started with some basic game engine work.

25th June 2020, 04:45 AM

I accidentally deleted 6 hours of uncommitted work:

~/W/shadesmar> rm -rf *
zsh: sure you want to delete all 21 files in /home/squadrick/Workspace/shadesmar [yn]? y

I thought I was in build deleting compiled targets. Time to retype from memory.