These short posts are no tutorials. I briefly mention things I find interesting so that other people may also discover them and crawl down the same rabbit hole I’ve just been to.

Competitive Programming

2021-07-11 00:00:00 +0000

I’ve been looking for a way to improve my coding skills and competitive programming has my highest reccomendations. Why? Because it forces you to come up with solutions on the spot. No diving into forums, no rethinking for the umpteenth time. You have a good half an hour to make an algorithm that works. Deal with it.

Also, in my experience most coding assignments tend to give away half the answer instantly. “Recreate this plot. Use Python’s seaborn library.” “Solve this network problem. Hint: You may want to use A* path finding which we discussed in class just half an hour ago. *wink wink*” Problems of this kind don’t prepare you for the real world because they spoon feed the solution path to you. A real-world problem may be “Solve this network problem. Good luck finding a decent square one.” Competitive programming is much closer to the real world. You are given a problem and zero hints on how to get started. No knowledge on whether you even have the tools to tackle the problem. All up to you to find out.

By far the most popular language for competitive programming is C++, which I’ve been wanting to have a reason to learn for quite a while. Long story short, we won’t be friends. I don’t want to have to write function signatures (where you essentially have to tell the compiler about a function’s parameters before the main method), they should be a thing of the past. I also definitely appreciate low-level-ness, but enough is enough. Many times the language was getting in my way more than it was useful to me. If I need to know an array’s length, then please let me write something like length(arr) or arr.length(), but not sizeof(arr)/sizeof(arr[0]). That is ridiculous. I am well aware that the language still has its place in todays landscape, but I struggle to understand why it is the de facto language of competitive programming.

The most popular place for competitions seems to be Codeforces. Contests are held every couple days for various skill levels. Have a go!

Literate configs in org-mode

2021-04-09 00:00:00 +0000

Version control of my config files used to be a total mess until I heard about tangling files in org-mode. Here’s how it works in a nutshell: Put a code snippet in an org-file like so:

#+begin_src haskell :tangle ~/.xmonad/xmonad.hs :comments link
myKeys conf@(XConfig {XMonad.modMask = modMask}) = M.fromList $
  [ ((modMask, xK_q), kill )
  , ((modMask, xK_Escape), spawn $ "xkill" )  -- target cursor to stealthily snipe kill apps
  , ((modMask, xK_space), spawn $ "rofi -show run" )  -- should become super + space
  , ((modMask, xK_f), sendMessage $ Toggle NBFULL) -- toggle fullscreen
  , ((modMask, xK_Escape), spawn $ "xkill" )
  , ((modMask, xK_Return), spawn $ "alacritty" )

Write your entire config file in the org file and explain, comment, and annotate to your heart’s liking. Then org-babel-tangle will (mercilessly over-) write the snippets to the path passed to :tangle. Make an org-file for every config file and put them in a repo called “dotfiles” (or whatever floats your boat). That’s it, version control done! Additionally, :comments link allows you to make changes directly in the config file and then propagate those changes back to the corresponding org-file with org-babel-detangle. Very useful for quickly testing stuff.

I decided to keep my own dotfile repo private for now because there may still be some sensitive data hidden somewhere (and also there not terribly interesting compared to what’s out there), but I keep seeing more and more dotfile repos make use of org-mode and tangling.




Osnabrück, Germany