Move all files to zet-old/

This commit is contained in:
Oliver Davies 2025-10-02 00:53:28 +01:00
parent e1badc9fd5
commit 29d11fa9b9
60 changed files with 0 additions and 0 deletions

17
zet-old/.editorconfig Normal file
View file

@ -0,0 +1,17 @@
# This file is used by editors and IDEs to unify coding standards
# @see http://EditorConfig.org
# @standards PHP: http://www.php-fig.org/psr/psr-2/
root = true
# Default configuration (applies to all file types)
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_size = 4
indent_style = space
# Markdown customizations
[*.md]
trim_trailing_whitespace = false

1
zet-old/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
# Load the issue ID from an `.issue-id` file within the project and replace the
# `ISSUE_ID` placeholder within a Git commit message.
#
# For example, running `echo "OD-123" > .issue-id` will add `Refs: OD-123` to
# the commit message.
#
# This also works with multiple issue IDs in the same string, e.g.
# "OD-123 OD-456", or IDs on multiple lines.
set -o errexit
set -o nounset
set -o pipefail
PROJECT_DIR=$(git rev-parse --show-toplevel)
ISSUE_FILE="$PROJECT_DIR/.issue-id"
if [ -f "${ISSUE_FILE}" ]; then
ISSUE_IDS=$(cat "${ISSUE_FILE}" | tr '\n' ',' | tr ' ' ',' | sed 's/,$//' | sed 's/,/, /g')
if [ -n "${ISSUE_IDS}" ]; then
sed -i.bak "s/# Refs:/Refs: $ISSUE_IDS/" "$1"
fi
fi

38
zet-old/.github/workflows/main.yaml vendored Normal file
View file

@ -0,0 +1,38 @@
---
name: Build and Deploy
on:
push:
branches:
- main
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
- uses: actions/checkout@v4
- name: Install dependencies
run: nix develop --command composer install
- name: Generate the website
run: |
nix develop --command ./run generate
tree output_prod
env:
APP_ENV: production
NODE_ENV: production
- name: Install the deploy key and known hosts
run: |
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/deploy && chmod 600 ~/.ssh/deploy
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts && chmod 600 ~/.ssh/known_hosts
- name: Deploy the website
run: ssh -i ~/.ssh/deploy zet-oliverdavies-uk@ssh.oliverdavies.uk

12
zet-old/.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
/.phpunit.cache
/.phpunit.result.cache
/output_*/
/vendor/
# Front-end assets.
node_modules
source/build
/.direnv/

1
zet-old/.stignore Normal file
View file

@ -0,0 +1 @@
.direnv/

5
zet-old/.yamlfmt.yaml Normal file
View file

@ -0,0 +1,5 @@
---
formatter:
type: basic
include_document_start: true
retain_line_breaks_single: true

5
zet-old/README.md Normal file
View file

@ -0,0 +1,5 @@
# zet.oliverdavies.uk
My personal Zettelkasten notes, powered by [Sculpin](https://sculpin.io).
All notes are located in the `source/_zets` directory and can also be viewed at <https://zet.oliverdavies.uk>

View file

@ -0,0 +1,6 @@
---
sculpin_content_types:
posts:
enabled: false
zets:
permalink: /notes/:basename-:title/

View file

@ -0,0 +1,5 @@
---
name: zet.oliverdavies.uk
locale: en
github:
url: https://github.com/opdavies/zet.oliverdavies.uk

View file

@ -0,0 +1,4 @@
---
imports:
- sculpin_site.yml
url: https://zet.oliverdavies.uk

View file

@ -0,0 +1,9 @@
---
name: zet.oliverdavies.uk
template: sculpin-site
parameters:
nix:
devshell:
packages:
- php81
- php81Packages.composer

25
zet-old/composer.json Normal file
View file

@ -0,0 +1,25 @@
{
"name": "opdavies/zet.oliverdavies.uk",
"description": "A skeleton Sculpin site.",
"license": "proprietory",
"authors": [
{
"name": "Oliver Davies",
"homepage": "https://www.oliverdavies.uk"
}
],
"require": {
"sculpin/sculpin": "^3.0"
},
"cripts": {},
"extra": {
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"config": {
"allow-plugins": {
"sculpin/sculpin-theme-composer-plugin": true
}
}
}

3527
zet-old/composer.lock generated Normal file

File diff suppressed because it is too large Load diff

27
zet-old/flake.lock generated Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1723991338,
"narHash": "sha256-Grh5PF0+gootJfOJFenTTxDTYPidA3V28dqJ/WV7iis=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "8a3354191c0d7144db9756a74755672387b702ba",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

19
zet-old/flake.nix Normal file
View file

@ -0,0 +1,19 @@
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
{
description = "A Nix Flake for sculpin-skeleton";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) mkShell;
in {
devShells.${system}.default =
mkShell { buildInputs = with pkgs; [ php81 php81Packages.composer ]; };
formatter.${system} = pkgs.nixfmt;
};
}

48
zet-old/run Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Do not edit this file. It is automatically generated by https://www.oliverdavies.uk/build-configs.
set -o errexit
set -o nounset
set -o pipefail
PATH="${PATH}:./vendor/bin"
# Generate the site.
function generate {
local args=()
if [[ "${APP_ENV:-}" == "production" ]]; then
args=(--env="prod")
else
args=(--server --watch)
fi
sculpin generate "${args[@]}" "${@}"
}
function help {
printf "%s <task> [args]\n\nTasks:\n" "${0}"
compgen -A function | grep -v "^_" | cat -n
printf "\nExtended help:\n Each task has comments for general usage\n"
}
function setup {
composer install
}
# Start the project.
function start {
sculpin generate --server --watch "${@}"
}
# Include any local tasks.
# https://stackoverflow.com/a/6659698
[[ -e "${BASH_SOURCE%/*}/run.local" ]] && source "${BASH_SOURCE%/*}/run.local"
TIMEFORMAT="Task completed in %3lR"
time "${@:-help}"
# vim: ft=bash

45
zet-old/run.local Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
function clean {
rm -fr output_*
}
# Create a new note.
function new {
if [[ "$1" == "" ]]; then
echo "Usage: ./run new <title>"
exit 1
fi
title="$1"
zet_path="source/_zets"
zet_count=$(find "$zet_path" -type f | wc -l)
next_zet=$((zet_count + 1))
next_zet_path="$zet_path/$next_zet.md"
date=$(date +"%Y-%m-%d %T")
{
echo "---"
echo "title: ${title}"
echo "date: ${date}"
echo "tags: []"
echo "---"
echo ""
} > "$next_zet_path"
git add "$next_zet_path"
git commit -m "$title"
}
# Generate and publish a new version of the website.
function publish {
git push
clean
APP_ENV=production generate
rsync -avz output_prod/ ssh.oliverdavies.uk:/var/www/vhosts/zet.oliverdavies.uk
}

15
zet-old/source/.htaccess Normal file
View file

@ -0,0 +1,15 @@
Options +FollowSymLinks -MultiViews
RewriteEngine on
# Remove trailing slashes from directories.
DirectorySlash Off
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule (.*) $1/index.html [L]
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Remove index.html from URLs.
RewriteCond %{THE_REQUEST} \s/+(.*/)?index\.html[\s?] [NC]
RewriteRule ^(.*)index\.html$ /$1 [L,R=301]

View file

@ -0,0 +1,13 @@
{% if links is not empty %}
<h2>Links</h2>
<ul>
{% for link in links %}
{% if link.text and link.url %}
<li><a href="{{ link.url }}">{{ link.text }}</a></li>
{% else %}
<li><a href="{{ link }}">{{ link }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endif %}

View file

@ -0,0 +1,13 @@
{% if related and zets %}
<section>
<h2>Related</h2>
<ul>
{% for zet in zets if related|filter((title) => title == zet.title) %}
<li>
<a href="{{ zet.url|trim('/', 'right') }}">{{ zet.title }}</a>
</li>
{% endfor %}
</ul>
</section>
{% endif %}

View file

@ -0,0 +1,10 @@
{% if tags is not empty %}
<h2>Tags</h2>
<ul>
{% for tag in tags|sort %}
<li>{{ tag }}</li>
{% endfor %}
</ul>
{% endif %}

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="{{ site.locale|default('en') }}">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="{{ site.url }}{{ page.url|trim('/', 'right') }}">
<title>{{ page.title }} - {{ site.name }}</title>
</head>
<body>
{% block body %}
<h1>{% block page_title %}{{ page.title }}{% endblock %}</h1>
{% block content_wrapper %}
{% block content %}{% endblock %}
{% endblock %}
<hr>
<footer>
<p>This website is open source. <a href="{{ site.github.url }}/edit/main/source/{{ page.relative_pathname }}">Improve this page</a>.</p>
</footer>
{% endblock %}
</body>
</html>

View file

@ -0,0 +1 @@
{% extends "base" %}

View file

@ -0,0 +1,25 @@
{% extends "base" %}
{% block body %}
<nav>
<a href="/">Home</a>
</nav>
{{ parent() }}
{% endblock %}
{% block content_wrapper %}
<time datetime="{{ page.date|date('c') }}">{{ page.date|date }}</time>
{% block content %}{% endblock %}
{% include "zets/links" with { links: page.links } %}
{% include "zets/related" with {
zets: data.zets,
related: page.related,
} %}
{% include "zets/tags" with { tags: page.tags } %}
{% endblock %}

34
zet-old/source/_zets/1.md Normal file
View file

@ -0,0 +1,34 @@
---
title: Ellipsis in pager template fails accessibility tests
date: '2024-08-21 12:00:00'
tags:
- Drupal
- Accessibility
- ARIA
- Software Development
- Web Development
---
```html
<ul> and <ol> must only directly contain <li>, <script> or <template> elements
Ensures that lists are structured correctly
more informationLink opens in a new window
Element Location:
.pager__items
<ul class="pager__items js-pager__items">
To solve this problem, you need to fix the following:
List element has direct children that are not allowed: [role=presentation]
Related Node
<li class="pager__item pager__item--ellipsis" role="presentation"></li>
```
Proposed resolution:
Replace `role="presentation"` with `aria-label="additional pages"`.
## Links
* <https://www.drupal.org/project/drupal/issues/3348552> (issue, currently "needs work").
* <https://www.drupal.org/node/3399874> (draft change record).

View file

@ -0,0 +1,15 @@
---
title: git-instafix
date: 2024-08-22 12:28:26
tags: [Software Developmemt, Git]
---
[git instafix](https://github.com/quodlibetor/git-instafix) is a tool that allows you to easily amend (or fix) previous Git commits.
How it works:
- Commit your original changes.
- Make more changes and stage them with `git add -p`.
- Run `git-instafix` (or `git instafix`, but this doesn't tab complete for me).
- Select the commit you want to amend.
- `git-instafix` will amend it and move you back to the HEAD commit.

View file

@ -0,0 +1,13 @@
---
title: Software Development Graduate website
date: 2024-08-22 14:09:53
tags: [Sculpin, PHP, Transport for Wales]
---
Shelley, the TfW Software Development Graduate, recently published [her own website](https://shell-web-dev.netlify.app) as her personal project to showcase the work she's been doing.
It's built with Sculpin and Tailwind CSS and hosted on Netlify.
## Links
- <https://github.com/SeaShell92/shell-website>

View file

@ -0,0 +1,14 @@
---
title: The Gin admin theme
date: 2024-08-22 14:22:56
tags: [Drupal]
---
Gin is a contrib admin theme for Drupal, and it has a dark mode.
It also has a companion toolbar module.
## Links
- <https://www.drupal.org/project/gin>
- <https://www.drupal.org/project/gin_toolbar>

View file

@ -0,0 +1,8 @@
---
title: 'TODO: Try zellij as a potential tmux alternative'
date: 2024-08-23 16:52:06
tags: [Linux, Shell, Zellij, tmux, Command-Line]
---
- <https://zellij.dev>
- <https://mynixos.com/search?q=zellij>

View file

@ -0,0 +1,29 @@
---
title: "Abbreviations are better than aliases"
date: 2024-08-25 01:02:35
tags: [Shell, zsh, Linux]
---
Aliases are a way to shorten long or complicated commands or to easily add additional arguments when running commands.
Common aliases are `gs` for `git status`, `a` for `artisan` and `dr` for `drush`.
I've been experimenting with Zellij today and have written aliases like `zl` for `zellij list-sessions`, but have also added extra arguments such as `zellij list-sessions | sort | grep -v EXITED` to sort the sessions and filter any exited sessions.
Running these aliases means it's easier and quicker for me to run these commands.
The issue with aliases, I think, is that you can forget that the underlying commands are if you only type `gs` or `zl`.
It's also not easy when giving demos, pair programming for others to see and understand the commands that are being run.
Instead of aliases, I mostly use abbreviations that expand automatically after pressing the space key.
That way, I and others get to see and understand the commands being run.
Note: I originally saw this done by [Sebastian Daschner](https://blog.sebastian-daschner.com/entries/zsh-aliases) and I originally used his ZSH expansion code, but now use [zsh-abbr](https://zsh-abbr.olets.dev). There are settings for this in Nix/Home Manager.
## Links
- <https://github.com/olets/zsh-abbr>
- <https://mynixos.com/search?q=zsh-abbr>
- <https://github.com/opdavies/dotfiles.nix/blob/main/lib/shared/modules/zsh/abbreviations.zsh>

View file

@ -0,0 +1,32 @@
---
title: "Data attributes and feature flags"
date: 2024-08-26 21:34:15
tags: [Web Development, Software Development, Feature Flags, Drupal, CSS, PHP]
---
I recently used the [Feature Toggle module](https://www.drupal.org/project/feature_toggle) to set a data attribute which enabled some new styling for buttons.
## The PHP code
In the theme's .theme file:
```php
/**
* Implements hook_preprocess_html().
*/
function mytheme_preprocess_html(array &$variables): void {
$variables['attributes']['data-use-new-button-styles'] = \Drupal::service('feature_toggle.feature_status')->getStatus('use_the_new_button_styling');
}
```
If the feature toggle is enabled, this adds a `data-use-new-button-styles=""` attribute to the `body` element.
## The CSS code
```css
[data-use-new-button-styles] .btn-primary {
background-color: red;
}
```
I like using feature flags and was happy to find a way to use them for adding this new CSS.

View file

@ -0,0 +1,29 @@
---
title: "Sending POST requests with curl"
date: 2024-08-27 20:11:37
tags: [Linux, Command-Line, curl]
links:
- https://stackoverflow.com/questions/7172784/how-do-i-post-json-data-with-curl
- https://linuxize.com/post/curl-post-request
---
```shell
curl --header "Content-Type: application/json" \
--insecure \
--data '{"foo": "bar"}' \
https://example.docker.localhost/webhook
```
`--request POST` is implied if `--data` is passed.
`--insecure` skips SSL validation, e.g. if using a self-signed certificate.
Also, from `man curl`:
```shell
--json works as a shortcut for passing on these three options:
--data [arg]
--header "Content-Type: application/json"
--header "Accept: application/json"
```

View file

@ -0,0 +1,9 @@
---
title: "Format JSON file in vim"
date: 2024-08-27 20:21:17
tags: [Vim, Neovim, JSON, jq]
links:
- https://vi.stackexchange.com/a/19950
---
Use `:%!jq` to format/beautify a JSON file within vim using `jq`.

View file

@ -0,0 +1,27 @@
---
title: Using data attributes with Tailwind CSS
date: 2024-08-27 23:39:23
tags: [HTML, CSS, Tailwind CSS]
---
Adam Wathan mentioned this in his "Tailwind CSS: It looks awful, and it works" at Rails World 2023.
This is the link to the video: <https://www.youtube.com/watch?v=TNXM4bqGqek>.
The data attribute example starts at 21:00, which shows using arbitrary classes for data attributes.
## Examples
With the attribute on the same element:
```html
<button class="data-[loading]:text-transparent" data-loading>
```
With the attribute on a parent element (group):
```html
<button class="group data-[loading]:text-transparent" data-loading>
<span class="hidden group-data-[loading]:flex">...</span>
</button>
```

View file

@ -0,0 +1,9 @@
---
title: Merging activities in Strava
date: 2024-08-30 12:52:35
tags: [Running]
---
Activities with multiple entries can be exported from the Strave website as .gpx files and combined using websites like <https://gotoes.org/strava>.
Then, the combined file can be re-uploaded to Strava as a single activity.

View file

@ -0,0 +1,9 @@
---
title: sshs
date: 2024-08-21 18:17:29
tags: [Linux, SSH]
---
A terminal user interface for SSH, based on your `~/.ssh/config` file.
<https://github.com/quantumsheep/sshs>

View file

@ -0,0 +1,51 @@
---
title: Sorting parameter arguments and array keys in Vim
date: 2024-09-03 19:03:27
tags: [PHP, Vim, Software Development]
---
Given this PHP code (for example):
```php
$a = [
'b' => 2,
'a' => 4,
'k' => 5,
'f' => 1,
'd' => 3,
];
$b = new Foo(
b: 2,
a: 4,
k: 5,
f: 1,
d: 3,
);
```
You can use `vi(` and `vi[` to visually select the text within the array or parentheses, and then ":sort" to sort the text within the selected range.
Using `vi(` and `vi[` instead of `vi)` and `vi]` excludes the lines that around the text to sort.
After running these commands, you should get this:
```php
$a = [
'a' => 4,
'b' => 2,
'd' => 3,
'f' => 1,
'k' => 5,
];
$b = new Foo(
a: 4,
b: 2,
d: 3,
f: 1,
k: 5,
);
```
At some point, I'll look into saving this as a macro with a keymap like `<leader>sa` (sort arguments) and `<leader>sk` (sort keys).

View file

@ -0,0 +1,21 @@
---
title: Extracting a custom module with a Git subtree
date: 2024-09-04 20:12:00
tags: [Git]
---
To extract a directory from a repository and keep the history, you can use the `git subtree split` command to create a new branch:
```shell
git subtree split --prefix=web/modules/custom/my_module --branch=split
Created branch 'split'
17835f24069061326e9e065f076afd67434e1b2f
```
This will create a new branch with just the contents of the given directory.
This can be pushed to a different repository:
```shell
git push git@github.com:opdavies/new-repo.git split:main
```

View file

@ -0,0 +1,25 @@
---
title: Setting max_allowed_packet in MariaDB
date: 2024-09-10 08:51:49
tags: [MariaDB, MySQL, Databases]
links:
- https://github.com/MariaDB/mariadb-docker/issues/467
---
If you need to set `max_allowed_packet` for MariaDB, you can specify it in Docker Compose as a `command`.
For example:
```yaml
services:
mariadb:
image: mariadb:10.9.3
command: --max_allowed_packet=5GB
volumes:
- "./backend_db/mariadb.storage:/var/lib/mysql"
ports:
- "3306:3306"
env_file: ./backend_db/mariadb.env
```
No Dockerfiles or configuration files needed.

View file

@ -0,0 +1,33 @@
---
title: "Error: unsupported tarball input attribute 'lastModified'"
date: 2024-09-10 22:35:41
tags: [Linux, Nix, NixOS]
links:
- https://discourse.nixos.org/t/error-unsupported-tarball-input-attribute-lastmodified/49435/4
---
Yesterday, my laptop died and I needed to resurrect a spare laptop to work on.
This laptop was running an outdated version of NixOS, old packages, a different window manager and other things, so I tried to update it to bring it up to date so it's up to date with my dead laptop's configuration.
Doing so, though, gave me this error:
> Error: unsupported tarball input attribute lastModified
A normal `sudo nixos-rebuild switch` worked, but trying to use a Flake was generating the error.
I was able to get it working after running these commands from a Discourse thread:
```shell
nix shell "github:NixOS/nix/2.18.4"
nix build .#nixosConfigurations.nixedo.config.system.build.toplevel
sudo nix-env --profile /nix/var/nix/profiles/system --set ./result
./result/bin/switch-to-configuration switch
```
I also needed to add `--experimental-features 'nix-command flakes'` to the `nix` commands to get them to run.
Once this finished, I was able to reboot and get a running up-to-date configuration.

View file

@ -0,0 +1,16 @@
---
title: POSTing data from a JSON file
date: 2024-09-14 13:39:01
tags: [Linux, curl]
related:
- Sending POST requests with curl
use: [zets]
---
When sending JSON data in a POST request, instead of writing it inline with the `--data` or `--json` option, a filename can be entered - prefixed with an `@` symbol.
For example, to POST the data from a data.json file:
```shell
curl --insecure --json @data.json https://mysite.com/webhook
```

View file

@ -0,0 +1,40 @@
---
title: Drupal's Lenient Composer endpoint
date: 2024-09-14 17:29:15
tags: [Drupal, PHP, Composer]
links:
- https://www.drupal.org/project/content_access
- https://www.drupal.org/docs/develop/using-composer/using-drupals-lenient-composer-endpoint
- https://github.com/mglaman/composer-drupal-lenient
- https://github.com/cweagans/composer-patches
---
Today, I tried to add the Content Access module to a Drupal 11 project, but there's no Drupal 11-compatible version.
It's a simple update - just adding `^11` to the content_access.info.yml file, but even with Composer Patches installed, it's not possible to download and patch the module using the normal Drupal 8+ Composer repository.
This is possible, though, with the Lenient Composer endpoint.
> This composer plugin lets you specify an allowlist of packages where you are willing to break the version constraint.
> Together with the Composer Patches Plugin, this allows you to install any Drupal extension, even if the version constraint hasn't been officially updated yet. Of course the code may still need to be patched for deprecations.
To add the lenient endpoint and add the Content Access plugin:
```shell
composer require mglaman/composer-drupal-lenient
composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/content_access"]
composer req drupal/content_access
```
Note that I'd already included this section to my composer.json file to add a patch to make the module installable on Drupal 11:
```json
"extra": {
"composer-patches": {
"drupal/content_access": {
"Drupal 11 support": "./tools/patches/content_access/d11_support.patch"
}
},
},
```

View file

@ -0,0 +1,11 @@
---
title: Should I learn React?
date: 2024-09-25 19:33:28
tags: [React, JavaScript, Web Development]
---
I've usually used Vue.js or, more recently, Stimulus when I write JavaScript.
I'm familiar with JSX from using Astro for a previous version of my website and have experimented with Next.js, but haven't really learned React properly - but maybe I should.
School of Code - the bootcamp I mentor for - teach React and Drupal's new Experience Builder is written with React, so maybe now is the time.

View file

@ -0,0 +1,14 @@
---
title: "TODO: re-evaluate Storybook"
date: 2024-09-30 21:36:38
tags: [Front-End, Web Development]
links:
- https://fractal.build
- https://github.com/frctl/fractal/issues/1167
- https://storybook.js.org
- https://www.drupal.org/project/storybook
---
I've used Fractal a lot for the past several years to build design systems and component libraries for projects, but as the last commit was in January 2023 and there was an issue saying the maintainers were stepping back and the project is unmaintained, it may be time to look at something else.
Storybook seems to be the popular choice and it has an integration module with Drupal.

View file

@ -0,0 +1,15 @@
---
title: Excluding local files from Git
date: 2024-11-07 10:10:19
tags: [git]
---
As well as using a shared `.gitignore` file in a directory, I've had a convention of putting my own files I want to ignore in an `.ignored` directory and having that in a [global excludes file](https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreexcludesFile).
This works for most situations, but sometimes files need to be in their expected location and not in a sub-directory.
I also have scripts that check for a file in both places before performing an action.
Git, though, has a built-in way to do this.
Any files added to `.git/info/exclude` will automatically be excluded by Git and because this is in my `.git` directory, it won't affect anyone else's version.

View file

@ -0,0 +1,17 @@
---
title: Drupal Recipe Unpacking
date: 2025-07-12 22:57:36
tags:
- drupal
links:
- text: New Recipe Unpack composer plugin
url: https://www.drupal.org/node/3522189
- text: This Blog Is No Longer on Drupal CMS, and That's a Good Thing
url: https://joshuami.com/blog/2025/recipe-unpack-blog-no-longer-drupal-cms-and-thats-good-thing
---
Drupal now supports recipe unpacking.
> The Recipe Unpacking system is a Composer plugin that manages "drupal-recipe" packages. Recipes are special Composer packages designed to bootstrap Drupal projects with necessary dependencies. When a recipe is required, this plugin "unpacks" it by moving the recipe's dependencies directly into your project's root composer.json, and removes the recipe as a project dependency.
This is added automatically for new projects, but can also be added to existing projects using `composer require drupal/core-recipe-unpack` and the `drupal:recipe-unpack` command.

48
zet-old/source/_zets/3.md Normal file
View file

@ -0,0 +1,48 @@
---
title: Writing bash scripts with Nix
date: 2024-08-21 18:30:24
tags: [Bash, Linux, Nix]
---
- Variables, such as username, can be injected.
- `shellcheck` is run automatically with `pkgs.writeShellApplication`.
- Packages defined in `runtimeInputs` will be automatically injected.
<https://github.com/opdavies/dotfiles.nix/blob/a1c356a1f576f041301a5c41d6ba7d0f098d0edb/lib/shared/scripts/export-video-list.nix>
```nix
{ pkgs, username, ... }:
{
name = "export-video-list";
runtimeInputs = with pkgs; [
jq
tree
udisks
];
text = ''
device_name="/dev/sda2"
device_label="UNTITLED"
source_path="/run/media/${username}/$device_label"
# If the source path doesn't exist, try mounting the device.
if [[ ! -d "$source_path" ]]; then
${pkgs.udisks}/bin/udisksctl mount -b "$device_name"
fi
# Exit early if the source path still doesn't exist.
if [[ ! -d "$source_path" ]]; then
echo "Error: $source_path not found."
exit 1
fi
output_file="$HOME/Documents/videos.json"
${pkgs.tree}/bin/tree -J "$source_path/Videos" | ${pkgs.jq}/bin/jq . > "$output_file"
${pkgs.jq}/bin/jq . < "$output_file"
'';
}
```

View file

@ -0,0 +1,17 @@
---
title: Counting tags
date: 2025-07-12 23:06:44
tags:
- git
links:
- text: My get-tags scrpt
url: https://code.oliverdavies.uk/opdavies/nix-config/src/commit/a620888277654fa413d14413d0d2a4ce82d1ad56/packages/get-tags.nix
- text: My count-tags script
url: https://code.oliverdavies.uk/opdavies/nix-config/src/commit/a620888277654fa413d14413d0d2a4ce82d1ad56/packages/count-tags.nix
---
To see all the tags in a repository, run `git tag`.
To see a filtered list of tags, such as tags that start with a specific year, run `git log | grep 2025`.
To count these, run `git log | grep 2025 | wc -l`.

View file

@ -0,0 +1,16 @@
---
title: Using Vim filters
date: 2025-07-12 23:13:54
tags:
- vim
---
In Vim, insert some text into a file, such as `date`.
In insert mode, press `!!` to switch to command mode and see a `:.!` prompt.
Enter a command, like `bash` to execute on the given text.
The text is replaced with the result from the command - `Sat Jul 12 23:16:29 BST 2025`.
This also works for other commands, such as typing `1+2+3` and running `:.!bc` will return 6.

View file

@ -0,0 +1,60 @@
---
title: Drupal Bundle classes
date: 2025-07-12 23:25:52
tags:
- drupal
- php
---
By overridding a given bundle type:
```php
<?php
// modules/opd_presentations/opd_presentations.module
function opd_presentations_entity_bundle_info_alter(array &$bundles): void {
if (isset($bundles['node'])) {
$bundles['node'][Presentation::NODE_TYPE]['class'] = Presentation::class;
}
if (isset($bundles['paragraph'])) {
$bundles['paragraph'][Event::PARAGRAPH_TYPE]['class'] = Event::class;
}
}
```
I can write my own bundle classes that extend `Node`, `Paragraph`, etc, with its own custom methods and behaviour.
```php
<?php
// modules/opd_presentations/src/Presentation.php
declare(strict_types=1);
namespace Drupal\opd_presentations;
use Drupal\paragraphs\Entity\Paragraph;
use Drupal\paragraphs\ParagraphInterface;
final class Event extends Paragraph implements ParagraphInterface {
public const PARAGRAPH_TYPE = 'event';
public function getEventDate(): string {
/** @var non-empty-string */
return $this->get('field_date')->value;
}
public function getEventName(): string {
/** @var non-empty-string */
return $this->get('field_event_name')->value;
}
public function isPast(): bool {
return $this->getEventDate() < strtotime('today');
}
}
```

14
zet-old/source/_zets/4.md Normal file
View file

@ -0,0 +1,14 @@
---
title: Drush now uses Laravel Prompts
date: 2024-08-21 18:43:15
tags: [Drupal, Drush, Laravel, PHP]
---
By Jess:
> Very cool to see Drush (Drupal's goto CLI tool) using Laravel Prompts! It was always a goal to make it work in any PHP application, not just Laravel.
- <https://x.com/jessarchercodes/status/1826033275196027268>
- <https://github.com/drush-ops/drush/pull/5823>
- <https://github.com/drush-ops/drush/commit/f2e39540cbd7cd39d6e7417bc91885a4d8e4fd39>
- <https://github.com/drush-ops/drush/commit/72da139dcbd74b623fb6b41adc92e292b07c9334>

17
zet-old/source/_zets/5.md Normal file
View file

@ -0,0 +1,17 @@
---
title: Using code snippets for effective live demos
date: 2024-08-21 18:53:51
tags: [Vim, Neovim, Public Speaking, Laravel, PHP, Jenkins]
---
[This tweet](https://x.com/DCoulbourne/status/1820068237226262810) mentions using code snippets whilst doing live demos to make them easier and less risky:
> Writing hella VSCode snippets for my @LaraconUS talk.
>
> I saw @joetannenbaum live coding with safety and ease in India and knew I'd need some of that swag for US.
Joe's talk was recorded but won't be published until after LaraconUS, but I also remembered [this talk by Micheal Heap at PHP UK 2018](https://www.youtube.com/watch?v=kuBD3p20oyE), where he used Vim snippets and shell aliases to show how to go from nothing to a deployed Laravel application using Jenkins.
I'd like to use this approach more when doing my live coding demos, such as in my Sculpin talk.
TODO: update this note with a link to Joe's talk once it's published.

16
zet-old/source/_zets/6.md Normal file
View file

@ -0,0 +1,16 @@
---
title: Unveiling Laravel Prompts
date: 2024-08-22 08:09:22
tags: [PHP, Laravel, Drush]
---
Now [Drush is using Laravel Prompts](../4), I should re-watch this video from Laracon US last year where Prompts was unveiled by Jess Archer:
<https://www.youtube.com/watch?v=PW-2_-KxF-8>
I think it's great that Prompts was intended to be used in any PHP project, not just Laravel, and this is a great example of the Drupal ecosystem "getting off the island".
## Links
- [Laravel Prompts documentation](https://laravel.com/docs/11.x/prompts)
- [Laravel Prompts GitHub repository](https://github.com/laravel/prompts)

23
zet-old/source/_zets/7.md Normal file
View file

@ -0,0 +1,23 @@
---
title: Scaling personal projects
date: 2024-08-22 09:00:00
tags: [PHPSW, Public Speaking, Software Development]
---
Here are some quick notes from Ferdie De Oliveria's talk, "Scaling Personal Projects", at [PHP South West last week](https://www.meetup.com/php-sw/events/302521220):
- Create the project and change the name later. Don't let the project name be a blocker.
- Identify key features and functionality. Use a tool like a Trello board to capture and manage tasks.
- Ponder on the challenges.
- Have a growth mindset.
- Divide tasks into heavy work, medium work and quick wins.
- Fail fast, fail early.
- Refactor.
- Iterate.
- If people don't like it, make it better.
- Consistency is key.
- Practice and perseverance.
<https://acumenlogs.com>
TODO: add links to the slides and video of the talk once they are released.

13
zet-old/source/_zets/8.md Normal file
View file

@ -0,0 +1,13 @@
---
title: One of my earliest Tailwind CSS projects
date: 2024-08-22 09:01:00
tags: [CSS, Tailwind CSS, PHPSW]
---
[The PHPSW website](https://phpsw.uk) is one of the earliest Tailwind CSS projects I did, at least that I can remember.
Tailwind CSS [was added to the project](https://github.com/phpsw/phpsw-ng/commit/879c23153b1f80b9b037cf6299a9bc17a63b66bd) on the 13th of November, 2017 (almost 7 years ago), and the yarn.lock file shows the version as 0.1.6.
0.1.0 was only released [on the 1st of November](https://github.com/tailwindlabs/tailwindcss/releases/tag/v0.1.0), and 1.0.0 wouldn't be released [until May 2019](https://github.com/tailwindlabs/tailwindcss/releases/tag/v1.0.0).
[Here's a photo](https://x.com/opdavies/status/968224364129906688) from an evening when Dave, Kat and I were working on it at the Lamp Bristol office.

15
zet-old/source/_zets/9.md Normal file
View file

@ -0,0 +1,15 @@
---
title: Git remotes can have more than one URL
date: 2024-08-22 09:43:42
tags: [Software Development, Git]
---
If you want to have multiple URLs for a single remote so `git push origin ...` will push to multiple remotes, such as GitHub and GitLab, or a personal repository and a client repository, you can do `git remote set-url --add origin <url>`.
Then `git remote -v` should show something like this:
```plain
origin git@github.com:opdavies/zet.oliverdavies.uk (fetch)
origin git@github.com:opdavies/zet.oliverdavies.uk (push)
origin git@gitlab.com:opdavies/zet.oliverdavies.uk.git (push)
```

View file

@ -0,0 +1,16 @@
---
layout: page
title: Zettelkasten for Oliver Davies (opdavies)
permalink: /
use: [zets]
---
<ul>
{% for zet in data.zets %}
<li>
<a href="{{ zet.url|trim('/', 'right') }}">
{{- zet.date|date }}: {{ zet.title -}}
</a>
</li>
{% endfor %}
</ul>

View file

@ -0,0 +1,16 @@
---
permalink: /notes.json
use: [zets]
---
[
{% for note in data.zets|sort((a,b) => b.date <=> a.date) %}
{
"id": {{ note.filename|replace({".md": ""}) }},
"date": {{ note.date }},
"title": "{{ note.title }}",
"url": "{{ site.url }}/{{ note.url|trim("/") }}"
}
{%~ if not loop.last %},{% endif %}
{% endfor %}
]

1
zet-old/todo Normal file
View file

@ -0,0 +1 @@
Add some basic styling.