From f47c5075fe69ea13aa940ae9be0e1e025f33e54d Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Wed, 15 Jan 2025 20:11:22 +0100 Subject: [PATCH] header, new posts and code blocks --- ewintr.nl/config.toml | 5 +-- .../2020/basic-caching-headers-in-nginx.md | 12 +++---- ...-timer-in-bash-with-termdown-and-wmctrl.md | 4 +-- .../2020/job-control-in-bash-scripts.md | 4 +-- .../2020/quick-go-test-cycle-with-reflex.md | 7 ++-- ...ment-variables-for-make-bash-and-docker.md | 23 ++++++------ ...ible-media-player-with-physical-buttons.md | 2 +- ...matically-mount-nfs-shares-with-systemd.md | 36 +++++++++++++++++++ ewintr.nl/content/_index.md | 2 +- ewintr.nl/content/about/_index.md | 27 ++++++++++++++ .../themes/no-style-please/sass/style.scss | 6 ++-- .../no-style-please/templates/index.html | 2 +- .../no-style-please/templates/section.html | 4 +-- .../{details.html => code-details.html} | 2 ++ .../templates/shortcodes/code.html | 5 +++ 15 files changed, 107 insertions(+), 34 deletions(-) create mode 100644 ewintr.nl/content/2025/til-one-can-automatically-mount-nfs-shares-with-systemd.md create mode 100644 ewintr.nl/content/about/_index.md rename ewintr.nl/themes/no-style-please/templates/shortcodes/{details.html => code-details.html} (91%) create mode 100644 ewintr.nl/themes/no-style-please/templates/shortcodes/code.html diff --git a/ewintr.nl/config.toml b/ewintr.nl/config.toml index 3b2b747..d5028a1 100644 --- a/ewintr.nl/config.toml +++ b/ewintr.nl/config.toml @@ -19,8 +19,9 @@ highlight_theme = "charcoal" [extra] # Put all your custom variables here list_pages = true +no_list_date = true header_nav = [ - { name = "home", url = "/" }, - { name = "about", url = "/" }, + { name = "posts", url = "/" }, + { name = "about", url = "/about" }, ] diff --git a/ewintr.nl/content/2020/basic-caching-headers-in-nginx.md b/ewintr.nl/content/2020/basic-caching-headers-in-nginx.md index b69c125..efc533e 100644 --- a/ewintr.nl/content/2020/basic-caching-headers-in-nginx.md +++ b/ewintr.nl/content/2020/basic-caching-headers-in-nginx.md @@ -5,7 +5,7 @@ date = 2020-01-05 To add basic caching headers for different filetypes, add an expires directive to your nginx config file, like this: -``` +{% code() %} # Expires map map $sent_http_content_type $expires { default off; @@ -23,7 +23,7 @@ server { expires $expires; ... -``` +{% end %} - `off` means no caching headers. - `epoch` is no caching, ask the website itself. @@ -35,18 +35,18 @@ server { It could be that this does not work right away for fonts, as nginx defaults to the `application/octet-stream mimetype` for those filetypes. To fix this, add these lines to the `/etc/nginx/mime.types` config file: -``` +{% code() %} font/ttf ttf; font/opentype otf; font/woff woff; font/woff2 woff2; -``` +{% end %} Don't forget to add the first two to the list of gzipped mimetypes, the last two already have compression baked into the format: -``` +{% code() %} gzip_types text/plain text/css ... font/ttf font/opentype; -``` +{% end %} In `/etc/nginx/nginx.conf` (on Debian). diff --git a/ewintr.nl/content/2020/basic-pomodoro-timer-in-bash-with-termdown-and-wmctrl.md b/ewintr.nl/content/2020/basic-pomodoro-timer-in-bash-with-termdown-and-wmctrl.md index 7a12a98..1ceaf8c 100644 --- a/ewintr.nl/content/2020/basic-pomodoro-timer-in-bash-with-termdown-and-wmctrl.md +++ b/ewintr.nl/content/2020/basic-pomodoro-timer-in-bash-with-termdown-and-wmctrl.md @@ -7,7 +7,7 @@ Like many other systems that aim to add some structure in the chaos of todo-item After some failed attempts to install `i3-pomodoro`, where I first had to upgrade my `i3status` to `i3blocks`, with its own configuration and all, I realized I just wanted one very simple thing from Pomodoro: a timer that lets me do some focused work for a certain period of time. Nothing more. For simple things, Bash is still the best: -```bash +{% code() %} #!/bin/bash MINUTES=25 if [ "$1" == "break" ]; then @@ -16,7 +16,7 @@ fi wmctrl -N "Pomodoro" -r :ACTIVE: termdown --no-figlet --no-seconds --no-window-title ${MINUTES}m wmctrl -b add,demands_attention -r "Pomodoro" -``` +{% end %} This runs a terminal timer that counts down to zero from a specified amount of minutes and then lets the window manager draw attention to it in it's native way. In default i3 this means the border turns red, as well as the workspace indicator in the status bar. diff --git a/ewintr.nl/content/2020/job-control-in-bash-scripts.md b/ewintr.nl/content/2020/job-control-in-bash-scripts.md index 9131e13..6836235 100644 --- a/ewintr.nl/content/2020/job-control-in-bash-scripts.md +++ b/ewintr.nl/content/2020/job-control-in-bash-scripts.md @@ -11,7 +11,7 @@ After some failed attempts with `bg` and `fg`, it turned out that bash does not The working result: -```bash +{% code() %} #!/bin/bash set -m @@ -31,7 +31,7 @@ mongo /scripts/mongo_init.js echo "Bringing back Mongo..." fg -``` +{% end %} ## Sources diff --git a/ewintr.nl/content/2020/quick-go-test-cycle-with-reflex.md b/ewintr.nl/content/2020/quick-go-test-cycle-with-reflex.md index ee249be..0371503 100644 --- a/ewintr.nl/content/2020/quick-go-test-cycle-with-reflex.md +++ b/ewintr.nl/content/2020/quick-go-test-cycle-with-reflex.md @@ -5,9 +5,10 @@ date = 2020-01-04 While you are working on some piece of code, it is nice to have some feedback about whether you broke or fixed something by running the relevant unit tests. To automate this I usually have a terminal window open with the following command: -```bash -$ reflex -r '\.go$' -- sh -c 'clear && go test -v ./web/model --run TestEvent' -``` +{% code() %} +$ reflex -r '\.go$' -- \ + sh -c 'clear && go test -v ./web/model --run TestEvent' +{% end %} - **reflex** is a small utilty that watches for changes on the file system. - **-r** indiates that it should only watch changes in files that satisfy the following regex pattern. diff --git a/ewintr.nl/content/2020/shared-environment-variables-for-make-bash-and-docker.md b/ewintr.nl/content/2020/shared-environment-variables-for-make-bash-and-docker.md index 6249f6e..477ae6a 100644 --- a/ewintr.nl/content/2020/shared-environment-variables-for-make-bash-and-docker.md +++ b/ewintr.nl/content/2020/shared-environment-variables-for-make-bash-and-docker.md @@ -9,33 +9,36 @@ Docker-compose can use an `.env` file to substitute variables in a `docker-compo Incuding this `.env` file in your `Makefile` makes hem available there as well, but they are not automatically exported to the Bash shells that are spawned by `make` to execute the targets. This can be changed by adding the `.EXPORTALLVARIABLES:` target to your `Makefile`. -``` -# .env +`.env`: + +{% code() %} VAR1=this VAR2=that VAR3=those -``` +{% end %} -```make -# Makefile +`Makefile`: + +{% code() %} include .env .EXPORT_ALL_VARIABLES: task: @echo "VAR1 is ${VAR1}" - @some_command # some_command can use $VAR1, $VAR2 and $VAR3 + @some_command # some_command can use $VAR1, $VAR2, $VAR3 @docker-compose up -``` +{% end %} -``` -# docker-compose.yml +`docker-compose.yml`: + +{% code() %} ... app: image: "registry/the_app:${VAR2}" environment: - VAR3=${VAR3} -``` +{% end %} ## Sources diff --git a/ewintr.nl/content/2024/an-invisible-media-player-with-physical-buttons.md b/ewintr.nl/content/2024/an-invisible-media-player-with-physical-buttons.md index 60b34a2..53b1e44 100644 --- a/ewintr.nl/content/2024/an-invisible-media-player-with-physical-buttons.md +++ b/ewintr.nl/content/2024/an-invisible-media-player-with-physical-buttons.md @@ -68,7 +68,7 @@ We can check for the current length of the queue and issue the command if it is --- -{% details(summary="Click to view a yaml example of the automation") %} +{% code-details(summary="Click to view a yaml example of the automation") %} alias: Pause/Play on Squeezelite Toren description: "" triggers: diff --git a/ewintr.nl/content/2025/til-one-can-automatically-mount-nfs-shares-with-systemd.md b/ewintr.nl/content/2025/til-one-can-automatically-mount-nfs-shares-with-systemd.md new file mode 100644 index 0000000..71d7101 --- /dev/null +++ b/ewintr.nl/content/2025/til-one-can-automatically-mount-nfs-shares-with-systemd.md @@ -0,0 +1,36 @@ ++++ +title = "TIL one can automatically mount NFS shares with systemd" +date = 2025-01-15 ++++ + +This might have been be obvious to some, but sometimes you don't learn about better ways to do something, just because the existing solution is not bad enough to spur you into action. + +Today, I learned that you can add a line to `/etc/fstab` and let `systemd` take care of how and when a network share should be mounted: + +``` +192.168.1.35:/volume1/notes /mnt/nas/notes nfs defaults,x-systemd.automount,vers=4 0 0 +``` + +The magic happens by adding `x-systemd.automount` to the options. This will leave the share unmounted until you access it. + +To make it effective, reload the `systemd` configuration with: + +```bash +$ sudo systemctl daemon-reload +``` + +And you're done. At least that is what everyone on the internet says. I needed to reboot before the change took effect. This also assumes that you have taken care of all other NFS related stuff, like installing `nfs-common` etc. + +## Backstory + +Sometimes you don't want to mount the share at boot. I have bad memories of when a share would somehow not be reachable over the network and some headless computer, of course stowed somewhere way back in an attic, would refuse to start because of that. And then I had to dig it out, attach a keyboard and a monitor to remove the line from `/etc/fstab` to get it working again. + +Other times you have a laptop and the share is simply not accessible. + +In the past, I used [autofs](https://help.ubuntu.com/community/Autofs) to cover situations like this. `autofs` also only mounts the share when it is accessed, but it has the ability to run a script first. + +This was helpful when I had a NAS that would regularly go to sleep to save power. One can write a script that pings your NAS, and sends a [WoL](https://en.wikipedia.org/wiki/Wake-on-LAN) packet to wake it up if it doesn't respond. This is an example of a script that implements that: [gist](https://gist.github.com/dj-mcculloch/9e097535ea35df8e2ec1e6e32f7f73ac) + +This was not perfect, though. Because even when the NAS was awake and ready, it could take seconds before I could access it. Not sure what caused it, but annoying it was. Even more so because often file managers and other apps in your desktop environment will try to inspect the contents of your directories in the background, over and over again, for all sorts of reasons. Sometimes I had to wait 10 seconds before I could open a directory, even when it was readily available. + +These days, my NAS has more duties to fulfil and is always on. This has been the case for months. But I was still waiting for `autofs` every day. Until I installed a new computer and thought: oh, might as well put it directly in `/etc/fstab`, and asked an LLM to help me with the config. diff --git a/ewintr.nl/content/_index.md b/ewintr.nl/content/_index.md index 872bd59..2424883 100644 --- a/ewintr.nl/content/_index.md +++ b/ewintr.nl/content/_index.md @@ -2,4 +2,4 @@ sort_by = "date" +++ -hoi +# Posts diff --git a/ewintr.nl/content/about/_index.md b/ewintr.nl/content/about/_index.md new file mode 100644 index 0000000..f7b950d --- /dev/null +++ b/ewintr.nl/content/about/_index.md @@ -0,0 +1,27 @@ ++++ +title = "About" ++++ + +## Hi, + +My name is Erik, and I am a Dutch software developer. Go is my language of choice, as one can easily gather from the posts on this site. At work I like to program in Go, outside of work I like to program in Go. + +When I am not programming... I dream of programming in Go. Nah, just kidding, I mostly do the same things as everyone else. Listen to music, watch movies, etc. I also have written some short stories and other fiction. If you can understand Dutch, you can read them at [vrijkorteverhalen.nl](https://vrijkorteverhalen.nl) 🇳🇱. + +## Find me elsewhere + +- Code + - [forgejo.ewintr.nl](https://forgejo.ewintr.nl/explore/repos) + - [Github.com](https://github.com/ewintr) (mirror) +- Dev and Tech: + - [Tweakers.net](https://tweakers.net/gallery/88794/) + - [Lobste.rs](https://lobste.rs/u/ewintr) + - @ewintr on the [Gophers Slack](https://gophers.slack.com/join/shared_invite/zt-1vukscera-OjamkAvBRDw~qgPh~q~cxQ#/shared-invite/email) +- Music + - [rateyourmusic.com](https://rateyourmusic.com/~ewintr) + - [Last.fm](https://www.last.fm/user/ewintr) +- Direct + - [Email](mailto:e@ewintr.nl) +- Business + - [LinkedIn.com](https://www.linkedin.com/in/erik-winter-5767a923b/) + diff --git a/ewintr.nl/themes/no-style-please/sass/style.scss b/ewintr.nl/themes/no-style-please/sass/style.scss index 0e06ee3..ce7b9e3 100644 --- a/ewintr.nl/themes/no-style-please/sass/style.scss +++ b/ewintr.nl/themes/no-style-please/sass/style.scss @@ -37,7 +37,7 @@ body { h2, h3, h4, h5, h6 { margin-top: 3rem; } -hr { margin: 2rem 0; } +hr { margin: 1.5rem 0; } p { margin: 1rem 0; } @@ -79,7 +79,7 @@ code { pre code { display: block; overflow-x: auto; - white-space: pre-wrap; + //white-space: pre-wrap; //padding: 1rem; } @@ -108,4 +108,4 @@ img { } } -nav, .taxonomies { text-align: center; } +nav, .taxonomies { text-align: left; } diff --git a/ewintr.nl/themes/no-style-please/templates/index.html b/ewintr.nl/themes/no-style-please/templates/index.html index e33b069..c5505b9 100644 --- a/ewintr.nl/themes/no-style-please/templates/index.html +++ b/ewintr.nl/themes/no-style-please/templates/index.html @@ -10,7 +10,7 @@

{{ ss.title }}

{% set ps = ss.pages | sort(attribute="date") | reverse %}