header, new posts and code blocks
This commit is contained in:
parent
6d9060c987
commit
f47c5075fe
|
@ -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" },
|
||||
]
|
||||
|
|
|
@ -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).
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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.
|
|
@ -2,4 +2,4 @@
|
|||
sort_by = "date"
|
||||
+++
|
||||
|
||||
hoi
|
||||
# Posts
|
||||
|
|
|
@ -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/)
|
||||
|
|
@ -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; }
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<h2>{{ ss.title }}</h2>
|
||||
{% set ps = ss.pages | sort(attribute="date") | reverse %}
|
||||
<ul>
|
||||
{% for page in ss.pages %}
|
||||
{% for page in ps %}
|
||||
<li>
|
||||
<a href="{{ page.permalink | safe }}">{% if page.date and not config.extra.no_list_date %}{{ page.date }} - {% endif %}{{ page.title }}</a>
|
||||
<br />
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block header %}
|
||||
<p><a href="{{ section.path }}..">..</a>{{ section.path }}</p>
|
||||
|
||||
<h1>{{ section.title }}</h1>
|
||||
{% endblock header %}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<hr>
|
||||
<details>
|
||||
<summary>{{ summary }}</summary>
|
||||
<pre><code>
|
||||
{{- body -}}
|
||||
</code></pre>
|
||||
</details>
|
||||
<hr>
|
|
@ -0,0 +1,5 @@
|
|||
<hr>
|
||||
<pre><code>
|
||||
{{- body -}}
|
||||
</code></pre>
|
||||
<hr>
|
Loading…
Reference in New Issue