header, new posts and code blocks

This commit is contained in:
Erik Winter 2025-01-15 20:11:22 +01:00
parent 6d9060c987
commit f47c5075fe
15 changed files with 107 additions and 34 deletions

View File

@ -19,8 +19,9 @@ highlight_theme = "charcoal"
[extra] [extra]
# Put all your custom variables here # Put all your custom variables here
list_pages = true list_pages = true
no_list_date = true
header_nav = [ header_nav = [
{ name = "home", url = "/" }, { name = "posts", url = "/" },
{ name = "about", url = "/" }, { name = "about", url = "/about" },
] ]

View File

@ -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: To add basic caching headers for different filetypes, add an expires directive to your nginx config file, like this:
``` {% code() %}
# Expires map # Expires map
map $sent_http_content_type $expires { map $sent_http_content_type $expires {
default off; default off;
@ -23,7 +23,7 @@ server {
expires $expires; expires $expires;
... ...
``` {% end %}
- `off` means no caching headers. - `off` means no caching headers.
- `epoch` is no caching, ask the website itself. - `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: 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/ttf ttf;
font/opentype otf; font/opentype otf;
font/woff woff; font/woff woff;
font/woff2 woff2; 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: 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; gzip_types text/plain text/css ... font/ttf font/opentype;
``` {% end %}
In `/etc/nginx/nginx.conf` (on Debian). In `/etc/nginx/nginx.conf` (on Debian).

View File

@ -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: 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 #!/bin/bash
MINUTES=25 MINUTES=25
if [ "$1" == "break" ]; then if [ "$1" == "break" ]; then
@ -16,7 +16,7 @@ fi
wmctrl -N "Pomodoro" -r :ACTIVE: wmctrl -N "Pomodoro" -r :ACTIVE:
termdown --no-figlet --no-seconds --no-window-title ${MINUTES}m termdown --no-figlet --no-seconds --no-window-title ${MINUTES}m
wmctrl -b add,demands_attention -r "Pomodoro" 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. 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.

View File

@ -11,7 +11,7 @@ After some failed attempts with `bg` and `fg`, it turned out that bash does not
The working result: The working result:
```bash {% code() %}
#!/bin/bash #!/bin/bash
set -m set -m
@ -31,7 +31,7 @@ mongo /scripts/mongo_init.js
echo "Bringing back Mongo..." echo "Bringing back Mongo..."
fg fg
``` {% end %}
## Sources ## Sources

View File

@ -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: 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 {% code() %}
$ reflex -r '\.go$' -- sh -c 'clear && go test -v ./web/model --run TestEvent' $ 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. - **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. - **-r** indiates that it should only watch changes in files that satisfy the following regex pattern.

View File

@ -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`. 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 VAR1=this
VAR2=that VAR2=that
VAR3=those VAR3=those
``` {% end %}
```make `Makefile`:
# Makefile
{% code() %}
include .env include .env
.EXPORT_ALL_VARIABLES: .EXPORT_ALL_VARIABLES:
task: task:
@echo "VAR1 is ${VAR1}" @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 @docker-compose up
``` {% end %}
``` `docker-compose.yml`:
# docker-compose.yml
{% code() %}
... ...
app: app:
image: "registry/the_app:${VAR2}" image: "registry/the_app:${VAR2}"
environment: environment:
- VAR3=${VAR3} - VAR3=${VAR3}
``` {% end %}
## Sources ## Sources

View File

@ -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 alias: Pause/Play on Squeezelite Toren
description: "" description: ""
triggers: triggers:

View File

@ -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.

View File

@ -2,4 +2,4 @@
sort_by = "date" sort_by = "date"
+++ +++
hoi # Posts

View File

@ -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/)

View File

@ -37,7 +37,7 @@ body {
h2, h3, h4, h5, h6 { margin-top: 3rem; } h2, h3, h4, h5, h6 { margin-top: 3rem; }
hr { margin: 2rem 0; } hr { margin: 1.5rem 0; }
p { margin: 1rem 0; } p { margin: 1rem 0; }
@ -79,7 +79,7 @@ code {
pre code { pre code {
display: block; display: block;
overflow-x: auto; overflow-x: auto;
white-space: pre-wrap; //white-space: pre-wrap;
//padding: 1rem; //padding: 1rem;
} }
@ -108,4 +108,4 @@ img {
} }
} }
nav, .taxonomies { text-align: center; } nav, .taxonomies { text-align: left; }

View File

@ -10,7 +10,7 @@
<h2>{{ ss.title }}</h2> <h2>{{ ss.title }}</h2>
{% set ps = ss.pages | sort(attribute="date") | reverse %} {% set ps = ss.pages | sort(attribute="date") | reverse %}
<ul> <ul>
{% for page in ss.pages %} {% for page in ps %}
<li> <li>
<a href="{{ page.permalink | safe }}">{% if page.date and not config.extra.no_list_date %}{{ page.date }} - {% endif %}{{ page.title }}</a> <a href="{{ page.permalink | safe }}">{% if page.date and not config.extra.no_list_date %}{{ page.date }} - {% endif %}{{ page.title }}</a>
<br /> <br />

View File

@ -1,8 +1,6 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block header %} {% block header %}
<p><a href="{{ section.path }}..">..</a>{{ section.path }}</p>
<h1>{{ section.title }}</h1> <h1>{{ section.title }}</h1>
{% endblock header %} {% endblock header %}
@ -25,4 +23,4 @@
{% if paginator %} {% if paginator %}
<p>{% if paginator.previous %}<a href="{{ paginator.first }}">&lt;&lt; First</a> <a href="{{ paginator.previous }}">&lt; Previous</a>{% endif %} [{{ paginator.current_index }}/{{ paginator.number_pagers }}] {% if paginator.next %}<a href="{{ paginator.next }}">Next &gt;</a> <a href="{{ paginator.last }}">Last &gt;&gt;</a>{% endif %}</p> <p>{% if paginator.previous %}<a href="{{ paginator.first }}">&lt;&lt; First</a> <a href="{{ paginator.previous }}">&lt; Previous</a>{% endif %} [{{ paginator.current_index }}/{{ paginator.number_pagers }}] {% if paginator.next %}<a href="{{ paginator.next }}">Next &gt;</a> <a href="{{ paginator.last }}">Last &gt;&gt;</a>{% endif %}</p>
{% endif %} {% endif %}
{% endblock content %} {% endblock content %}

View File

@ -1,6 +1,8 @@
<hr>
<details> <details>
<summary>{{ summary }}</summary> <summary>{{ summary }}</summary>
<pre><code> <pre><code>
{{- body -}} {{- body -}}
</code></pre> </code></pre>
</details> </details>
<hr>

View File

@ -0,0 +1,5 @@
<hr>
<pre><code>
{{- body -}}
</code></pre>
<hr>