Working Notes: a commonplace notebook for recording & exploring ideas.
Home. Site Map. Subscribe. More at expLog.

2024-07-07

TermDex

I spent most of this week hacking on termdex and learning new things from the process: I hope to combine all of that into a new setup to publish this website (and bring over my previous slipboxes) within the next few weeks.

I've started using it to collect notes, tasks, bookmarks, and anything else that catches my fancy: and to write this week's letter, I have it open in a split window to see things I explored (trying out remote-pdb, python-manhole, etc.).

In time I'm excited to throw an LLM at this, and also to have it automatically figure out when I wrote the same note / explored the same resource last time. There's also a lot of functionality to build out to make it easier to create notes with values prefilled: one of the pieces of functionality I really liked in FocalBoard -- that was almost perfectly implemented but still had some issues.

Some of the new tricks I learned this week include:

  WITH RECURSIVE
  split_path(path, remainder, moved) AS (
	SELECT * FROM (SELECT "" as path, path AS remainder, 0 FROM markdown_files WHERE basename LIKE '%.md' LIMIT 2)
	UNION
	SELECT
	  path || substr(remainder, 1, instr(substr(remainder, 2), '/')) as path,
	  substr(remainder, instr(substr(remainder, 2), '/') + 1) as remainder,
	  moved + 1 as moved
	FROM
	  split_path
	WHERE
	  instr(substr(remainder, 2), '/') != 0
  )
  SELECT SUBSTR("............", 1, 2*moved) || remainder FROM split_path LIMIT 20
  ;

CUPTI and LD_PRELOAD

The other interesting project this week was trying to listen for cuda context initialization using LD_PRELOAD and subscribing to CUPTI callbacks. I have a tiny implementation working, but need to see if I can get good cross programming language stack traces.

Stream Dye

While playing with PTYs to get unbuffered output (mainly for improving torchrun I tried implementing a quick program to tag stdout and stderr separately by running a subprocess with 2 pty pipes attached). This worked surprisingly well, though I think this interferes with the terminal size estimations -- at least when done through basic python.

Having something that explicitly displays stderr / stdout separately is pretty valuable, so I plan to make this a tiny zig utility in the near future.

Kunal