Log: 3/26/2021

03.26.2021
log

This week: fugues, the US's vulnerable infrastructure, CAD software, routing algorithms, Miyazaki and Marxism, Anachronox, and a few other things.

Fugues

BWV 895 (source: Critical Legal Thinking)

Growing up my only exposure the musical composition form of the "fugue" was through Bach, so I mostly only ever heard in his very baroque style (for example, Toccata and Fugue in D minor, which I probably first encountered in the game Dark Castle). But the form as defined is pretty open-ended: it's mostly about having one theme (melody) that is played somewhat independently by different voices in counterpoint. Shostakovich's Fugue in A Major is a nice example of how different fugues can sound. This video on fugues in (or rather, their absence in) film scores helped me further think about fugues beyond Bach's sound.

I also came across this old essay on fugues in the New York Times, "A Gorgeous Tapestry Woven as You Listen: The Art of Fugue", that describes almost exactly how I'm thinking about fugues in relationship to the new game I'm working on (and summarizes the form well):

The fugue now seems a strange musical form: with its imitating and intertwining voices it embodies the tastes of an antique era. For the last two centuries we have been preoccupied elsewhere. Much concert music has been thought of as having two ingredients: a melody and an accompaniment. The melody is the solo voice: the instrumentalist or the singer expressing emotion, demanding attention. The accompaniment is the background, emphasizing a melody's tensions or commenting upon them, embracing a voice or confronting it. But melody reigns supreme. When we praise music, we are often praising its melody. Even symphonies, with their hundred instruments, are often remembered mainly through their themes.

The fugue is an entirely different story. It is all melody, or, perhaps, all accompaniment. It does not have an individual voice; it has many individual voices. And each voice is an image of the others, accompanying them by echoing them. A fugal theme may not even be distinctive as a melody. It might seem awkward, incomplete, lacking resolution or purpose.

But set that theme in motion. Then, after a few measures, set another voice to work, singing the same theme, perhaps at a different pitch; then a third, or a fourth, or a fifth. Build tension as these voices echo each other in cascades of fresh entrances; release tension as they break into free-form episodes. Invert a voice so it moves up where it once went down and down where it once went up. Fracture the theme or expand it. Keep the separate voices in a state of nearly perpetual motion and then confound the ear by allowing them to intertwine.

Such is the fugue — a drama not about the individual voice at large in a society of sound, but a drama about a society of sound created by related individual voices. It is an astonishing structure, constructed with intense concentration. In the midst of that musical society, combinations can never be random or arbitrary. Rules govern these interactions. And the character of the theme helps determine the character of the fugue itself.

...Each fugue's theme has a distinctive character; each character constructs its own society; and each society is bound by law while allowing extraordinary liberty. The fugue is a model of an ideal society in which obligation and independence coexist, in which the individual is incomplete without the society and the society unthinkable without the individual, in which passion erupts but reason rules.

There's also this piece, "Can a Novel Be a Fugue?", that points out the etymology of the term:

The word fugue comes from the Latin fugo, "flight," as well as fugere, "to flee" (as do the words fugitive and refugee).

Finally, this piece, "Law is a Fugue", has a perspective on "fugue-as-subjectivity" that I hadn't considered:

This leads me to draw out a first line of thought from the metaphor: the comparison of the fugal subject with the human subject.

...For [Julia] Kristeva (as for many others), the subject “I” is an unstable identity. It is in continuous flux, under constant tension, and in the process of being made. The subject subsists in what she calls an “open system” where the structure of the subject is open to other structures that permit the subject to permanently renew itself. This open system could also be seen in terms of a more radical thinking of community. For example, J-L Nancy has written in similar vein but different discursive register of “inoperativity” or being “unworked”. For Nancy, the inoperative community is an ontology of community independent of any striving towards artificial delineation, cultivation, or hypostatization. The essence of community is that which is in a state of constant tension and flux between inside and outside, between finitude and infinitude, between subjects with others.

It strikes me that the subject of the fugue mirrors this thinking very well: the fugal subject is itself in a state of flux, in the process of being iterated yet still identifiable (as if an ‘I’) through the whole piece. Moreover, its identity is challenged and modified by the multiple voicings harmonising in counterpoint. One could call such polyphonic counterpoint the open system of voicings or even the community of voicings. Both human and fugal subjects become or modulate into something other when with voices in community, all while retaining their identities. Both are subjects in process.

There's also this interesting tidbit, connecting things back to fugues-that-break-with-Bach:

There is a flux or “play” between the fixed canonical subject and the breaking of the canon that subverts the rules that first constituted it, an act of sublime beauty in self-sabotage. ... The late Baroque music theorist, Jean Phillipe Rameau, wrote that fugal art “cannot be reduced to rules” and that it is as much about defying rules as it is to follow principles. 3 Some say J S Bach, undeniably the greatest exponent of the fugue, should be avoided if you want to learn the “true” principles of the fugue. He was brilliant precisely because he broke the rules.

I found those last two while searching for an image for this post, kind of funny how that happens.

America’s Drinking Water Is Surprisingly Easy to Poison, Peter Elkind & Jack Gillum.

A pretty worrying look into the cybersecurity vulnerabilities of US water treatment systems.

So many of these problems go back to default passwords as a major attack vector. I wonder a) what % of attacks this actually account for (since there are so many other failure points that are mentioned in that piece, e.g. non-default passwords but the same password everywhere and widely shared), and b) is there no better approach to creating initial passwords for devices?

The deeper problem is, maybe unsurprisingly, a drive towards lowering costs (mostly through eliminating labor costs) because this kind of critical infrastructure is so cash-strapped:

The origins of the problem are clear. The vast majority of the nation’s water systems are small and publicly owned, with limited resources and aging infrastructure. As they turned to digital systems and monitors to boost efficiency while saving money and staff, they failed to install the safeguards and carry out employee training needed to secure the resulting vulnerabilities. “Every one of them had one guiding principle over the last 50 years: increased automation to lower the size of the workforce to keep costs down,” Montgomery said. “Along with that, there should have been an investment in the cybersecurity of the infrastructure. But that did not happen.”

I wonder what the cost savings are after the necessary cybersecurity measures are taken into account?

There have definitely been more stories of these kind of industrial/infrastructural cyber-attacks, but I feel like they must still be vastly underreported (for example, hospital ransomware attacks feel like part of everyday background noise now). And will probably only get worse and worse as the trend outlined in the quote above continues.

This also reminds me of a data catalog I came across recently, the Homeland Infrastructure Foundation-Level Data, which has a surprising amount of geospatial data available on US infrastructure (power transmission lines, hospitals, power generation facilities, etc) which are provided for researchers to assess the country's preparedness against these kinds of attacks.

h/t Kira

SolidPython

Recently I started using OpenSCAD for sketching out simple woodworking projects and sewing patterns. There are a lot of options for CAD software, many more powerful than OpenSCAD, but I like that you control OpenSCAD through code. For me that's a lot easier than using a mouse or forms to layout a project. There are no doubt limits—I'm guessing that as designs get more sophisticated, the advantages of sketching the object out in code decline. But so far it's worked well.

The only thing is that the OpenSCAD language is kind of clunky. Even modest projects can feel overgrown and difficult to manage. I came across SolidPython, which is basically a Python library that compiles to OpenSCAD—you can leverage the power of Python and have a bit of a cleaner interface. For example, this bill of materials decorator looks amazing:

Put @bom_part() before any method that defines a part, then call bill_of_materials() after the program is run, and all parts will be counted, priced and reported.

Here's a compost bin I designed in OpenSCAD:

A compost bin designed in OpenSCAD

ORION: The algorithm proving that left isn't right

From a June 2015 UPS deck titled "The Road to Optimization"

ORION is the route-planning system that UPS drivers use. Interesting to read their comments on the r/UPS subreddit. Every comment I've seen mention ORION is about how nonsensical (to a human) the routes are, it slows them down, doesn't compare to experience drivers' route knowledge, etc. The shortcoming might be ORION itself, or, as this comment suggests it might be the fault of the dispatcher entering in inaccurate data, or it's just because there are so many factors like specific pickup/delivery times that rule out more efficient and human-legible routes. The routes are puzzling even to outside observers waiting for their packages.

My main interest in ORION is because of dial-a-ride systems; I first learned of them after reading this book, Multi-agent System Applications: On-demand Electric Vehicles Dial-a-Ride Operation System. Dial-a-ride systems are basically a public precursor to Uber and the like (but with minibuses instead of personal vehicles), from as early as the 1970s. You call up the service a day in advance and let them know when you'd like to be picked up and where you're going. Then some route planner or route planning algorithm figures out routes for each available bus. It's been some time since I read about them in detail, but if I recall one major challenge was limitations in route planning algorithms. Nowadays computing power is not only cheaper but the algorithms have been improved with these ride-sharing services. UberPOOL and Lyft Line basically "reinvented" dial-a-ride systems. Interest in the topic is up again with the possibility of autonomous vehicles, but there still seems to be a lot of promise in their public transit application, and taking whatever Uber or Lyft have developed for that purpose is nice example of feasible algorithmic expropriation.

More on these "demand-responsive transit" systems

Miyazaki's Marxism, Zeria

Miyazaki's Marxism, Zeria

There is so much good media analysis on YouTube and this one is a great reflection on Miyazaki's trajectory from Marxism—especially his belief in labor's power to change the world—to a disenchantment of industrial progress in general and a skepticism towards any possibility of revolutionary change. The more explicitly Marxist elements fade and earlier elements that once co-existed with those previous beliefs come to the fore: romanticism of agrarianism and a more ecologically-harmonious pre-industrial past. Eventually, this romanticism gives way to a deep pessimism and misanthropy in the Nausicaä manga (which sounds wild), where ecological collapse takes center stage. Humanity is irredeemable.

This gives way to Princess Mononoke and Spirited Away, which start to synthesize all of these phases and point towards the possibility of something more positive.

Miyazaki's fluctuating relationship with Japan and nationalism also runs throughout his films. The scale of Japanese atrocities during World War II does not strike me as well known in the US, but I know of them through my family; my grandfather refused to buy Japanese-made cars since several Japanese car companies (Mitsubishi, as in Miyazaki's The Wind Also Rises, and Subaru) have their roots in creating the aircraft used in the war. Miyazaki had a close connection to the war: his father owned an airplane factory during WWII. He clearly struggled with this and Japan's history, and is definitely not trying to make excuses for that history, but I have to say that whole aspect of his work makes me uncomfortable. Especially because of how Japan's reputation in the West has been so sanitized through anime and that network of cultural products.

Also mentioned in the review, but could probably be expanded upon a lot, is Miyazaki's own changing class position throughout his career and what influence that had on his movie's themes.

Anyways, there's a lot more in the review—definitely worth a watch!

Anachronox

The core party of Anachronox

Anachronox is a great game (now 20 years old!) that isn't very well-known, especially compared to the JRPG lineage (Final Fantasy and Chrono Trigger) it draws a lot of inspiration from. I re-watched Errant Signal's reflection on the game which reminded me a lot of the game's best aspects: a strong ensemble cast (each of whom had a special skill for interacting with the game world), its non-seriousness/lightheartedness/comedy, its range of rich environments, and its willingness to try a lot of things—for example, a literal planet as a party member and a comic-book themed sequence that breaks from the rest of the game's style.

The various planets in the game's universe give a nice sense of the game's humor (quoting the video):

  • Democratus: a planet which, as the name implies, enshrines democracy as its core value, but "reveal[s] itself to be an oligarchy because voting on issues is hard and the everyday person might not get it"
  • Sunder: "a planet full of scientists that ironically acts more like a religion by sequestering heretics whose scientific views goes against the orthodoxy"
  • Hephaestus: "a religious planet that operates more like a hyper-capitalist theme park/industrial mine where bishops hawk t-shirts"

The game was originally supposed to have a sequel, because it was basically a financial failure, it never happened.

Make it rain: US states embrace 'cloud seeding' to try to conquer drought, Oliver Milman

First I've seen of cloud seeding in the US. I remember hearing about it while living in China. I'm guessing it also has some drought/agricultural purpose but I was told that it was to help clear out pollution (the skies were noticeably cleaner after rainfall). Another example of "solving" the problem but not the cause: "Experts who have studied cloud seeding point out that it is no panacea, given it doesn't solve the systemic causes of drought".

Thieves Nationwide Are Slithering Under Cars, Swiping Catalytic Converters

Thefts of catalytic converters are increasing as the prices of palladium and rhodium reach record highs, driven in part by stricter pollution regulations for cars. It's an interesting example of how material substitution just throws similar problems down the line. Palladium replaced platinum in catalytic converters as platinum's price climbed, and then there was talk of switching back to platinum because then palladium's price climbed too high.

Would be interesting to have a site that's an exploded view of an ICE car that shows the value of each component in real time, based on its metal composition.

h/t Jay

De Beers: Destruction Is Forever, Matthew Gavin Frank

[The 'Reflections of Nature' jewelry line] includes five unique sets and a total of 39 'exclusive' pieces that, according to De Beers, are meant to honor and 'immortalize the glorious triumph… [and] raw beauty of nature untouched by man.'

The greenwashing of precious stones is a new one. I guess buying pieces of nature to show how much you love nature and destroying nature in the process fits into the current trajectory. This piece gives an example of how corporate-led remediation projects disproportionately focus on the PR/optics rather than the actual remediation, while actively excluding the Indigenous people who can make use of the land. It fits well into the tradition of conservation-as-displacement (Western notions of pristine nature as one without humans, so to conserve nature means to remove people who live there).

What Video Games Assume You Know, Triple Click podcast

After playing video games for a couple decades, there's a lot of game-specific logic I take for granted but that make no sense to someone who hasn't played before. One that I don't think was mentioned in the discussion but that I've encountered a lot is that experimentation/just trying things is "cheap" in games. Some games actively encourage it but others at least have some kind of save system where you can try things without much—if any—penalty. People who haven't played many video games are often worried about making a mistake or messing up as if the consequence will be irreversible.

#1400challenge on Twitter

A collection of ideas of how to put your $1,400 stimulus towards community projects:


@forestofmyth


Log: 3/19/2021

03.19.2021
log

This week: arenas in Rust, food safety and preservation, Jevons' paradox, Buddhism and empire, climate narratives, and Outer Wilds.

My feelings around the Atlanta shootings this week remind me of this piece by Kali Holloway following the capitol riots: "I’m for Abolition. And Yet I Want the Capitol Rioters in Prison.". Cops are the right hand of white supremacy and patriarchy, the criminal justice system is an embodiment of their violence, but in the immediate present...the "justice" that system offers can feel like all that's available. However, actual justice would mean ameiloriating the harms done (what's possible, at least), and doing what it takes to stop something like this from ever happening again, and I know the justice system won't do that.

The banner reads: "the police do not protect us. we have to protect/support each other." (via Xiaowei Wang)

Evaluating Memory Models for Graph‐Like Data Structures in the Rust Programming Language: Performance and Usability, Rasmus Viitanen.

When I first started picking up Rust a couple years ago, the first application I wanted to make was a multithreaded actor system. In an actor system you work with "actors", which can basically do the following things:

  • Receive messages into an inbox
  • Send messages to other actors
  • Read and act on messages

It's totally possible to do something like this in Rust without anything outside of the standard library, e.g. using Arcs and Mutexs, but at the time it felt so messy. I also played around with tracking actors and their inboxes by indices through a single monolithic vectors, but it seemed so hacky. I thought the language and its concepts just weren't clicking for me. So my first experiences with Rust were very frustrating.

It was only later when I re-visited Rust that I learned that these kind of graph-like structures where there may be cyclical references and unclear ownership is exactly what Rust isn't good at (out-of-the-box, at least). I was encouraged to learn that some of the approaches I tried that felt hacky weren't too far off from the recommended approaches. It was around this time that I learned of the arena data structure which makes these (potentially cyclical) graph structures much easier to work with.

The most recent This Week in Rust (#381) includes a paper that compares different approaches for these graph structures, and the arena approach (also called "region-based allocation") performs the best, though there is no one-size-fits-all approach when considering pathological cases. Rust's standard Arc and Rc both perform well too, though leave open the possibility of memory leaks. These perform well in single-threaded contexts, which is actually probably fine because often you have one thread deal with the graph structure (e.g. one thread running a simulation that uses the graph) and preserve other threads for e.g. dealing with networking messages or something (for multi-threaded contexts, the author instead recommends an approach called "epoch-based reclamation" though this doesn't perform as well as arena and Arc/Rc in single-threaded environments).

There are a few arena libraries in Rust: generational-arena, thunderdome, rust-typed-arena, and slotmap. I haven't tried any of these yet so I can't speak to their ergonomics and usability, but I'm looking forward to the chance to do so.

I also came across this post that explains arenas in Rust in more detail and also mentions the bumpalo arena library, which has the advantage of faster allocations but loses memory deallocation/re-use for individual objects (so better if working with groups of objects that are allocated/deallocated all at once).

How not to kill people with your food

Great overview on food safety and preservation techniques. When we think of "food preservation" our minds probably jump to refrigeration as the major innovation, but there are so many other approaches to managing the microbial/viral activity in food, each of which sprouted their own culinary traditions and forms (jams, miso, cured meats, and so on). The show Flavorful Origins covers regional Chinese cuisines and many of the best showcased foods have their genesis in some kind of long-term food storage.

Pickled vegetables from Yunnan in Flavorful Origins

The Jevons paradox unravelled: A multi-level typology of rebound effects and mechanisms and Energy efficiency and economy-wide rebound effects: A review of the evidence and its implications

Energy efficiency improvements are usually advocated with the implication that they will lower energy demand (thus lowering e.g. greenhouse gas emissions). The Jevons Paradox describes how such energy efficiency improvements can paradoxically lead to an increase in aggregate energy demand. While it might be easier to see these effects at a large scale, it can be really hard to pull apart specifics or identify them with a lot of certainty at smaller scales. These effects can be really sprawling too: one example mentioned in Timothée Parrique's "The political economy of degrowth" (which has a good section on rebound effects, using an alternative typology to the one described below) is that more fuel efficient cars further entrench car culture and car infrastructure, which in turn increases reliance on cars, making lower-impact alternatives like bicycles or public transit more costly to adopt.

When I was researching "Inside Out" I struggled to find a lot of material on the paradox (I probably wasn't looking in the right places). This week, however, a couple papers came out on the topic.

The first paper, "The Jevons paradox unravelled: A multi-level typology of rebound effects and mechanisms", lays out a new typology of rebound effects (more detailed than the previous popular typology), breaking them down by mechanism (the actual cause of the effect), the effect (the size of the change in energy consumption), the scale (micro:firm or household, meso:market or sector, macro:national economy, or global:world economy), and the time frame (short or long run), summarized in this figure:

A visual summary of the typology in "The Jevons paradox unravelled: A multi-level typology of rebound effects and mechanisms"

The example they offer gives more details about how the typology works:

efficiency improvements in car production can allow companies to increase profits and expand production (output mechanism) – a mechanism at the micro level. When many firms introduce this new technology, price competition may lead to lower prices and, thereby, to higher sales (intermediate goods and services mechanism) – a mechanism at the meso level. This mechanism at the meso level would not have taken place without the mechanism at the micro level. Mechanisms at higher levels can also impact a rebound effect at a lower level. With regard to the car example, an efficiency improvement can lead to decreasing energy demand at the macro level, which can result in a lower energy price in a competitive energy market (overall energy price mechanism). This reduced price, in turn, further decreases the car manufacturer costs and may trigger additional expansion of production (output mechanism at the micro level).

The second paper is "Energy efficiency and economy-wide rebound effects: A review of the evidence and its implications", which reviews 33 studies looking at economy-wide rebound effects and finds that at least 50% of the gains from energy efficiency are negated by rebound effects, and that this relationship is not captured or is underrepresented in the major integrated assessment models. So these models are probably overly optimistic about the effects of energy efficiency improvements. It's a better result than, say, if the rebound effects exceeded 100% (i.e. energy efficiency improvements lead to an overall increase in energy consumption). But I don't think any of the reviewed studies try to measure rebound effects like the car infrastructure one in "The political economy of degrowth".

The Buddha's Footprint: An Environmental History of Asia, Johan Elverskog

As part of my research for Fugue I've been reading more about East Asian Buddhist schools of thought (Pure Land, Chan, Zen, Huayan, and Tiantai). I had a lot of interest in Buddhism when I was a teenager but it was pretty "basic"; I didn't delve at all into the overwhelming strands of Buddhist tradition and thought (especially their dizzying metaphysics) that developed over the thousands of years of its existence. Fugue will be anchored around cycles, which are central to Buddhism, e.g. in samsara/reincarnation, the imagery of the wheel, etc (owing to its antecedent Indian subcontinent religions), and I wanted to better understand the concepts and their surrounding history before relying on them.

The popular reputation of Buddhism and Buddhists is something like: peaceful/pacifist, austere, gentle, jovial, kind, maybe even environmentally-friendly, and persecuted (Tibetan Buddhists specifically). The Rohingya genocide has disrupted that image (there are also claims of Tibetan slavery and serfdom, which, based on this incredibly detailed thread, sounds like it's not totally accurate in that serfdom/slavery in Tibet didn't completely match European serfdom or chattel slavery, but sounds close enough in that they did indeed have serfs and slaves1) but still might be taken as anomalous in the religion's history. Buddhism's spread, though small compared to the major Abrahamic religions, is substantial, and usually that kind of spread has some kind of violence behind it. I listened to this interview with Johan Elverskog on his recent book, The Buddha’s Footprint: An Environmental History of Asia, where he discusses Buddhism's relationship to empire and expansion, which supports this suspicion.

One main point he argues is that Buddhism, despite its reputation as ascetic, is a prosperity theology. Austerity is for the monks and nuns, but for the laity its conception of karma provides a framework for rationalizing/justifying wealth separate from birth/caste. It makes it more "meritocratic"—if you're wealthy, you must have done something to deserve it (good karma). Wealth becomes something you earn based on personal merit, rather than something you're born (or not born) into.

He also mentions Buddhism's role in the expansion of empires: that monasteries are located where they are as part of the development of commodity frontiers and owned tremendous amounts of lane, that monks had an active role in the spread of more intensive agriculture and used slave labor for that agriculture, and that these stem from the fact that Buddhism requires surplus production to support the clergy and devotional displays of large and ornate monasteries and the like. He even goes as far as pointing to European colonialism as a comparison. Buddhism, as an organized entity, is not unlike other major organized religions or states—they have their own interests, and expand to secure those interests.

Along a similar thread: There's a strong impulse to secularize Daoism in the West; it's very common to portray Daoism as a philosophy with no organized component. This is also very far from the historical reality of Daoism, which is an organized religion with its own clergy and temples and gods and scriptures beyond the Dao de jing. It has also been tied up in the history of Chinese empire and certainly has had suffering and blood spilled in its name. For more, see "The Taoism of the Western Imagination and the Taoism of China: De-Colonializing the Exotic Teachings of the East" (with some dunking on Western "Daoist" pop-psychology), "Common misconceptions concerning Daoism (Taoism)" (a much more concise overview), and this encyclopedia entry.

The Ministry for the Future, or Do Authors Dream of Electric Jeeps? Samuel Miller McDonald

A very critical review of Kim Stanley Robinson's Ministry for the Future, which, disclaimer: I haven't yet read, so I can't really comment on the fairness of the review. I found it helpful more for thinking through climate narratives and theories of change around climate change than about the book itself. The reviewer describes the tension between useful present value and abstract future value; i.e. how hard it is to convince someone to give up something in the present for something so far in the future that it feels abstract, that they probably won't be around for. The example given is "fishing plastic out of the ocean", which serves two purposes: keeping the fishing industry employed (valuable politically and preserves livelihoods) and cleaning waste from the oceans (environmentally valuable), contrasted against fishing fish (which gives you fish now, but at the potential expense of fewer or no fish in the future). I don't know if this is the best example to make that point—cleaner oceans have near-term benefit as well (water recreation, there are probably some short-term effects on fish stocks too), but the general framing is helpful for me.

The reviewer also poses another problem very clearly: "how you make the economics of not manufacturing more profitable than manufacturing".

A more constructive piece of criticism:

Utopian imaginaries often set up a dichotomy between a high tech, complex global economy growing ever more complex until it spans the solar system, versus a return to what’s imagined as “primitivism,” foraging for scraps, or toiling as a vast agrarian peasantry. But there’s something in between and beyond that we need to envision. It takes imagination, and for those who make a living using theirs to render it.

I think about this a lot: this dichotomy is really deeply rooted, and it's really hard for people who hear something like the term "degrowth" to envision it as anything other than regression, a suggestion of extreme austerity and poverty. Sure, some degree of re-ruralization/re-agrarianization may be in the cards, but it doesn't mean a life of uncertainty, precarity, and suffering (at least, not any more than what we already have) or a sudden loss of all the knowledge we've accumulated in the past few centuries.

The review also criticizes the book's focus on bureaucratic/technocratic institutions as the main actor in combating climate change, in contrast to (for example) on-the-ground direct action and the like. It was good to read alongside this reflection on forest defense/occupation in Germany, which includes debates on sabotage and militancy's effectiveness in achieving their goals (which go beyond the immediate goal of halting the clearing of trees).

There were also a couple papers referenced in the review that were interesting:

  • "It’s the End of the World and They Know It: How Dystopian Fiction Shapes Political Attitudes": "there are strong reasons to think that ideas contained in fiction may have just as strong an impact on people’s beliefs and attitudes as nonfictional content, given that people tend to incorporate ‘facts’ they learn regardless of whether the source is labeled fiction or nonfiction, and the narrative structure typical of fiction is known to be exceptionally powerful in shaping cognition and persuasion."
    • And: "we find consistent evidence that dystopian narratives enhance the willingness to justify radical—especially violent—forms of political action"
  • "Narrative structure of A Song of Ice and Fire creates a fictional world with realistic measures of social complexity": A social network analysis of the Game of Thrones books: There are roughly 2000 characters mentioned in the books, though each chapter (which are each told from a different character's POV) has around 35 characters on average. 35 people "has been identified as a stable subgrouping within social networks and as the typical size of (contemporary) bands of hunter-gatherers." The POV characters rank high on degree and centrality measures in the complete series' social network; that is, the POV characters are also the ones most important in the social network, and the major POV characters have an average degree of 154 (close to Dunbar's number, "the average number of stable relationships usually maintained at any given point in human life"). These features make the large amount of characters in the series cognitively manageable.

Outer Wilds

Riebeck playing the banjo in Outer Wilds

Possible spoilers for Outer Wilds and The Three-Body Problem

I finished Outer Wilds this week, after first giving it a try maybe a year ago. I had trouble getting into it at first, but the whole thing comes together as the loop of the game becomes familiar (the game is structured around a repeating 22 minute loop) and you start putting together the star system's mysteries. The process of investigation and discovery work really well, as simple as they are. Reading other comments, it seems like a lot of people also found the game to be unassuming and then are struck with how attached they become. The relatively brief encounters you have with the other (living) characters end up being surprisingly powerful by the end. The final sequence will probably stick with me for a long time—I was really struck by how unexpectedly emotional it was, providing small comfort in something as terrifying (but also so distant as to be entirely abstract) as cosmic death. One of the central themes in Fugue is rebirth, and Outer Wilds portrays it beautifully.

It reminded me of the ending for The Three-Body Problem, which now that I'm thinking about it has a very similar, but less moving, end. Interstellar maybe also tried to grapple something similar, what about quantum physics and the scale of space and time and so on, but it didn't land in the same way.

In any case, I highly recommend it.


Me, at the end of Outer Wilds


  1. From the thread: "The situation in Bhutan is still in living memory and we can probably infer that the situation in Tibet wasn't very different. In Bhutan, like Tibet, there was a very rigid aristocratic system. The majority of properties that weren't run-of-the-mill subsistence farmers run by extended families (80% of the population), were either monasteries run by tulkus (meritocratic systems run by knowledge of the Buddhist scriptures, Drukpa Kagyu in Bhutan, Gelukpa or Karma Kagyu in Tibet), or Lamaist choje families. ... So while these large extended aristocratic families ruled estates and concerned themselves with matter of religion and politics, the first set of serfs were lay-followers who didn't want to take the vows of Buddhist monks or nuns but still wanted to live in close proximity to the Lamas. These people became the first class of serfs called "drap." Drap were not hereditary, so while they were not taxed individuals, their children were born free. Drap were also granted less menial jobs in the house and were oftentimes more skilled than their contemporaries. The "Zap," the lower class of serfs/slaves, were a little bit different. ... Bhutan has a long tradition of north-south contact with Assam and Tibet, and less but still prevalent east-west contact with Sikkim. Part of this included the slave trade where parties of Bhutanese raiders would descend into Indian territory and kidnap Assamese, Bengali, Nepalis, etc. and sell or trade them as workers to wealthy families. Note this is not chattel slavery like we're familiar with. The parties of Bhutanese raiders tended to be associated directly with this village or that chöje family and already knew who they were kidnapping Zap for. There were no slave markets. That said, the Zap were hereditary. Their children were born Zap and their descendants still live in Bhutan (and Tibet) today. While the Lamas were required to cordon off a part of their land for Drap to live and provide for their own sustenance, the Lama was given no real obligation to provide the Zap with shelter. They showed up on the Lama's estate, were given three meals, and worked. (I have no idea how this system was enforced. It seems like it would be rather easy to run away and I'm sure there was a lot of that happening." 


Log: 3/12/2021

03.12.2021
log

I'm going to try to write more regularly and this seems like a good, low-pressure format. It'll also help me remember what I read/was thinking about during the week and ground the passage of time more (I hope).

The Distributive Effects of Risk Prediction in Environmental Compliance: Algorithmic Design, Environmental Justice, and Public Policy

Examines the shortcoming of an algorithmic/machine learning approach to allocating resources for Clean Water Act violations. The current model's objective function is the number of violations as opposed to the severity of violations. So it would prioritize, for example, frequent but small amounts of pollution over infrequent but large amounts. However, the frequency of violations itself a function of who's health is prioritized (i.e. where violations are routinely checked for), and the existing distribution of environmental violations exacerbates this inequity, given that polluting facilities are more likely to be sited around/within marginalized communities (so not only are violations less frequently checked for, but the total amount of pollution is also greater). The choice of that objective function just further compounds those environmental inequities. h/t Jay

A comprehensive quantification of global nitrous oxide sources and sinks

Gives a sense of the scale of NO2 emissions and insight into its main driver (fertilizer). That simulated fertility is killing the planet is a real twisted thing. I have a piece in edits about fertilizer (draft here), and after writing that it became really clear why some consider the "metabolic rift" (which in a crude/oversimplified way is about the dislocation of agricultural production) as one of the foundational pieces of capitalism. Via this summary of the paper

Anatomy of a counter-insurgency: Efforts to undermine the George Floyd uprising, Martin Schoots-McAlpine and The other side of the COIN: counterinsurgency and community policing, Kristian Williams

A useful overview of how state counterinsurgency tactics played out over the peak of last year's George Floyd protests and a deeper dive into the development of counterinsurgency tactics and the police-military pipeline in apply/developing strategies domestically and abroad.

All COIN tactics are focused on building legitimacy with the population and the approaches mostly shake out to a kind of "good cop, bad cop" at the level of a city, region, or nation. A key first step is drawing a line (whether real or not) between "radical" or "extremist" elements and more "moderate" elements (usually along the lines of "violence" and non-violence; I put "violence" in quotes because actions that go no further than property destruction are considered "violence" in this context). On one hand, this division serves to make crackdowns on the radical group more palpable to the moderate elements, and it also encourages the more moderate elements to scramble to demonstrate their non-belonging to the radical group and basically act as a mouthpiece for/collaborators with e.g. the police. This radical-moderate division in this particular case is also applied to the police themselves, with the isolation of the murderous cops as "bad apples" (though seeing no real consequence for it) and the rest of them as moderate, and the moderate elements of both parties (moderate protesters and moderate cops) fuse together in a way that is meant to amplify (the military might say "force multiply") their "reasonableness" (i.e. cops marching with protesters or whatever).

Each piece goes into more depth and covers a lot of the longer-term foundation-building work (e.g. the role non-profits play).

Semi-related is this photo collection of DIY protest gear made by the Tute Binache, a movement that was inspired by the EZLN (see below).

The Uprising of Dignity - The Zapatista Movement in Chiapas / Mexico

I knew about the EZLN (they had a pretty potent media presence in the 90's; Rojava has maybe taken up a similar place today; I don't know if Rage Against the Machine has a song about Rojava but people there have been playing RATM) but couldn't really tell you much detail about them (I don't mention them at all in the fertilizer piece above, when in retrospect I really should have); this documentary that gives some insight into their day-to-day life and organization. I don't know how dated the documentary is (looks like it might be from the 90's) but it's clear that they've achieved a lot though still struggle with internal issues such as women's self-determination and, of course, the Mexican state and paramilitary forces. I have to imagine that there have been many changes in the decades since.

There was also a great exhibit about them at the Queens Museum in 2019, featuring a giant corn spaceship.

'I learned about storytelling from Final Fantasy': novelist Raven Leilani on Luster and video games, Raven Leilani interviewed by Keith Stuart

In the past couple months I've been thinking more seriously about a game, Fugue, that I've had in the back of my mind for years now (I'll write more about it in the near future). Two main reference points are Final Fantasy VII and Final Fantasy VIII, since those two games were so formative for me and had a very strong ensemble cast element to them. So it was exciting to see this interview with Raven Leilani, who also points to FF7 as an inspiration. Her words on FF7 and video games in general resonated with my thinking around Fugue:

"Games are not simply an escape from the real world, they're a place to process what has happened in the real world," says Leilani. "That's how it has worked for me. I'm extremely introverted and I'm naturally inclined to more solitary activities. I want to be sucked into an experience."

When I ask Leilani if playing Final Fantasy has influenced her approach to storytelling, she nods enthusiastically. Luster is filled with beautiful, intricate observations – she places brand names, specific disco songs and other cultural artefacts with the exactness of an artist setting up a still life painting. This, she says, is something she learned from RPGs. “You follow a character on this journey of self-discovery, and I like the work that it entails. I like going into villagers’ houses and finding what’s there, I like talking to NPCs and exhausting my options. I love being rewarded for that attention and rigour … It’s hard to articulate the magic of a world that responds to you in that way.

“RPGs represent something that is central to making art, which is data collection and attention. You have to be rigorous and curious – because curiosity, too, is central to art,” she says. “You have to seek out the gifts that are built into the world. Playing those games and seeing how they work and knowing how to advance not just the game but the character in their journey, helped give me patience for the accumulation of small epiphanies and small interactions.

“All of it means something – that’s the most succinct way I can put it. Small things matter.”

(Incidentally, something bizarre/brilliant about FF7 is that Barret, who is the leader of the eco-group that bombs planet-killing energy facilities in the game, later becomes an oil prospector in FF7: Advent Children.)

Visible mending

A beautiful example of visible mending:

A patchwork visible-mended jacket

I learned to sew this past year and have been doing a fair amount of repairing worn clothing and modding old backpacks and the like. Here are a few things I've made:

A gardening toolbelt for Kira, featuring an embroidered Korok

A paintbrush roll for Ferris

Modded Mission Workshop backpack (added water bottle holders and compression straps)

Nier: Automata mechanics

Nier: Automata spoilers ahead

I never had any interest in Nier: Automata but caught wind that there were some interesting mechanics in it, so I ended up watching this playthrough of it to see what they were. There were some neat ideas—a lot of nods to the fact that it's a video game, mostly—but I was underwhelmed in the end. The ambient multiplayer is nice, where the bodies of other players appear in your game, but it didn't seem all that much different than Dark Souls et al in that feature (at this point Death Stranding probably has the most interesting ambient multiplayer, where players build infrastructure for each other). Though it was pretty cool to see the opening credits/title sequence not show up until like 25 hours into the game lol.

I knew going into the playthrough that there was something about "sacrificing your game save" but didn't realize it would be at the very end of the game! There is basically a very difficult shoot-em-up sequence over the end credits, and other players end up forming a shield around you so you can survive until the end. When a player is hit, they "die", meaning their save game is deleted. At the end, you decide if you too are willing to sacrifice your save game so another player can make it until the end. It's a really neat idea but at that point you're basically finished the game so the weight of the decision is considerably less than if, say, there were parts of the game you actually gave up as a result.

Things I don't understand about NFTs

I wish I could ignore this NFT internet fight but I can't. This summarizes a lot of my feelings on the topic:

NFTs by @simulacracid

Everest Pipkin covers a lot of the environmental problems here, so I won't really mention those, as important as they are. I've seen that piece patronizingly dismissed by NFT advocates as "not having good arguments" or "better than most anti-NFT arguments" (implied to still not be very good). I've never seen anyone elaborate how or why. The closest is things like: crypto responds to price signals so as renewables get cheaper, more of its energy will be renewable, or pointing out that Ethereum is switching to proof-of-stake. Whether or not the energy is renewable is kind of beside the point, all energy has a opportunity cost and we have to stop thinking that isn't the case. Expanding even renewable energy production is not without its impacts, so we can't take for granted that we can build out more solar or wind to satisfy crypto when that energy could probably be used in better ways. I've seen it argued that in China and perhaps elsewhere that the energy being used would otherwise go to waste; I have to imagine that crypto is not the only way that energy can be used. In any case, the present environmental cost alone is (should be) enough to turn people away from NFTs, and some pale promise of a greener crypto stack in the indeterminate future gives no comfort.

As the image above points out, one of the best parts of the digital medium is near-zero marginal cost replication. With that in mind this push for NFTs feels sort of like a kind of digital enclosure. The analogy doesn't totally work because enclosure takes common land use for subsistence whereas here it's "closing off" something that people don't live off of (and would argue is exactly the problem, that the easy of copying and difficulty of tracking are exactly what make it hard to live off of say digital music). Maybe that completely negates the analogy. But in any case it seems to squander a really unique and important property of the digital world. And the off-chance of making money off it as an artist feels just like another form of capitalist meritocracy masquerading as the only feasible and legitimate way to a better life. I'm curious to see the numbers on this, but I suspect that the vast majority of money made with NFTs is through people with already well-established presences and that are already materially doing ok (though I know that these two things aren't highly correlated in the arts). I pointed out elsewhere that it seems telling that the examples used are often already-established artists/companies like Adidas and Kanye, since ultimately an NFT's value has to be realized through a secondary market of some kind. It smells a little like the WSB/GME situation, which was basically Wall Street kayfabe that got spun into a nonsense David-vs-Goliath story—rich insiders against rich insiders played off as some kind of populist revolution.

What enforces the connection between the ownership of the crypto asset and ownership of its referent? If I sold an NFT that I said represented an image I made, if I later declare that I no longer recognize that as a valid indication of ownership, what would happen? I suppose collectors or whoever would refuse to recognize my claim, but could they sue me or what? I guess many kinds of financial value are on similarly shaky ground. Can you "double mint" NFTs to point to the same thing?

That said, I get the appeal of automatically re-capturing a fraction of re-sale and I know that it's extremely hard to get by in the arts...but are NFTs really going to change that or are they only the most recent grift that promises to do so?

Anyway, I hope that's enough to get the NFT bug out of my head.



Vim and Note-taking/Writing

03.11.2021
etc

A while ago I posted about research tools I've built and a few parts focused on enhancements to vim (taking screenshots, opening media and links, automatically formatting text from pdfs), which is still my preferred program for writing and note-taking. Here are a few other enhancements that make it a more pleasant experience.

I have all of the following snippets enabled for markdown only (in ~/.vim/ftplugin/markdown.vim).

Spelling correction

I still make a lot of typos and don't notice until a bit later. This snippet lets you hit <ctrl-f> while in insert or normal mode to automatically fix the closest speling error. This is an example.

setlocal spell

" quickly fix the closest previous spelling error.
imap <c-f> <c-g>u<Esc>[s1z=`]a<c-g>u
nmap <c-f> [s1z=``

The only shortcoming is that the default vim dictionary is really lacking, so a lot of common words come up as spelling errors. You can easily add words to the dictionary by moving over them and hitting zg by default.

Quickly fixing a typo in vim

Preview markdown as HTML

Sometimes it's easier to read through a markdown file as HTML. This lets you use <leader>v to compile the file and open it in a browser using nom.

" compile and open in browser
nnoremap <leader>v :r !nom view "%:p"<cr>

Previewing markdown with nom

Create footnote from text

I try my best to keep my citations organized in anything public-facing, but if you have a lot of footnotes it can be troublesome to manage them all in markdown. This lets me highlight a citation, hit <ctrl-f>, and then fills my clipboard with a markdown-formatted citation to paste in.

" make footnote from selected text
vnoremap <C-f> y:! cite "<C-r>0" \| xsel -b<cr>

Automatically generating a markdown footnote from a selection

Writing mode

One challenge with writing in vim is that the text width can be too wide. There's a popular plugin called goyo that helps with this by artificially constraining the current vim window to a smaller number of columns, but I always had issues with it. Fortunately I found a much simpler implementation that I adapted below.

" writing mode
" <https://stackoverflow.com/a/59955784>
function! ToggleWriteMode()
  let l:name = '_writeroom_'
  if bufwinnr(l:name) > 0
    colorscheme dark
    :bwipeout _writeroom_
  else
    colorscheme light

    " hide vertical split
    hi VertSplit ctermfg=bg ctermbg=NONE cterm=NONE

    " auto-close writeroom buffers when the text buffer closes
    autocmd QuitPre <buffer> :bwipeout _writeroom_

    " target column width
    let l:target = 90
    let l:width = (&columns - l:target) / 2
    silent! execute 'topleft' l:width . 'vsplit +setlocal\ nobuflisted' l:name | wincmd p
    silent! execute 'botright' l:width . 'vsplit +setlocal\ nobuflisted' l:name | wincmd p
    endif
endfunction
nnoremap <silent> <leader>w :call ToggleWriteMode()<cr>

Toggling writing mode

Table of contents navigation

In vim it's harder to get a sense of the high-level document structure and navigate through sections. There's a plugin called VOoM that basically adds a table of contents pane for markdown documents. It's nice but a bit cumbersome to jump to it and make your section selection there.

Instead I've set up a way to pull up section headings and quickly jump to them using the fzf.vim plugin (which I'll describe in more detail in the next section) and ripgrep.

" Table of Contents (for markdown files)
" Jump to line match from ripgrep
" Expects that the line is delimited with ':'
" and the first field is the line number.
function! s:line_handler(line)
    let keys = split(a:line, ':')
    execute "normal! " . keys[0] . "gg"
endfunction

" Args
" - Source: user ripgrep to search for one or more '#' at the start of a line
"   in the current file
" - Sink: use the line hanlder function above to jump to the selected line
" - Options:
"   - reverse output
"   - split on ':' and take all fields from the 2nd on
"   (i.e. skip the line number)
command! -bang -complete=dir -nargs=? TOC
    \ call fzf#run(fzf#wrap('toc', {
        \'source': 'rg -Tcsv --line-number --no-heading "^#+" '.expand('%:p'),
        \'sink': function('s:line_handler'),
        \'options': '--reverse --delimiter=: --with-nth=2..'
    \}, <bang>0))

nnoremap <leader>e :TOC<cr>

Pulling up the table of contents and jumping to a section

fzf.vim

I put very little effort into keeping my notes organized these days because of fzf.vim. It makes it very easy to quickly search through files by filename or contents from within vim (using ripgrep).

Using fzf.vim to quickly search files by filename and contents

You can get a pseudo-wiki functionality with the following, which searches files for the word under the cursor:

" Search for word under cursor
nnoremap <silent> <Leader>g :Rg <C-R><C-W><CR>

Using fzf.vim to quickly search files for the word under the cursor

Honorable mention: Opening files

This isn't anything I've added to vim, but is really useful. If your cursor is over a file path, you can hit gf to open that file in vim. It gives you a wiki-like functionality (though more cumbersome) or a way of making indices for research topics.

An example project index (gf to open file under cursor and <ctrl-o> to jump back to the index)


Research Tools

10.31.2019
etc

My fellowship at the Jain Family Institute involves a lot of reading and research across various sources: typically papers in the form of PDFs, articles on my phone browser, and ePub books.

Prior to the fellowship the research I did was spontaneous and infrequent enough that my ad hoc system of typing out highlights by hand into a one or more markdown files and sorting through them manually worked alright. But now that I'm dealing with many, many more pages of research, this system has become kind of unwieldy.

Here I'll go over the tools I've built over the past couple years (most within the past year) to make this process more manageable. They are mostly meant to address a few key pain points:

  • Aggregating highlights from across several platforms (phone, desktop, and eReader) into a central repository
  • Capturing charts and other graphics
  • Tagging and organizing highlights
  • Generating footnotes

These tools are still new—I'm still testing and tweaking them—so they don't quite link up as well as they should. Eventually they'll likely be grouped into a single tool, but that might not be for awhile.

Setup

Basically all of my reading happens on either my phone (Android), my laptop, or my eReader (a Kobo). Documents are either web articles (phone and laptop), PDFs (laptop1), or ePubs (eReader). I'll occasionally print out PDFs, especially if I'm having a hard time focusing on the laptop.

The last pieces of the setup are vim, which I use to take notes and save highlights, and Firefox (though everything here would work fine for Chrome/Chromium).

eReader

The eReader is the most straightforward. Kobo readers have a built-in function for highlighting and annotating text. I haven't really tested if this works for images though.

The highlighting and annotating functions work smoothly for the proprietary Kobo .kepub format, which books from the Kobo store come in. For .epub books, the highlighting is atrociously slow and finicky. Fortunately, .epub files can be converted to .kepub with kepubify.

Kobo eReaders store highlights and annotations in a SQLite database. I have a script which exports rows from this database to a JSON file, and another script that lets you easily mount and run this script when you plug your Kobo into your laptop.

Web articles

Copy and paste

On the desktop, saving text web articles are also straightforward: copy and paste. When text from a web article is copied, it's saved in your system clipboard as both plain text and as HTML. When pasting into vim, only the plain text is pasted. Sometimes it's helpful for me to have the HTML pasted—to preserve links, for example—but as markdown instead (since my notes are in markdown files).

I have a tool called nom I developed to make managing markdown files easier. One function it has is nom clip, which takes HTML saved in the system clipboard, converts it to markdown, and then prints it out.

In my vim configuration file for markdown files (~/.vim/ftplugin/markdown.vim) I bound <leader>c to call this function, prepend > to each line (which defines a blockquote in markdown), and then output it into vim2:

" easily paste html clipboard content as quoted markdown
function! PasteQuotedHTML()
    augroup AsyncGroup
        autocmd!
        autocmd User AsyncRunStop normal P
    augroup END
    call asyncrun#run("!", "", "nom clip | sed 's/^/> /' | xsel -bi")
endfunction
nnoremap <leader>c :call PasteQuotedHTML()<cr>

Converting clipboard HTML to markdown

Mobile

Highlighting on phones is less straightforward. I briefly tried copying highlights into an email, sending it to myself, then copying it into a markdown file when I got to my laptop, but this ended up being too complicated and unpleasant.

I wrote a web extension called hili (for Firefox, but should work for Chrome in theory) that streamlines this. With hili, you select text or an image on a webpage, select "Highlight", and then a tag prompt comes up. Enter the tags and save the highlight, and the selected text or image data, along with some metadata about the page (url, title), is sent to a server that appends the data to a JSON file. The goal here was a very fire-and-forget, uninterrupting way of highlighting that is easy to search through later.

hili desktop demo

One snag is that this requires a server to communicate with. I run the application on my personal server, but I'm often reading on the subway where there's only an intermittent internet connection. For awhile this meant I'd be reading an article and come across something I'd want to save, but have to wait until the next subway stop for the internet connection to come back. Now hili queues highlights locally (indicated by the yellow box below) until an internet connection is detected, at which point the local highlights are synchronized with the server.

hili mobile demo

hili also helped with an anxiety of mine: I'd procrastinate reading articles that sounded especially interesting because I was worried about forgetting its contents. With hili I can save highlights without much thought, and this is less of a worry.

PDFs

PDF is a horrible format. It's really not meant for reading on computers...but we do it anyways. Copy and pasting from text from a PDF will result in weird line breaks, there are often broken words (hyphenated) because the text is frequently justified, and is not particularly precise in selecting the text you want.

For a long time I'd either 1) copy the PDF text and manually fix line breaks, broken words, and delete extraneous text; or 2) manually type in whatever I wanted to highlight. Even though it probably takes longer, I usually went with the latter—it just felt faster than jumping around correcting little errors.

Fortunately, the copy-and-paste errors are consistent enough that a lot of the cleanup can be automated, which is what this script does. This feels small, but ends up being a huge time saver. Like with HTML pasting, I added a function to my vim configuration (same file as before), bound to <leader>d, which automatically applies this processing to text in the system clipboard:

" easily paste pdf clipboard content as quoted markdown
function! PasteQuotedPDF()
    augroup AsyncGroup
        autocmd!
        autocmd User AsyncRunStop normal P
    augroup END
    call asyncrun#run("!", "", "xsel -b | ~/.bin/pdfpaste | sed 's/^/> /' | xsel -bi")
endfunction
nnoremap <leader>d :call PasteQuotedPDF()<cr>

It's not perfect though. The heuristics used to clean up the text can hit false positives, as in the demo below ("European-derived" is collapsed to "Europeanderived" because the script takes all hyphenations at the end of lines to be word breaks).

Automatically formatting pasted PDF text

Some PDFs are scans of books or articles. These are basically just images, so highlighting text usually doesn't work with them. If you're lucky, the scans will have been OCR'd and there will be selectable text. However, the OCR quality can vary; sometimes you'll copy in PDF text and have to manually correct errors, which can be tedious. Still, better than manually typing in everything.

In any case, what's to be done for graphics in PDFs? I have a simple script for taking screenshots which dumps them into a folder (~/docs/shots/). I added another function to my vim configuration (same file as before) that automatically moves this to a folder called assets (relative to the current markdown file) and then drops in the markdown syntax for the image:

" screenshot, move to assets folder, paste in markdown
nnoremap <leader>s "=system("fpath=$(shot region <bar> tail -n 1); fname=$(basename $fpath); mv $fpath assets/$fname; echo '![](assets/'$fname')'")<CR>P

Capturing a screenshot and auto-pasting markdown

And finally, another vim function lets me easily view the image with gx:

" open markdown syntax urls
" open local images with feh
" open local gifs with gifview
function! OpenUrlUnderCursor()
    let l:lnum = line('.')
    let l:line = getline(l:lnum)
    let l:coln = col('.')

    let l:lcol = l:coln
    while l:line[l:lcol] != '(' && l:line[l:lcol] != '<' && l:lcol >= 0
        let l:lcol -= 1
    endwhile

    let l:rcol = l:coln
    while l:line[l:rcol] != ')' && l:line[l:rcol] != '>' && l:rcol <= col("$")-1
        let l:rcol += 1
    endwhile

    let l:obj = l:line[l:lcol + 1: l:rcol - 1]
    let l:url = matchstr(l:obj, '\(http\|https\):\/\/[^ >,;]*')
    let l:img = matchstr(l:obj, '[^<>()]\+\.\(jpg\|jpeg\|png\|gif\)')
    if l:url != ''
        call netrw#BrowseX(l:url, 0)
    elseif l:img != ''
        if matchend(l:img, 'gif') >= 0
            silent exec "!gifview -a '".l:img."'" | redraw!
        else
            silent exec "!feh --scale-down '".l:img."'" | redraw!
        endif
    else
        echomsg 'The cursor is not on a link.'
    endif
endfunction
nnoremap gx :call OpenUrlUnderCursor()<cr>

Quickly viewing a saved image

Tagging and sorting

The final piece is the most recent addition: a tool for quickly going through highlights and tagging bits of text. When I'm in the middle of research, I'm using dumping pretty large chunks of text into my notes file, without worrying too much about annotating or tagging it. Early on in the research I'm often not really sure what's relevant, or how a particular highlight fits into the broader topic or questions I'm interested in.

At the end, however, I'm left with hundreds of pages of text chunks that I need to go through and sort. I used to go through all of these highlights and repeat the copy-and-pasting process, just with smaller chunks of text organized into tag groups. It was an extremely slow process.

Now I have grotto3, which renders these notes as HTML, and provides a very quick interface to select and tag text and images. This information is all saved into a CSV file that can easily be processed later.

As a bonus, since the tags and annotations are well-structured, grotto can automatically organize these selections into an outline (well, tag groupings) and generate markdown footnotes.

grotto demo

Future work

Right now these various tools don't really talk to each other, and they dump their data in different locations and in somewhat different formats. In the future these formats would be harmonized and another tool would be built to quickly explore and search through them. Until then, it's a manual process.

I've also been curious to try mind maps as a way to organize research. grotto could help with this by auto-generating a mind map based on tag co-occurrence, but I haven't given it a try yet. Even so, there's something to be said for the tactile experience of organizing information on paper, so an automatic system might not be ideal.

Honorary mention: signal-daemon

signal-daemon

A tool that isn't directly related to highlighting or annotating text but is worth mentioning is signal-daemon, which is a very simple script that lets you "text" notes to another number you register with Signal (e.g. a Google Voice number), and then downloads those texts to a markdown file on your computer. I use this to write down random thoughts, in general, but also on whatever topic I'm researching.


  1. I tried reading PDFs on my phone and found it too straining. I did however put together a script that extracts highlights and annotations for MoonReader, available here

  2. This uses the asyncrun plugin. 

  3. There were a lot of challenges setting up the tag highlighting interactions, mostly to do with the DOM model having a tree structure and edge cases involving overlapping or nested tag highlights...happy to go more into it if it's of interest to anyone. 

<< >>