Zettelkasten Forum


What does a coder's ZK look like?

TL;DR - How do you implement your coding schema into your zettelkasten? Do you store code snippets in your Zk and how? There are reasons for and against including coding as a schema in a zettelkasten. There are different ways to treat coding in a zettelkasten.

In this forum post Code snippets in ZK, a few brave coders showed how they store snippet, UNIX commands, logging, concepts, and how-tos.

@discordian said:
a pleasant side effect that many of my code snippets are now actually executable: I can spawn a repl for playing with the code on the zettel with a keypress.

I wonder how I might duplicate this? Keyboard Maestro to the rescue!

@brennen said:
I'm usually asking two kinds of questions:

  1. What is this thing?
  2. What did I do about it last time?

@brennen goes on to differentiate between "a subject-matter dimension and a temporal dimension."

@matti said:
For me it's possible to divide the Zettels into three different groupings:

  1. abstract concepts - ideas, definitions, patterns, etc.
  2. concrete implementations - APIs, documentation of functions and keywords, classes, etc.
  3. HowTo's, concrete solutions and approaches

@matti's breakdown is sensible and would help focus finding answers to the pressing questions. This tactic of thinking about where the note fits when creating it will help it appropriately resurface.

@matti's blog post How I use my Zettelkasten as a developer is a wellspring of thought. He points out that time is precious and when you are on the clock, you have to be quick. He describes three ways he searches his coding questions. I'm not sure I get his references to note length and composabilty. His post responds to the forum thread and is well worth a look even if you are not a coder.

@henrikenggaard in How I use my Zettelkasten as a developer compares what I'd call a philosophical zettel with a coding zettel. He says, "For writing it is a really big advantage that vagueness and looseness is allowed -- a draft can be a draft build still have value because language is quite permissive. Code is of course much, much stricter."

@ctieze in My life as a craftsperson talked about producing "quite a few "tutorials to myself" in my Zettelkasten." He talked about his struggle to "keep my Zettelkasten clean; it was supposed to focus on truly important topics, like morality, living the good life, psychology, and stuff like that." Only realizing that programming is an essential topic for him and is part of living a good life.

Note-taking prompts.

Here is a list of prompts I'm trying out as I capture coding stuff into my ZK. Do you have other candidates?

  1. How have I implemented something similar in the past?
  2. What is the concept behind a function or class?
  3. How is the language syntax formulated?
  4. How do I do "X"?
  5. How is the code used?
  6. How will it be searched?
  7. When will it be searched for?
  8. What question does the note answer?

Will Simpson
My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
kestrelcreek.com

Comments

  • @Will wrote:

    How do you implement your coding schema into your zettelkasten? Do you store code snippets in your Zk and how?

    I store a lot of snippets in my zettelkasten. I'm inclined to agree with @ctietze in that finding technical solutions to interesting and/or recurring problems is part of what makes for a satisfying day-to-day existence for me.

    For me, there's nothing fancy - see attached. Code snippet and any explanatory notes, source if there is one. And maybe a word about the project where I used or encountered it first. I always make an attempt to link the new snippet note to some other note. Often that consists of adding it to a structure note. For example, for snippets that pertain to the Unix shell, I have a large structure note 20210411065601 §Shell snippets that acts as a guide to hundreds of snippets below it. That note in-turn rolls up to 20210207040647 §§Snippets.

    And of course, I tag snippet notes to aid in finding things orthogonally across language categories.

    Tangent: Sometimes I find myself wondering whether we get too judgemental with ourselves about what's in-scope vs out-of-scope for the ZK. There's a sort of implicit (or sometimes explicit) philosophical value that gets applied. "Oh that's not important/lofty/heady enough." As long as I'm conforming to the spirit of ZK - actively seeking and forming new connections within the content and not using it only as a collector's repository, I'm content with the strange juxtapositions between workaday snippet notes and musings on Nietzsche's Eternal Return.

    Professionally I'm a collaborative pianist & chamber music coach,

  • Thanks for the thought-provoking and actionable reply.

    @aduncan said:
    I store a lot of snippets in my zettelkasten. I'm inclined to agree with @ctietze in that finding technical solutions to interesting and/or recurring problems is part of what makes for a satisfying day-to-day existence for me.

    Finding solutions to questions in the ZK, whether academic or technical, "makes for a satisfying day-to-day existence."

    For me, there's nothing fancy - see attached. Code snippet and any explanatory notes, source if there is one. And maybe a word about the project where I used or encountered it first. I always make an attempt to link the new snippet note to some other note. Often that consists of adding it to a structure note. For example, for snippets that pertain to the Unix shell, I have a large structure note 20210411065601 §Shell snippets that acts as a guide to hundreds of snippets below it. That note in-turn rolls up to 20210207040647 §§Snippets.

    The little nugget you casually slip into the above paragraph leads to a gold mine of connectivity. I hadn't considered placing a few words about the project where a snippet is used. It sure would help with the search, and once landed on a candidate zettel/snippet, the example would be readily available via a potential link. I can imagine a query like #snippets awk "Reference Weight" being focused and quickly providing an example. I'm stealing this idea! I am all in for anything that adds links and/or references to my ZK.

    Questions
    1. Is §§Snippets a 'root' note, or does it hang off some other note?
    2. Snippets are one aspect of a coder's ZK. How do you handle software installation steps, links to tools like Cheat Sheets, UTF-16 tables, and other coding detritus that are not snippets?

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • @will:

    Is §§Snippets a 'root' note, or does it hang off some other note?

    I do have one level higher, which is a sort of "home" note. But §§Snippets is what I call a main structure note. That's as much formal hierarchy as I'm willing to enforce in my ZK.

    How do you handle software installation steps?

    Well, similarly. But I always try to anchor it in something relevant to the goal I'm trying to achieve. It's my slight pushback against the tendency to just collect reference materials in my ZK.

    ...links to tools like Cheat Sheets, UTF-16 tables, and other coding detritus

    Somewhat arbitrary on my part but I save a copy outside my ZK and only make a note about it if I'm actively using it; and then I'll only abstract the bits I'm using. Again, somewhat arbitrary boundary.

    @will, you referred to the idea of contextualizing the snippet (and here, I'm talking all sorts of coding-related notes) - I suppose it's partly to help avoid stuffing unused references into my archive, but also to aid my feeble memory in finding its way back to something I learned at some point.

    Finding solutions to questions in the ZK, whether academic or technical, "makes for a satisfying day-to-day existence."

    Favourite utterance while reviewing my archive: "Oh yeah, there's that..." ;-)

    Professionally I'm a collaborative pianist & chamber music coach,

  • Thank you for your engagement in the conversation.
    I completely identify with your phrase "Oh yeah, there's that… :wink:"

    @aduncan said:
    … idea of contextualizing the snippet (and here, I'm talking all sorts of coding-related notes) - I suppose it's partly to help avoid stuffing unused references into my archive, but also to aid my feeble memory in finding its way back to something I learned at some point.

    Breadcrumbs are what we are scattering in the hopes of "finding [our] way back to something [we] learned at some point."

    I'm all in for not collecting frivolous stuff. Like you, I store stuff that 'feels' like a collection outside my ZK in Evernote and link back and forth.

    Avoiding the Collectors Syndrome is a balancing act my mind is poorly calibrated for. We want to "avoid stuffing unused references into [our] archive" while at the same time we are poor judges of what will be useful and what won't. We add stuff to our archive with inspired intentions, and it quickly loses its usefulness. Pick your time frame if I trimmed everything unused from my ZK in the last year or two or ten or forty. I'd end up with a history of what I used and there'd be no potential left. We need some stuff that at one time had no use as the fodder for something new.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

  • @aduncan said:
    Tangent: Sometimes I find myself wondering whether we get too judgemental with ourselves about what's in-scope vs out-of-scope for the ZK. There's a sort of implicit (or sometimes explicit) philosophical value that gets applied. "Oh that's not important/lofty/heady enough." As long as I'm conforming to the spirit of ZK - actively seeking and forming new connections within the content and not using it only as a collector's repository, I'm content with the strange juxtapositions between workaday snippet notes and musings on Nietzsche's Eternal Return.

    At first glance, I read one of the sentences as "as long as I'm conforming to the spirits in the ZK" -- and I liked that. A co-worker almost a decade ago called a Zettelkasten a daimon that you feed. A genie in a bottle, a research humunculus, the ghost in the rock we call "computer processors." :)

    This idea of feeding a spirit entity helps twist thinking a bit, in a good way, because then you can ask questions about the complex system that you are dealing with with it's inherent processes and logic. It's not "what does the [nonexistend!] ZK rulebook say about pasting code snippets/cooking recipes/...?", it's more like: "how does this fit in? Where could this seedling be planted into the garden?"

    @Will said:
    TL;DR - How do you implement your coding schema into your zettelkasten? Do you store code snippets in your Zk and how? There are reasons for and against including coding as a schema in a zettelkasten. There are different ways to treat coding in a zettelkasten.

    [...]

    Here is a list of prompts I'm trying out as I capture coding stuff into my ZK. Do you have other candidates?

    1. How have I implemented something similar in the past?
    2. What is the concept behind a function or class?
    3. How is the language syntax formulated?
    4. How do I do "X"?
    5. How is the code used?
    6. How will it be searched?
    7. When will it be searched for?
    8. What question does the note answer?

    I do store snippets in my Zettelkasten, as you already pointed out. I don't have such a nice checklist to perform post-processing steps, though :)

    Merely pasting code I wrote into a note doesn't cut it, so "How will it be searched?" is in the back of my mind all the time when I add things to the Zettelkasten.

    I shared a breadcrumb-related story in 2019 where I added the search terms I find myself using time and again to the note so it would pop up, too. So this is a factor.

    The introductory paragraph needs to say all the important things: where is this used, what alternatives did I consider, and is there context I should be remembering/loading into my own memory again when reading this?

    E.g. here:

    # 202112310913 Overriding I-beam cursor in NSTextView when mouse moves
    #nstextview #nscursor 
    
    With regular `NSResponder` subclasses or view, you can override `resetCursorRects()` and override the cursor for the view's bounds. 
    
        class MyTextView: NSTextView {
            public override func resetCursorRects() {
                self.addCursorRect(bounds, cursor: .dragCopy)
            }
        }
    
    But `NSTextView` implements custom cursor changes that win over these.
    
    - `resetCursorRects()` is, for all intents and purposes, effectively ignored:
        - when you scroll with the mouse wheel (without moving the pointer!), the cursor rect's effect is applied for ~half a second
        - shortly afterwards, `cursorUpdate(with:)` is called back because the app changed the cursor to `.arrow`
    - `mouseMoved(with:)` can override the cursor, but only for regular moving of the mouse, not when dragging, and is not triggered when scrolling.
    - `scrollWheel(with:)` is called when scrolling, but that doesn't mean what I thought:
        - is called after the mouse wheel has rotated a unit/notch
        - using the trackpad's momentum, this is called while you move your fingers, and while the remaining momentum is applied, but only until you reach the edge: the rubberband-effect does not invoke this. But while the rubberband-effect is animating, you receive `cursorUpdate(with:)` events at a high frequency (aka a lot)
    - `setNeedsDisplay(_:avoidAdditionalLayout:)` is called periodically at ~2Hz. (It's hard to tell if it's also called in reaction to scrolling finishing because of that frequency. It appears to.)
    - `updateTrackingAreas()` as a callback is invoked when scrolling, also when resizing the text view/window. 
    - `cursorUpdate(with:)` is called during the rubber-band phase of scrolling
    
    Special cases:
    
    - Dragging/drag and drop[[202112301518]]
        - `draggingSession(_:movedTo:)` is called for the _source_ of the drag operation, not for the destination text view if you drag onto it, so it's not a good replacement for `mouseMoved(with:)` events
        - `draggingUpdate(event:)` is called periodically when you drag e.g. a file onto the text view and responds to mouse move events
    

    The introduction is actually 3 paragraphs, including the first code block; it's objective is to inform me about the supposedly canonical ways to do what I wanted to achieve:

    With regular NSResponder subclasses or view, you can override resetCursorRects() and override the cursor for the view's bounds.

    In case I look for this topic, mouse cursor overrides, and all I have is this note with workarounds. In the future, I want to try again to do the right thing, not the hack that I discovered, even though I don't spend another hour now to process how the canonical implementation is intended to be.

    Author at Zettelkasten.de • https://christiantietze.de/

  • I'm new here. Hi. I'm a zettelkasten enthusiast and a professional programmer, and mainly I just wanted to say it had never even occurred to me to put code snippets in my ZK. Probably because until very recently I used the old fashioned paper and pencil method. I'm not sure if I would start. I use my ZK for my interests outside of work. So far: mythology, note-taking, scaffolding, organic growth, quality, and psychology to name a few subjects in my own ZK.

  • @adamcross said:
    I'm new here. Hi. I'm a zettelkasten enthusiast and a professional programmer, and mainly I just wanted to say it had never even occurred to me to put code snippets in my ZK.

    Maybe you'll change your mind when you find yourself with Zettlr, and your IDE open all day, every day. There are so many advantages that my IDE (Visual Studio Code) has a zettelkasten plugin called Dendron so users don't even have to leave the IDE to create or search for a zettel.

    Will Simpson
    My zettelkasten is for my ideas, not the ideas of others. I don’t want to waste my time tinkering with my ZK; I’d rather dive into the work itself. My peak cognition is behind me. One day soon, I will read my last book, write my last note, eat my last meal, and kiss my sweetie for the last time.
    kestrelcreek.com

Sign In or Register to comment.