Compare commits

...

26 Commits

Author SHA1 Message Date
a2aff0171e
Add retroactive signing to git.md 2021-09-01 13:24:00 +01:00
6872e0e4e0
Create pulseaudio notes 2021-09-01 13:23:59 +01:00
5359811cb5
Add GNOME notes 2021-09-01 13:23:56 +01:00
424603343c
Update gohookr script to clean before site generation 2021-09-01 13:23:55 +01:00
29cf143caa
Delete threat_modelling.md 2021-09-01 13:23:54 +01:00
84e1d2a381
Minor change 2021-09-01 13:23:54 +01:00
0debd6477d
update vimrc 2021-09-01 13:23:53 +01:00
17319d9ac1
Add basic vimrc 2021-09-01 13:23:52 +01:00
512282e379
add python notes 2021-09-01 13:23:51 +01:00
e846cf0e6c
Add tags 2021-09-01 13:23:49 +01:00
7f68d6d364
fix typo 2021-09-01 13:23:48 +01:00
ca0be58e2c
alra.uk -> alv.cx 2021-09-01 13:23:48 +01:00
b91591a402
Capitalisation 2021-09-01 13:23:47 +01:00
ee1b119cdf
Minor edit 2021-09-01 13:23:46 +01:00
037a352095
Create notes on docker + nginx + let's encrypt 2021-09-01 13:23:45 +01:00
205312ef3c
Add alternative to add replace directive to go.mod 2021-09-01 13:23:45 +01:00
cb82c51f8c
golang: go mod edit directive 2021-09-01 13:23:44 +01:00
94a03df352
go: godoc 2021-09-01 13:23:43 +01:00
54f937ad96
Create bash notes 2021-09-01 13:23:43 +01:00
5959b16b78
Update gohookr.sh 2021-09-01 13:23:42 +01:00
688762a9c5
Add gohookr script 2021-09-01 13:23:41 +01:00
4d9cde4339
create notes on thread modelling 2021-09-01 13:23:41 +01:00
49ebcae5ea
add notes on go 2021-09-01 13:23:40 +01:00
09ce26cbde
create notes file on git 2021-09-01 13:23:39 +01:00
aded939a5d
update postgres backup process 2021-09-01 13:23:38 +01:00
5d412184a8
libvirt.md: `no polkit agent available to authenticate action \'org.libvirt.unix.manage\' 2021-09-01 13:23:36 +01:00
12 changed files with 389 additions and 31 deletions

12
bash.md Executable file
View File

@ -0,0 +1,12 @@
---
author: Alvie Rahman
date: \today
title: Bash
tags: [ linux, shell, programming ]
---
# `set` builtin[^gnuset]
- `-e`--- exit a program if any program returns a non-zero error code (fails)
[^gnuset]: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#The-Set-Builtin

39
basic.vimrc Normal file
View File

@ -0,0 +1,39 @@
" my basic minimal vimrc for easy installation:
" curl https://notes.alv.cx/notes/basic.vimrc > ~/.vimrc
set number
set relativenumber
set lazyredraw
set undofile
set undodir=~/.undodir
set ignorecase
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
noremap H ^
noremap L $
noremap ^ H
noremap $ L
hi Normal ctermbg=None
highlight VertSplit cterm=None ctermfg=8 ctermbg=None
highlight StatusLine cterm=underline ctermfg=8 ctermbg=None
highlight StatusLineNC cterm=underline ctermfg=8 ctermbg=None
highlight LineNr ctermfg=8 ctermbg=None
highlight LineNrAbove ctermfg=8 ctermbg=None
highlight LineNrBelow ctermfg=8 ctermbg=None
highlight CursorLineNr ctermfg=8 ctermbg=None
highlight FoldColumn ctermfg=8 ctermbg=None
highlight SignColumn ctermfg=8 ctermbg=None
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au VimEnter,WinEnter,BufWinEnter * setlocal cursorcolumn
au WinLeave,BufLeave,BufWinLeave * setlocal nocursorline
au WinLeave,BufLeave,BufWinLeave * setlocal nocursorcolumn
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType yml setlocal ts=2 sts=2 sw=2 expandtab

110
docker_nginx_lets_encrypt.md Executable file
View File

@ -0,0 +1,110 @@
---
author: Alvie Rahman
date: \today
title: Setting Up Nginx and Let's Encrypt in Docker
tags: [ linux, docker, programming ]
---
# Setting Up Nginx and Let's Encrypt in Docker
This turned out to be way harder than I thought it would be.
I tried to follow
[this](https://pentacent.medium.com/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71)
post here but the `init-letsencrypt.sh` script didn't work for me.
Most of the content here is from that post.
## Create the necessary files
### `docker-compose.yaml`
Notice how `certbot`'s `entrypoint` field is commented out?
Yeah, that's one of the things that tripped me up.
When the autorenew entrypoint is specified, you can't perform one of the future steps.
```
version: '3'
services:
nginx:
image: nginx:1.15-alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./data/nginx:/etc/nginx/conf.d
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
certbot:
image: certbot/certbot
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
volumes:
- ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot
```
### `data/nginx/app.conf`
Again, things are commented out in this file.
The SSL section is commented out as Nginx cannot start an SSL server without first having SSL
certificates but certbot won't give us SSL certificates unless we have a webserver (the certbot
Docker image supports hosting a standalone server for this purpose but that would mean changing
around the ports in `docker-compose.yaml`).
Also the 301 redirect in the port 80 section is commented out as we don't want to immediately
redirect certbot to a https URL we aren't listening for.
```
server {
listen 80;
server_name DOMAIN.NAME;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
#return 301 https://$host$request_uri;
proxy_pass http://example.com;
}
}
# server {
# listen 443 ssl;
# server_name DOMAIN.NAME;
#
# location / {
# # anything you want can go in here, of course
# proxy_pass http://example.com;
# }
# ssl_certificate /etc/letsencrypt/live/DOMAIN.NAME/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/DOMAIN.NAME/privkey.pem;
# include /etc/letsencrypt/options-ssl-nginx.conf;
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# }
```
## Set your domain
Run the following command, replacing `REPLACEME` with your domain name:
```
sed -i 's/DOMAIN.NAME/REPLACEME/g' data/nginx/app.conf
```
## Get your first certificates
Run the following commands:
docker-compose up -d nginx
docker-compose run certbot certonly --webroot /var/www/certbot
Enter the information your are prompted for.
## Enable HTTPS on Nginx and auto renew certificates
1. Uncomment the commented out server block in `data/nginx/app.conf`.
2. Remove the `proxy_pass` line in the port 80 server block.
3. Uncomment the line starting with `return 301`
4. Restart Nginx (`docker-compose restart nginx`)
5. Uncomment line beginning with `entrypoint` in `docker-compose.yaml`

42
git.md Executable file
View File

@ -0,0 +1,42 @@
---
author: Alvie Rahman
date: \today
title: Git
tags: [ linux, programming, git ]
---
# Fix detached head
From <https://stackoverflow.com/a/10229202>:
## To Delete Changes
```
git checkout main
```
## To Keep Changes
```
git branch temp
git checkout main
git pull . temp
git branch -D temp
```
# Retroactively Sign Commits
From <https://webdevstudios.com/2020/05/26/retroactively-sign-git-commits/>:
1.
```
git rebase -i HEAD~<number of commits to sign>
```
2. Replace `pick` with `reword`:
In vim: `:%s/^pick/reword/:wq`
3. Save all commit messages
4. Force push to remote

26
gnome.md Executable file
View File

@ -0,0 +1,26 @@
---
author: Alvie Rahman
date: \today
title: GNOME is a Whole Mess
tags: [ gnome, linux, troubleshooting ]
---
Gnome is, like, a whole mess. These are the weird issues I had to solve.
# Super+1, Super+2, Super+3, etc. keys can not be remapped in Gnome (gnome super+1 shortcut not working)
From <https://unix.stackexchange.com/a/510376>:
> It turns out that some keyboard shortcuts in Gnome do not show up in Settings → Devices →
> Keyboard → Keyboard Shortcuts. These "hidden" shortcuts are accessible by using the dconf-editor
> command. In the dconf editor, the Super+1 remapping was found at
>
> org/gnome/shell/keybindings/switch-to-application-1
# Setting Default Terminal
Not possible??
# No Bluetooth Dongle not Recocgnised
Had to update BIOS.

59
go.md Executable file
View File

@ -0,0 +1,59 @@
---
author: Alvie Rahman
date: \today
title: Go (golang)
tags: [ golang, programming ]
---
# Getting Up to Speed With Go
Probably the most useful resoure I found was the [Tour of Go](https://tour.golang.org/).
It's easy to understand and teaches you all you need to know.
# Making a web api
> We need to memorize the `Handler` interface.
>
> type Handler interface {
> ServerHTTP(ResponseWriter, *Request)
> }
# `godoc` [^golang-godoc]
> Godoc parses Go source code - including comments - and produces documentation as HTML or plain
> text.
> The end result is documentation tightly coupled with the code it documents.
> For example, through godoc's web interface [which is at <http://localhost:6060> by default] you can
> navigate from a function's documentation to its implementation with one click.
## Installing godoc // `command not found: godoc`
```bash
go get golang.org/x/tools/cmd/godoc
```
# `go.mod`
## `replace` [^go-mod-edit]
```
go mod edit -replace old.repo/location=../new/location
```
or
```
echo "old.repo/location => ../new/location" >> go.mod
```
> The `-replace=old[@v]=new[@v]` flag adds a replacement of the given
> module path and version pair. If the @v in old@v is omitted, a
> replacement without a version on the left side is added, which applies
> to all versions of the old module path. If the @v in new@v is omitted,
> the new path should be a local module root directory, not a module
> path. Note that -replace overrides any redundant replacements for old[@v],
> so omitting @v will drop existing replacements for specific versions
[^golang-godoc]: Andrew Gerrand, 31 March 2011 --- <https://blog.golang.org/godoc>
[^go-mod-edit]: <https://golang.org/ref/mod#go-mod-edit>

9
gohookr.sh Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# this is a script that is used by gohookr (git.alv.cx/alvierahman90/gohookr) to automatically
# update notes.alv.cx when i push a change
set -e
cd `dirname $0`
git pull
cd ..
rm -rf notes.alv.cx/*
notes2web.py -o notes.alv.cx notes

View File

@ -1,7 +1,8 @@
---
author: Alvie Rahman
date: \today
title: libvirt notes
title: libvirt
tags: [ linux, virtualisation ]
---
# issues
@ -11,3 +12,11 @@ title: libvirt notes
```bash
# virsh net-start default
```
## `no polkit agent available to authenticate action 'org.libvirt.unix.manage'`
add user to `libvirt` group
```bash
usermod -a -G libvirt user
```

View File

@ -1,7 +1,8 @@
---
author: Alvie Rahman
date: \today
title: linux notes
title: Linux
tags: [ linux ]
---
# user stuff

View File

@ -1,7 +1,8 @@
---
author: Alvie Rahman
date: \today
title: postgres notes
title: Postgres
tags: [ programming ]
---
\tableofcontents
@ -71,7 +72,7 @@ changed since the first backup.
- to enable WAL archiving:
1. set `wal_level` to `archive` (or `hot_standby`)
1. set `wal_level` to `replica` or higher
1. set `archive_mode` to `on`
1. set `archive_command` to the command to use to backup
@ -101,34 +102,11 @@ changed since the first backup.
1. make a base backup
### make a base backup
### make a base backup[^pg_basebackup]
1. ensure WAL archiving is enabled and working
2. issue the following command as superuser:
1. ensure that WAL archiving is working and set up properly.
1. Run `pg_basebackup -D - -F tar > backup.tar`
```
SELECT pg_start_backup('label');
```
- `label` is any string to uniquely identify backup operation, e.g. the full path where you
intend to put the backup dump file
- It does not matter which database within the cluster you connect to to issue this command
3. Perform the backup, using any convenient file-system-backup tool such as tar or cpio
(not pg_dump or pg_dumpall). It is neither necessary nor desirable to stop normal operation of
the database while you do this.
4. issue the following command as superuser:
```
SELECT pg_stop_backup();
```
this terminates the backup mode and performs an automatic switch to the next WAL segment
> You can also use the pg_basebackup tool to take the backup, instead of manually copying the files.
This tool will do the equivalent of pg_start_backup(), copy and pg_stop_backup() steps
automatically, and transfers the backup over a regular PostgreSQL connection using the replication
protocol, instead of requiring file system level access. pg_basebackup does not interfere with
file system level backups taken using pg_start_backup()/pg_stop_backup().
[^c24]: https://www.postgresql.org/docs/9.1/backup-dump.html
[^pg_basebackup]: https://www.postgresql.org/docs/13/app-pgbasebackup.html

48
pulseaudio.md Executable file
View File

@ -0,0 +1,48 @@
---
author: Alvie Rahman
date: \today
title: Pulseaudio
tags: [ pulseaudio, linux, audio, mixing, microphone, sink ]
---
# Collect and Mix Sound Input From Different Sources {#paMixer}
## Create Mixer {#createMixer}
From <https://askubuntu.com/a/870596>:
> [...]
>
> pactl load-module module-null-sink sink_name=inputs
>
> [...] please repeat this for [every] input you want to mix [...]
>
> pactl load-module module-loopback sink=inputs
>
> Now you will have to connect this new "loopback" channels to the device you intend to record from.
> You can do this using "pavucontrol" (install it if missing), open the "Recording" tab, select
> "Virtual Streams" from the bottom selector and then make sure you connect a different input to
> each different loopback.
> [...]
The number returned by each command is the module id.
You may want to keep it if you want to [delete them individually](#destroyMixerSpecific).
## Destroy Mixer {#destroyMixer}
### Destroy _all_ Loopback and Null-Sink Modules {#destroyMixerAll}
From <https://www.pclinuxos.com/forum/index.php/topic,119695.msg1159936.html#msg1159936>:
>
> pactl unload-module module-loopback
> pactl unload-module module-null-sink
>
This will unload _all_ loopback and null-sink modules.
### Destroy Specific Modules {#destsroyMixerSpecific}
>
> pactl unload-module <module number>
>

25
python.md Executable file
View File

@ -0,0 +1,25 @@
---
author: Alvie Rahman
date: \today
title: Python
tags: [ docker, python, programming, io ]
---
# Issues
## No log output when running in docker
Change line beginning with `CMD` from:
```Dockerfile
CMD [ "python", "app.py" ]
```
to:
```Dockerfile
CMD [ "python", "-u", "app.py" ]
```
This disabled output buffering (stdout and stderr).