less big rename

This commit is contained in:
2021-12-23 15:41:57 +00:00
parent 51a5b12813
commit e8c154d43b
10 changed files with 0 additions and 0 deletions

12
computery_stuff/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

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.
```yaml
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
computery_stuff/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
computery_stuff/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.

50
computery_stuff/go.md Executable file
View File

@@ -0,0 +1,50 @@
---
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.
# `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>

22
computery_stuff/libvirt.md Executable file
View File

@@ -0,0 +1,22 @@
---
author: Alvie Rahman
date: \today
title: libvirt
tags: [ linux, virtualisation ]
---
# issues
## default network is not running
```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
```

20
computery_stuff/linux.md Executable file
View File

@@ -0,0 +1,20 @@
---
author: Alvie Rahman
date: \today
title: Linux
tags: [ linux ]
---
# user stuff
## add user to group
```bash
usermod -a -G group user
```
## change primary user group
```bash
usermod -g group user
```

112
computery_stuff/postgres.md Executable file
View File

@@ -0,0 +1,112 @@
---
author: Alvie Rahman
date: \today
title: Postgres
tags: [ programming ]
---
\tableofcontents
# Chapter 24: Backup and Restore[^c24]
Three types of backups:
- SQL dump---create text file of SQL commands that can recreate the database
`pg_dump dbname > outfile`
To restore: `psql dbname < infile`
- must be run as database superuser
- can be run remotely
- set host and username with `-h` and `-U` switches
- File system level backup
`tar -cf backup.tar /usr/local/pgsql/data`
- The database server **must** be shut down
- You can only backup and restore entire database clusters
- Continuous archiving (write ahead log archiving)
- "We do not need a perfectly consistent file system backup as the starting point."
- method can be used to create a continuous backup
- supports point in time recovery
- can be used to create a warm standby system
- can only be used to restore an entire database cluster
- requires a lot of archival storage
## SQL Dump
### Restoring a dump
Important note before you restore a database:
> Before restoring an SQL dump, all the users who own objects or were granted permissions on objects
in the dumped database must already exist. If they do not, the restore will fail to recreate the
objects with the original ownership and/or permissions. (Sometimes this is what you want, but
usually it is not.)
You should probably read the whole document [here](https://www.postgresql.org/docs/9.1/backup-dump.html)
## File system backup
You can run a FS level backup with minimal downtime with `rsync`:
1. Perform a backup with `rsync` while system is live
2. Shut down database server
3. Rerun `rsync` backup command
4. Restart database server
The second `rsync` command will run significantly quicker as it only has to transfer what has
changed since the first backup.
## Write Ahead Log (WAL) archiving
- WAL segment files usually get "recycled" by being renamed
- to archive WAL data, the content of each segment is captured and saved before it is reused
- you can save the data any way you like
- to enable WAL archiving:
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
- e.g.
```
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix
archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
```
where `%f` is the filename of the file to archive and `%p` is the path of file to archive:
```
test ! -f /mnt/server/archivedir/00000001000000A900000065 && cp pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065
```
- The command must only ever return a exit status of 0 **only if it succeeds*
- postgres will recycle the file if the command returns 0
- The archived data should have minimal access permissions
- the archive command should generally refuse to overwrite files and return non-zero
- In writing your archive command, you should assume that the file names to be archived can be
up to 64 characters long and can contain any combination of ASCII letters, digits, and dots.
- It is not necessary to preserve the original relative path (`%p`) but it is necessary to
preserve the file name (`%f`).
1. make a base backup
### make a base backup[^pg_basebackup]
1. ensure that WAL archiving is working and set up properly.
1. Run `pg_basebackup -D - -F tar > backup.tar`
[^c24]: https://www.postgresql.org/docs/9.1/backup-dump.html
[^pg_basebackup]: https://www.postgresql.org/docs/13/app-pgbasebackup.html

48
computery_stuff/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
computery_stuff/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).