42nd Week of 2023
Activism⚑
-
New: Add song for Gaza.
We Will Not Go Down (Song for Gaza Palestine) - Michael Heart
Life Management⚑
Task Management⚑
Org Mode⚑
-
New: Code blocks syntax.
Org offers two ways to structure source code in Org documents: in a source code block, and directly inline. Both specifications are shown below.
A source code block conforms to this structure:
<body>
You need to use snippets for this to be usable.
An inline code block conforms to this structure:
src_<language>{<body>}
or
src_<language>[<header arguments>]{<body>}
Where:
#+NAME: <name>
: (Optional) Names the source block so it can be called, like a function, from other source blocks or inline code to evaluate or to capture the results. Code from other blocks, other files.#+BEGIN_SRC’ … ‘#+END_SRC
: (Mandatory) They mark the start and end of a block that Org requires.<language>
: (Mandatory) It is the identifier of the source code language in the block. See Languages for identifiers of supported languages.<switches>
: (Optional) Switches provide finer control of the code execution, export, and format.<header arguments>
: (Optional) Heading arguments control many aspects of evaluation, export and tangling of code blocks. Using Org’s properties feature, header arguments can be selectively applied to the entire buffer or specific subtrees of the Org document.<body>
: Source code in the dialect of the specified language identifier.
-
It's not yet supported to focus or zoom on one task.
-
New: Interesting things to investigate.
- org-bullets.nvim: Show org mode bullets as UTF-8 characters.
- headlines.nvim: Add few highlight options for code blocks and headlines.
- Sniprun: A neovim plugin to run lines/blocs of code (independently of the rest of the file), supporting multiples languages.
- Python library: Org-rw
- List of plugins
Knowledge Management⚑
Spaced Repetition⚑
-
New: Introduce spaced repetition references.
Game Theory⚑
-
New: Add the evolution of trust game theory game.
Game theory shows us the three things we need for the evolution of trust:
- Repeat interactions: Trust keeps a relationship going, but you need the knowledge of possible future repeat interactions before trust can evolve
- Possible win-wins: You must be playing a non-zero-sum game, a game where it's at least possible that both players can be better off -- a win-win.
- Low miscommunication: If the level of miscommunication is too high, trust breaks down. But when there's a little bit of miscommunication, it pays to be more forgiving
DevOps⚑
Continuous Integration⚑
Shellcheck⚑
-
New: Introduce shellcheck.
Shellcheck is a linting tool to finds bugs in your shell scripts.
apt-get install shellcheck
Errors
SC2143: Use
grep -q
instead of comparing output with[ -n .. ]
.Problematic code:
if [ "$(find . | grep 'IMG[0-9]')" ] then echo "Images found" fi
Correct code:
if find . | grep -q 'IMG[0-9]' then echo "Images found" fi
Rationale:
The problematic code has to iterate the entire directory and read all matching lines into memory before making a decision.
The correct code is cleaner and stops at the first matching line, avoiding both iterating the rest of the directory and reading data into memory.
Storage⚑
OpenZFS⚑
-
New: Mount a dataset that is encrypted.
If your dataset is encrypted using a key file you need to:
- Mount the device that has your keys
- Import the pool without loading the key because you want to override the keylocation attribute with zfs load-key. Without the -l option, any encrypted datasets won't be mounted, which is what you want.
- Load the key(s) for the dataset(s)
- Mount the dataset(s).
zpool import rpool # without the `-l` option! zfs load-key -L file:///path/to/keyfile rpool zfs mount rpool
-
New: Umount a pool.
zpool export pool-name
-
Correction: Improve the Repair a DEGRADED pool instructions.
First you need to make sure that it is in fact a problem of the disk. Check the
dmesg
to see if there are any traces of reading errors, or SATA cable errors.A friend suggested to mark the disk as healthy and do a resilver on the same disk. If the error is reproduced in the next days, then replace the disk. A safer approach is to resilver on a new disk, analyze the disk when it's not connected to the pool, and if you feel it's safe then save it as a cold spare.
Monitoring⚑
Loki⚑
-
New: Introduce loki.
Loki is a set of components that can be composed into a fully featured logging stack.
Unlike other logging systems, Loki is built around the idea of only indexing metadata about your logs: labels (just like Prometheus labels). Log data itself is then compressed and stored in chunks in object stores such as Amazon Simple Storage Service (S3) or Google Cloud Storage (GCS), or even locally on the filesystem.
A small index and highly compressed chunks simplifies the operation and significantly lowers the cost of Loki.
Authentication⚑
Authentik⚑
-
New: Troubleshoot I can't log in to authentik.
In case you can't login anymore, perhaps due to an incorrectly configured stage or a failed flow import, you can create a recovery key.
To create the key, run the following command:
docker run --it authentik bash ak create_recovery_key 1 akadmin
This will output a link, that can be used to instantly gain access to authentik as the user specified above. The link is valid for amount of years specified above, in this case, 1 year.
Operating Systems⚑
Linux⚑
Linux Snippets⚑
-
New: Wipe a disk.
Overwrite it many times with badblocks.
badblocks -wsv -b 4096 /dev/sde | tee disk_wipe_log.txt
-
New: Impose load on a system to stress it.
sudo apt-get install stress stress --cpu 2
That will fill up the usage of 2 cpus. To run 1 vm stressor using 1GB of virtual memory for 60s, enter:
stress --vm 1 --vm-bytes 1G --vm-keep -t 60s
You can also stress io with
--io 4
, for example to spawn 4 workers. -
New: Get the latest tag of a git repository.
git describe --tags --abbrev=0
-
New: Configure gpg-agent cache ttl.
The user configuration (in
~/.gnupg/gpg-agent.conf
) can only define the default and maximum caching duration; it can't be disabled.The
default-cache-ttl
option sets the timeout (in seconds) after the last GnuPG activity (so it resets if you use it), themax-cache-ttl
option set the timespan (in seconds) it caches after entering your password. The default value is 600 seconds (10 minutes) fordefault-cache-ttl
and 7200 seconds (2 hours) for max-cache-ttl.default-cache-ttl 21600 max-cache-ttl 21600
For this change to take effect, you need to end the session by restarting
gpg-agent
.gpgconf --kill gpg-agent gpg-agent --daemon --use-standard-socket
-
New: Get return code of failing find exec.
When you run
find . -exec ls {} \;
even if the command run in theexec
returns a status code different than 0 you'll get an overall status code of 0 which makes difficult to catch errors in bash scripts.You can instead use
xargs
, for example:find /tmp/ -iname '*.sh' -print0 | xargs -0 shellcheck
This will run
shellcheck file_name
for each of the files found by thefind
command.
Gancio⚑
Hard drive health⚑
-
New: Check the disk health with smartctl.
Start with a long self test with
smartctl
. Assuming the disk to test is/dev/sdd
:smartctl -t long /dev/sdd
The command will respond with an estimate of how long it thinks the test will take to complete.
To check progress use:
smartctl -A /dev/sdd | grep remaining smartctl -c /dev/sdd | grep remaining
Don't check too often because it can abort the test with some drives. If you receive an empty output, examine the reported status with:
smartctl -l selftest /dev/sdd
If errors are shown, check the
dmesg
as there are usually useful traces of the error. -
New: Check the health of a disk with badblocks.
The
badblocks
command will write and read the disk with different patterns, thus overwriting the whole disk, so you will loose all the data in the disk.This test is good for rotational disks as there is no disk degradation on massive writes, do not use it on SSD though.
WARNING: be sure that you specify the correct disk!!
badblocks -wsv -b 4096 /dev/sde | tee disk_analysis_log.txt
If errors are shown is that all of the spare sectors of the disk are used, so you must not use this disk anymore. Again, check
dmesg
for traces of disk errors.
Vim⚑
-
New: Concealment.
Some plugins allow the conceal of some text, for example in orgmode you will only see the text of the description of a link and not the content, making it more pleasant to read. To enable it set in your config:
-- Conceal links -- https://github.com/nvim-orgmode/orgmode#links-are-not-concealed -- Use visual mode to navigate through the hidden text vim.opt.conceallevel = 2 vim.opt.concealcursor = 'nc'
Where:
-
conceallevel
: Determine how text with the "conceal" syntax attribute is shown: -
0
: Text is shown normally 1
: Each block of concealed text is replaced with one character. If the syntax item does not have a custom replacement character defined the character defined in 'listchars' is used (default is a space). It is highlighted with the "Conceal" highlight group.2
: Concealed text is completely hidden unless it has a custom replacement character defined.-
3
: Concealed text is completely hidden. -
concealcursor
: Sets the modes in which text in the cursor line can also be concealed. When the current mode is listed then concealing happens just like in other lines. n
: Normal modev
: Visual modei
: Insert modec
: Command line editing, for 'incsearch'
A useful value is
nc
. So long as you are moving around text is concealed, but when starting to insert text or selecting a Visual area the concealed text is displayed, so that you can see what you are doing. -
yq⚑
-
New: Introduce yq.
yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor. It uses
jq
like syntax but works with yaml files as well as json, xml, properties, csv and tsv. It doesn't yet support everythingjq
does - but it does support the most common operations and functions, and more is being added continuously. -
New: Find and update items in an array.
We have an array and we want to update the elements with a particular name.
Given a
sample.yaml
file of:- name: Foo numBuckets: 0 - name: Bar numBuckets: 0
Then
yq '(.[] | select(.name == "Foo") | .numBuckets) |= . + 1' sample.yaml
will output:- name: Foo numBuckets: 1 - name: Bar numBuckets: 0
-
New: Iterate over the elements of a query with a bash loop.
readarray dependencies < <(yq e -o=j -I=0 '.roles[]' requirements.yaml) for dependency in "${dependencies[@]}"; do source="$(echo "$dependency" | yq e '.src' -)" done
Android⚑
HappyCow⚑
-
New: Introduce Happycow.
Happycow is a web application and android app to search vegan restaurants nearby.
The android app requires google services to work :(.
Arts⚑
Dancing⚑
Lindy Hop⚑
Video Gaming⚑
Age of Empires⚑
-
New: Added references.
- Hera channel: Awesome to learn to play
- Hera gameplay channel: Good 1st person point of view games
- Tatoh channel: Good spanish content.
Science⚑
Math⚑
-
3Blue1Brown. Recomended by Nicky Case
Other⚑
-
New: Ansible retry a failed job.
- command: /usr/bin/false retries: 3 delay: 3 register: result until: result.rc == 0
-
New: Introduce Bookwyrm.
Bookwyrm is a social network for tracking your reading, talking about books, writing reviews, and discovering what to read next. Federation allows BookWyrm users to join small, trusted communities that can connect with one another, and with other ActivityPub services like Mastodon and Pleroma.
-
New: Introduce Elastic security.
Elastic security is a program to protect, investigate, and respond to complex threats by unifying the capabilities of SIEM, endpoint security, and cloud security.
-
New: Introduce RSS.
Note: This post is a shameless direct copy of Nicky beautiful post, read it there as it has beautiful illustrations
What is RSS (Really Simple Syndication)?
Imagine an open version of Twitter or Facebook News Feed, with no psy-op ads, owned by no oligopoly, manipulated by no algorithm, and all under your full control.
Imagine a version of the newsletter where you don't have to worry about them selling your email to scammers, labyrinth-like unsubscribe pages, or stuffing your inbox with ever more crap.
Now imagine this existed and was extremely popular 15 years ago. Then we got suckered by the shiny walled gardens.
Well, it's time to make like a tree and go back to the future, baby!
Unlike newsletters where give each publisher your email (and they may abuse that trust), RSS works on a "don't call me, I'll call you" policy.
An RSS feed is a text file on a website. It's just a bunch of posts – no tracking or "personalization" – like a printed newspaper:
Then, whatever RSS reader app you use – you can use any app made by anyone – it'll call the websites for the feeds you specifically opted into, no more or less. The websites can't force it in the other direction.
Your app then shows you your posts in good ol' reverse chronological order. (Some apps let you add extra filters, but unlike social media algorithms, you control 'em.) Apps also make the posts prettier than raw text:
Really Simple, indeed!
First, you need a reader app. Such as the minimalist Inoreader, but Feedly is the most popular, and folks use The Old Reader. See this list of readers.
To add a feed to your app, just paste a link to the blog/site, and your app will automatically find the feed! RSS also lets you follow creators on YouTube, Substack, Medium, and more.
- Beware the hoarder instinct. No algorithm can save you from hoarding feeds "just in case", then being overwhelmed. The only cure is to ruthlessly Marie Kondo that crap – if a feed doesn't consistently enrich your life, cut it.
- Some feeds only give you the excerpt of a post, with a link to see the full post at their site. Don't follow those: they break you out of the RSS reading experience, and trick you into losing time on their site. (This is a harsh rule: I used to follow Quanta Magazine's feed, but they switched from full-text to excerpts, so I unsubscribed.)
- Don't follow feeds that update more than once a day. Go for daily digests, or better yet, weekly digests.
If RSS Was So Great, Why'd It Die In The First Place
Well, Google killed Google Reader in 2013, the #1 RSS reader at the time. This was to make way for Google Plus, which failed. The sacrificial lamb was for nothing.
But Google only did what nearly everyone – including yours truly – did in 2013: leave the open, decentralized Web 1.0 for the shiny new Web 2.0 platforms. Why? Well, it was more fun & convenient.
But now in 2021, for most of us, social media is very not fun and not convenient. That's why I went back to the future with RSS, and wrote this post encouraging you to do the same!
(Ok, RSS had two more problems: 1) Getting overwhelmed with feeds. As said above, the only cure is to trim ruthlessly. 2) RSS lets you serve text/link/image ads, but not the creepy user-tracking ads. In 2013 that was the "best" way make money on the web, but these days ad revenue is dying, and subscriptions like Patreon/Substack are thriving.)
And that's all, folks! Now you know how to escape the attention-draining, empathy-killing, critical-thought-suffocating siren song of the algorithms. And get your inbox less cluttered with newsletters.