Compare commits

...

11 Commits

Author SHA1 Message Date
d1a1146260 allow ascii dependency map 2025-08-18 01:37:40 +02:00
3dface826f playing with ansible 2025-08-16 02:54:41 +02:00
a55712032b make all file names lowercase 2025-08-14 06:35:44 +02:00
33a959fcea note makefile warning 2025-08-13 22:09:48 +02:00
4ed4c87acf improve group logins 2025-08-13 22:09:12 +02:00
68f9eb2a7d note ijq for json 2025-08-06 05:28:58 +02:00
c407e8be9e note git requirement for lfs 2025-07-29 16:38:28 +02:00
f52b241dc2 write make a gif 2025-07-29 16:38:18 +02:00
c0755da29f fix ffmpeg headers 2025-07-29 16:31:02 +02:00
c3afb4b562 add git stash 2025-07-24 07:23:42 +02:00
f5b3d969fd grok vi 2025-07-14 12:42:45 +02:00
24 changed files with 298 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ FZF != command -v sk || command -v fzy || command -v fzf || \
spill_contents = sed -e '1,/---/d'
help: ## Print the help message
help: .git/info/exclude ## Print the help message
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z._-]+:.*?## / {printf "\033[36m%s\033[0m : %s\n", $$1, $$2}' $(MAKEFILE_LIST) | \
sort | \
column -s ':' -t
@@ -19,6 +19,8 @@ categories = $(patsubst %/, %, $(dirs))
databases = $(patsubst %, .dbs/%.rec, $(categories))
default += $(databases)
default += db.rec
default += .dbs/map.fmt
$(foreach dir, $(categories), \
$(eval .dbs/$(dir).rec: $(wildcard $(dir)/*)) \
@@ -26,6 +28,7 @@ $(foreach dir, $(categories), \
.dbs/:
mkdir $@
$(databases): .dbs/%.rec: %/ | .dbs/
$(info making $(@F))
for entry in $(shell find $< -type f -name "*.md") ; do \
@@ -38,6 +41,7 @@ $(databases): .dbs/%.rec: %/ | .dbs/
# This two-variable read can only happen because of the quotes in the titles.
db.rec: $(databases)
$(warning rebuilding from $? )
printf '%s\n' '%rec: guide' > $@
printf '%s\n' '%key: title' >> $@
printf '%s\n' '%type: requires rec guide' >> $@
@@ -55,10 +59,8 @@ db.rec: $(databases)
recfix --sort $@
$(info Created main database: $@)
default += db.rec
.git/info/exclude: $(default)
echo $^ | tr ' ' '\n' > $@
@echo $^ | tr ' ' '\n' > $@
default += .git/info/exclude
@@ -76,6 +78,18 @@ article: ## Write an article
printf '%s\n\n' '---' >> $$path/$$filename.md ;\
$(EDITOR) +5 "$$path/$$filename.md"
.dbs/map.fmt:| .dbs/
printf '%s\n' '[ {{requires[0]}} ] --> [ {{title}} ] {border-style: dashed;}' > $@
printf '%s\n' '[ {{requires[1]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[2]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[3]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
printf '%s\n' '[ {{requires[4]}} ] --> [ {{title}} ] {border-style: dashed;}' >> $@
.PHONY: map
map: db.rec .dbs/map.fmt ## Show knowledge dependency map
recsel -t guide $< -e 'requires != ""' -p title,requires | recfmt -f .dbs/map.fmt |\
grep -vF '[ ]' | graph-easy --boxart | $${PAGER}
.PHONY: clean
clean: ## Remove all generated files
$(RM) $(default)

View File

@@ -1,6 +1,7 @@
---
title: "git-lfs"
tags: [ "data", "git" ]
requires: [ "git" ]
---
Git Large File Storage ('LFS') needs to change your `~/.gitconfig` to check out those binary files:

69
data/git/git_stash.md Normal file
View File

@@ -0,0 +1,69 @@
---
title: "git stash"
tags: [ "data", "git" ]
requires: [ "git" ]
---
Save file-changes without committing anything.
Change a file:
```sh
file=README.md
fortune >> ${file}
git diff
git stash save
```
List which stashes you have:
```sh
git stash list
stash@{1}: WIP on master: c21f102 init git
```
Make a new file, then stash it:
```sh
otherfile=file.log
fortune > ${otherfile}
git add ${otherfile}
stashname=logfile
git stash save ${stashname}
```
Now you can see two stashed changes, and the most recent has a name:
```sh
git stash list
stash@{0}: On master: logfile
stash@{1}: WIP on master: c21f102 init git
```
You can delete a stash by referring to its index number, or name (if it has one).
```sh
choice=1
git stash drop ${choice}
choice=${stashname}
git stash drop ${choice}
```
Or just run `git stash drop` to remove the most recent (labelled `{0}`).
Return stashed changes with an index number (or the most recent).
```sh
git stash pop ${choice}
```
Delete all stashes:
```sh
git stash clear
```

13
data/json.md Normal file
View File

@@ -0,0 +1,13 @@
---
title: "ijq"
tags: [ "data", "json", "TUI" ]
---
Analyse `json` easier with `ijq`.
```sh
column -J -ts: -H PW,GID,shell -N User,PW,UID,GID,Description,Home,shell /etc/passwd > host.json
ijq !$
```
If you get stuck, try adding `.[]`.

View File

@@ -0,0 +1,114 @@
---
title: "Ansible with Docker"
tags: [ "system", "ansible", "docker" ]
requires: [ "Docker" ]
---
Set up two containers: `deb` and `arch`, add them to an `ansible` hosts file, then do a 'ping' to see if they respond.
## Required Packages
- `ansible`
- `jq`
- `docker`
## Debian Container
```sh
docker run -di --rm --name deb --hostname deb debian
docker exec -it deb sh -c 'apt update && apt -y install openssh-server python3 sudo'
```
Generate the host's ssh keys, then start the ssh daemon:
```sh
docker exec -it deb sh -c 'ssh-keygen -A'
docker exec -d deb /usr/sbin/sshd -D
```
## Arch Linux Container
```sh
docker run -di --rm --name arch --hostname arch archlinux
docker exec -it arch sh -c 'pacman -Syu --noconfirm python sudo openssh'
docker exec -it arch sh -c 'ssh-keygen -A'
docker exec -d arch /usr/sbin/sshd -D
```
## `ssh` Keys
Copy across your public ssh key to the container's `authorized_keys` file:
```sh
pubkey=~/.ssh/id_rsa.pub
for hostname in arch deb; do
docker cp $pubkey $hostname:/root/.ssh/authorized_keys
docker exec -it $hostname sh -c "chown -R root:root /root/.ssh/"
docker exec -it $hostname sh -c "chmod -R 700 /root/.ssh/"
done
```
## Hosts File
Find name of containers' IPv4 addresses.
```sh
docker network inspect bridge
```
The output is awful.
Use `jq` to parse the `json`:
```sh
docker network inspect bridge | jq -r '.[].Containers | .[].IPv4Address'
```
Now put those into a host file:
```sh
docker_hosts=hosts.txt
echo '[containers]' > $docker_hosts
docker network inspect bridge | \
jq -r '.[].Containers | .[] | "root@" + .IPv4Address' | \
cut -d/ -f1 >> $docker_hosts
```
You may need to add those host keys to your known hosts file.
Either connect interactively, or (for scripts):
```sh
hosts="$(docker network inspect bridge | jq -r '.[].Containers | .[] | .Name + " " + .IPv4Address' | \
cut -d/ -f1)"
echo "$hosts"
echo "$hosts" | while read hostname ip; do
printf "%s" "$ip"
key="$(docker exec $hostname cat /etc/ssh/ssh_host_ed25519_key.pub)"
echo "$ip $key" >> ~/.ssh/known_hosts
done
```
Check if they ping:
```sh
ansible -i $docker_hosts all -m ping
```
This command produces an irritating warning about the python interpreter (i.e., `python3`).
Make the warning shut-up:
```sh
echo '
[containers:vars]
ansible_python_interpreter=/usr/bin/python3.13' >> $docker_hosts
```
Now the ping is cleaner:
```sh
ansible -i $docker_hosts all -m ping
```

View File

@@ -17,10 +17,10 @@ Remove yourself from all groups, and add yourself back to only `wheel`, `audio`,
sudo usermod --groups wheel,audio,$USER
```
Add yourself to the `wheel` group:
Add yourself to the `docker` group:
```sh
su root -c "usermod --append --groups wheel $USER"
su root -c "usermod --append --groups docker $USER"
```
Add yourself to the `network` group:
@@ -28,5 +28,11 @@ Add yourself to the `network` group:
sudo usermod -aG network $USER
```
The changes will not take effect until you log in again, so reboot or log into `localhost` with [ssh](../networking/ssh.md).
The changes have not taken effect, so log into your own account again with `su`:
```sh
groups
sudo su $USER
groups
```

View File

@@ -1,6 +1,7 @@
---
title: "Docker"
tags: [ "documentation", "virtualization" ]
requires: [ "Managing Groups" ]
---
```sh
sudo pacman -S docker

View File

@@ -10,7 +10,7 @@ ffmpeg -i [input file] output_file.mkv
The input file might be a device, such as a camera.
#Record screen
# Record screen
Take the format as 'grab the x11 screen'.
@@ -30,7 +30,8 @@ or maybe just...
ffmpeg -f x11grab -s "$(xdpyinfo | grep dimensions | awk '{print $2}')" -i :1.0 out.mkv
```
#Add default pulse audio
# Add default pulse audio
```bash
ffmpeg -f x11grab -s [screensize] -i :0.0 -f alsa -i default out.mkv
```

22
vision/make_a_gif.md Normal file
View File

@@ -0,0 +1,22 @@
---
title: "Make a gif"
tags: [ "vision" ]
---
Split your video into frames.
```sh
d=$(mktemp -d)
cp $vid.mp4 $d
cd $d
ffmpeg -i $vid.mp4 -vf "fps=10, scale=360:-1" frame%04d.png
gifski --fps 10 -o ${out}.gif frame*.png
```
Optimize:
```sh
gifsicle --optimize=3 --lossy=100 -o ${final}.gif ${out}.gif
```

View File

@@ -3,13 +3,14 @@ title: "vim basics"
tags: [ "vim", "basic" ]
---
1. Insert text by pressing `i`.
1. Insert text by pressing `a`.
1. Stop inserting text by pressing `Ctrl+[`.
1. Exit with `ZZ`.
1. Congratulations, you now know `vim`.
## Extras
- [Learning Vim](vim/vi.md)
- [Navigation](vim/navigate.md)
- [Completion](vim/completion.md)
- [Search](vim/search.md)

46
writing/vim/vi.md Normal file
View File

@@ -0,0 +1,46 @@
---
title: "How to Learn `vim`"
tags: [ "vim", "learning" ]
requires: [ "vim basics" ]
---
1. Uninstall `vim`.
1. Install `vi`.
1. Write a few blog posts.
The [ancient wisdom](https://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118) is correct - everyone should start with `vi`.
But the standard wisdom fails to mention writing.
So people just 'try to remember', then they edit a couple of configuration files with `vim`, then stop, because it's a pain to think about keystrokes while thinking about how the configuration file works.
Nobody can learn like that.
Learn with a blog, or writing emails in `vim`, or writing anything, as long as it's *real writing*.
Write a journal or some recipes.
Write literally anything which is written in paragraphs.
And while you're writing, remember one rule: if you want something, `vi` can do it, you just need to look up how.
Blog first, then try out some of these commands:
- `hjkl`
- `x`
- `:!grep very %`
- `onew line<Esc>...`
- `Onew line<Esc>...`
- `~`
- `~~~~`
- `$r!`
- `w %-2`
- `x!`
- `0RTipex`
- `_4rX`
- `bc2e`
- `c2E`
- `cw`
- `cW`
- `ci'`
- `zz`
- `:set number`
- `:set nonumber`
- `:set relativenumber`
- `:set number relativenumber`