Compare commits
	
		
			65 Commits
		
	
	
		
			0da2b4c7e8
			...
			bbaee49831
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| bbaee49831 | |||
| 0544be1bbb | |||
| 069b0752e3 | |||
| 4447d3f877 | |||
| 8a4896b971 | |||
| b2ea104e96 | |||
| 5a1ba18176 | |||
| 75cf02197e | |||
| f62e007d1f | |||
| 095adff052 | |||
| f4176a9ddb | |||
| 588ce9b0cb | |||
| bd657c9ddc | |||
| 658bda6eea | |||
| 7ec037d5df | |||
| 92d14e41b5 | |||
| 79fff90250 | |||
| 31f12e2161 | |||
| b5123a0d01 | |||
| 377a85c2b0 | |||
| d4c4463f70 | |||
| 47961779d5 | |||
| e199b99947 | |||
| 6d44a44d0d | |||
| 60c5cd829e | |||
| df53667f91 | |||
| a710375f82 | |||
| 51e489a8e3 | |||
| d4ca81c2ae | |||
| ae1e0ad726 | |||
| fc085dbb1e | |||
| 2ab863d88f | |||
| 55d5862b10 | |||
| 531cb8da3d | |||
| 09f3afa35b | |||
| e0e403fc96 | |||
| 72d624ec95 | |||
| 5b3a12d628 | |||
| f666ac3dc9 | |||
| 38bcdd15cc | |||
| 54a9444544 | |||
| b8a9fb3fbf | |||
| ce3e10e442 | |||
| e4beb16951 | |||
| e77d0676cf | |||
| c6e673f1b0 | |||
| 772f642679 | |||
| 69d6c1ab53 | |||
| 6525ad85ad | |||
| ad9054c212 | |||
| 93a48fded8 | |||
| c4313277e8 | |||
| aac3df9997 | |||
| c732d7d18d | |||
| b24a330f7a | |||
| 0fc1f58d24 | |||
| ff3a3d2556 | |||
| 6557ec6ebe | |||
| 912eeb478b | |||
| aa34b8b6e8 | |||
| fac575fc59 | |||
| b7fa4ab8c7 | |||
| 6f54bad403 | |||
| c1aff83d3e | |||
| 554eb989d5 | 
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -26,6 +26,8 @@ The chronology should never branch. | |||||||
| If `gitea` can use three different types of database, the documentation should simply pick one and continue instructions from there. | If `gitea` can use three different types of database, the documentation should simply pick one and continue instructions from there. | ||||||
| Repetition works better than a reference - if a database requires three commands to set up, it's better to repeat those three commands for every program that requires a database than to just link to another file which discusses databases. | Repetition works better than a reference - if a database requires three commands to set up, it's better to repeat those three commands for every program that requires a database than to just link to another file which discusses databases. | ||||||
|  |  | ||||||
|  | --- | ||||||
|  |  | ||||||
| ### Closing | ### Closing | ||||||
|  |  | ||||||
| Introductory documents should show anything required to cleanly uninstall a program, without leaving bulky configuration files behind. | Introductory documents should show anything required to cleanly uninstall a program, without leaving bulky configuration files behind. | ||||||
| @@ -52,6 +54,8 @@ Non-commands (e.g. output) should be shown as quoted text: | |||||||
| > Mail         kn | > Mail         kn | ||||||
| > Projects     music | > Projects     music | ||||||
|  |  | ||||||
|  | --- | ||||||
|  |  | ||||||
| # Example | # Example | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
| @@ -61,9 +65,9 @@ How to see which websites you're actively accessing: | |||||||
| ss -tr dst :$PORT | ss -tr dst :$PORT | ||||||
| ` ` `    | ` ` `    | ||||||
|  |  | ||||||
| > State  Recv-Q  Send-Q   Local Address:Port                                    Peer Address:Port   Process   | > State  Recv-Q  Send-Q   Local Address:Port     Peer Address:Port   Process   | ||||||
| > ESTAB  0       0         192.168.0.14:42476                                 149.154.167.91:https            | > ESTAB  0       0         192.168.0.14:42476  149.154.167.91:https            | ||||||
| > ESTAB  0       0         192.168.0.14:43644                                  104.17.90.199:https            | > ESTAB  0       0         192.168.0.14:43644   104.17.90.199:https            | ||||||
|  |  | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								basics/Joyous_ASCII.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								basics/Joyous_ASCII.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | |||||||
|  | --- | ||||||
|  | title: "Joyous ASCII" | ||||||
|  | tags: [ "fun" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | - `asciiquarium` | ||||||
|  | - `cbonsai -lim "$(fortune)"` | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cow=$(cowsay -l | sort -R | head  -1) | ||||||
|  | fortune -s | figlet | cowsay -nf $cow | lolcat | ||||||
|  | ``` | ||||||
							
								
								
									
										116
									
								
								basics/cron.md
									
									
									
									
									
								
							
							
						
						
									
										116
									
								
								basics/cron.md
									
									
									
									
									
								
							| @@ -2,9 +2,11 @@ | |||||||
| title: "cron" | title: "cron" | ||||||
| tags: [ "Documentation", "Basics" ] | tags: [ "Documentation", "Basics" ] | ||||||
| --- | --- | ||||||
| # Cron | # Cronie | ||||||
|  |  | ||||||
| The crontab program might have various names, like `cronie` or `crond`. | The `cronie` program is also known as `crond`. | ||||||
|  |  | ||||||
|  | ## Install | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| sudo apt search -n ^cron | sudo apt search -n ^cron | ||||||
| @@ -14,20 +16,35 @@ Once installed, search for the service name, and start it. | |||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| sudo systemctl list-unit-files | grep cron | sudo systemctl list-unit-files | grep cron | ||||||
|  | sudo systemctl enable --now $NAME | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | ## Usage | ||||||
|  |  | ||||||
|  | Show your current crontab: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| sudo systemctl enable --now cron | crontab -l | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| You can *e*dit your crontab with: | You can put this in a file and edit it: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| crontab -e | crontab -l > $filename | ||||||
|  | echo '39 3 */3 * * /bin/tar czf /tmp/etc_backup.tgz /etc/' >> $filename | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | Then apply that crontab: | ||||||
|  |  | ||||||
| > 39 */3 * * * /usr/bin/updatedb | ```bash | ||||||
|  | crontab $filename | ||||||
|  | rm $filename | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The `cron` program will check your syntax before adding the tab. | ||||||
|  |  | ||||||
|  | Your crontab file sits somewhere in `/var/spool/`. | ||||||
|  | Probably in `/var/spool/cron`. | ||||||
|  |  | ||||||
| ## Syntax | ## Syntax | ||||||
|  |  | ||||||
| @@ -39,43 +56,61 @@ These five points refer to: | |||||||
|  |  | ||||||
| So '3pm every Sunday' would be: | So '3pm every Sunday' would be: | ||||||
|  |  | ||||||
| > 0 15 * * 7 | `0 15 * * 7` | ||||||
|  |  | ||||||
| Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'. | Here 'Sunday' is indicated by "7", and '3pm' is 'the 15th hour'. | ||||||
| The minute is '0' (i.e. '0 minutes past three pm'). | The minute is '0' (i.e. '0 minutes past three pm'). | ||||||
|  |  | ||||||
| Doing the same thing, but only in February, would be: | Doing the same thing, but only in February, would be: | ||||||
|  |  | ||||||
| > 0 15 * 2 7 | `0 15 * 2 7` | ||||||
|  |  | ||||||
| ### Full Paths | ### Variables | ||||||
|  |  | ||||||
|  | `cronie` doesn't know where you live, so to put something in your `$HOME` directory, you have to tell it: | ||||||
|  |  | ||||||
| Executing something requires the full path to where it is, so you cannot simply use `apt update -y`, because cron does not know where `apt` is. |  | ||||||
| Instead, find out where it is: |  | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| type -P apt | echo "HOME=$HOME" > $filename | ||||||
|  | crontab -l >> $filename | ||||||
|  | crontab $filename | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| `/usr/bin/apt` | `cronie` doesn't know where anything lives, including programs. | ||||||
|  | You can give it your usual `$PATH` variable like this: | ||||||
|  |  | ||||||
| Then put that into the crontab: |  | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| sudo crontab -e | echo $PATH > $filename | ||||||
|  | crontab -l >> $filename | ||||||
|  | crontab $filename | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| > 40 */3 * * * /usr/bin/apt update -y | Now instead of doing this | ||||||
|  |  | ||||||
| This will run `apt update -y` as root every 3 hours, at 40 minutes past the hour, e.g. 00:40, 03:40, 06:40. | `40 */3 * * * /usr/bin/du -sh $HOME/* | sort -h > $HOME/sum.txt` | ||||||
|  |  | ||||||
| ## Directories | You can simply do this:  | ||||||
|  |  | ||||||
|  | `40 */3 * * * du -sh $HOME/* | sort -h > $HOME/sum.txt` | ||||||
|  |  | ||||||
|  | ## Run as Root | ||||||
|  |  | ||||||
| You can execute a script as root by putting it into a directory, instead of in the tab. | You can execute a script as root by putting it into a directory, instead of in the tab. | ||||||
| Look at the available cron directories: | Look at the available cron directories: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| ls /etc/cron.\* | ls -d /etc/cron.* | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Make a script which runs daily: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | f=apt_update.sh | ||||||
|  | echo '#!/bin/bash' > $f | ||||||
|  | echo 'apt update --yes' >> $f | ||||||
|  | chmod +x $f | ||||||
|  | sudo mv $f /etc/cron.daily/ | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ### Testing with runparts | ### Testing with runparts | ||||||
| @@ -86,50 +121,9 @@ Run-parts runs all executable scripts in a directory. | |||||||
| run-parts /etc/cron.hourly | run-parts /etc/cron.hourly | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Tips | # Troubleshooting | ||||||
|  |  | ||||||
| ### Variables |  | ||||||
|  |  | ||||||
| Add your `$HOME` to crontab to use scripts. |  | ||||||
| First add `HOME=/home/user`, then you can use syntax like this: |  | ||||||
|  |  | ||||||
| 0 * * * * $HOME/.scripts/myScript.sh |  | ||||||
|  |  | ||||||
| *Remember to test the script by executing that line first*: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| $HOME/.scripts/myScript.sh |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| You can also add your regular path to your crontab as a variable (see example below). |  | ||||||
| If you're using vim as the editor, just run this at the top of your crontab: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| :r!echo PATH=$PATH |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ### `date` Commands | ### `date` Commands | ||||||
|  |  | ||||||
| Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`. | Cron doesn't understand the `%` sign, so if you want to use `date +%R`, then it should be escaped with a backslash: `date +\%R`. | ||||||
|  |  | ||||||
| ### File Location |  | ||||||
|  |  | ||||||
| The crontab files are in `/var/spool/cron/`, so you can backup or restore them. |  | ||||||
|  |  | ||||||
| # Example |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| HOME=/home/user |  | ||||||
| PATH=/usr/condabin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/home/user/.local/bin:/home/user/.scripts/:/home/user/.local/bin:/home/user/.scripts/ |  | ||||||
|  |  | ||||||
| 1 0 1 * *    /usr/bin/mkdir -p $HOME/arc/$(date +\%Y/\%m) |  | ||||||
|  |  | ||||||
| 18 0 1 */3 * $HOME/.scripts/mail-clean.sh |  | ||||||
|  |  | ||||||
| * * * * * ping -c 1 home || mail-pull.sh |  | ||||||
|  |  | ||||||
| 50 18 * * * /usr/bin/timeout 30m /usr/bin/syncthing |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								basics/eval.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								basics/eval.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | --- | ||||||
|  | title: "eval" | ||||||
|  | tags: [ "basics" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Compose a statement for execution. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | x='echo $y' | ||||||
|  | echo $x | ||||||
|  | y=dragon | ||||||
|  | eval "$x" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The results remain in the current shell, unlike sub-shells. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | b=basilisk | ||||||
|  | sh -c 'echo $b' | ||||||
|  | eval "g=goblin" | ||||||
|  | echo $g | ||||||
|  | ``` | ||||||
							
								
								
									
										11
									
								
								basics/games.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								basics/games.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | --- | ||||||
|  | title: "bash games" | ||||||
|  | tags: [ "Documentation", "Games" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Games are a great way to learn bash. | ||||||
|  |  | ||||||
|  | - `mapscii.me` is an interactive terminal map. | ||||||
|  |     1. Install telnet. | ||||||
|  |     1. `telnet mapscii.me` | ||||||
|  | - [Over the Wire](https://overthewire.org/wargames) teaches bash with small challenging you can do over `ssh`. | ||||||
							
								
								
									
										38
									
								
								basics/hard_links.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								basics/hard_links.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | |||||||
|  | --- | ||||||
|  | title: "hard links" | ||||||
|  | tags: [ "basics", "links" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | A hard link is one file which exists in multiple locations. | ||||||
|  |  | ||||||
|  | Each file has an ID, which is kept on the hard disk's partition. | ||||||
|  | Each hard link has the same ID, because they are the same file. | ||||||
|  | This ID is called the 'inode'. | ||||||
|  |  | ||||||
|  | Create a file, and a hard link: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | fortune > $file_1 | ||||||
|  | mkdir -p x/y/z/ | ||||||
|  | ln $file_1 x/y/z/$file_2 | ||||||
|  | ``` | ||||||
|  | Have a long look at the file with the `-l` flag, and check the inode with `-i`: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -li $file_1 x/y/z/$file_2 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Since they are the same file, you can make a change to one, and it changes both: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | fortune | tee x/y/z/$file_2 | ||||||
|  | cat $file_1 | ||||||
|  | cat x/y/z/$file_2 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | # Danger Zone | ||||||
|  |  | ||||||
|  | - hard links will not work on directories, only standard files and fifos. | ||||||
|  | - `git` will destroy and remake files, so it will not respect hard links. | ||||||
|  | - Files cannot have a hard link on another disk partition, because the inode is stored on each partition. | ||||||
|  |  | ||||||
| @@ -1,19 +1,9 @@ | |||||||
| --- | --- | ||||||
| title: "links" | title: "links" | ||||||
| tags: [ "Documentation", "Basics" ] | tags: [ "basics", "links" ] | ||||||
| --- | --- | ||||||
| Link from X to Y. |  | ||||||
|  |  | ||||||
| ```bash | There are two types: | ||||||
| ln -s X ../otherdir/Y |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| If you want a hard link, this will make a single file exist in two locations. |  | ||||||
| If it is deleted in one location, it continues to exist in the other. |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| ln *X* *Y* |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Both files must be on the same hard drive, as they have the same inode (check this with `ls -i file`). |  | ||||||
|  |  | ||||||
|  | - [Soft links](soft_links.md) | ||||||
|  | - [Hard links](hard_links.md) | ||||||
|   | |||||||
							
								
								
									
										46
									
								
								basics/ls.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								basics/ls.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | |||||||
|  | --- | ||||||
|  | title: "ls" | ||||||
|  | tags: [ "basics" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Firstly, your `ls` is probably aliased to something. | ||||||
|  |  | ||||||
|  | Check it with: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | alias ls | ||||||
|  | ``` | ||||||
|  | If the prompt shows some alias, then start by removing it: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | unalias ls | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Now we can begin. | ||||||
|  |  | ||||||
|  | Check the most recently modified file: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -t | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Reverse this with `tac` to see the file which has been unmodified the longest: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -t | tac | ||||||
|  | ``` | ||||||
|  | Group files by extension: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -X | ||||||
|  | ``` | ||||||
|  | Sort largest files first: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -X | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										180
									
								
								basics/setup/Quality_of_Life.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								basics/setup/Quality_of_Life.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,180 @@ | |||||||
|  | --- | ||||||
|  | title: "Quality of Life" | ||||||
|  | tags: [ "basics", "setup" ] | ||||||
|  | dependencies: [ "vi", "basics" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | This & That | ||||||
|  | =========== | ||||||
|  |  | ||||||
|  | Refer to 'that last thing', and 'the first thing': | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | fortune -l > file1 | ||||||
|  | cat !$  | tr -d u | ||||||
|  | diff !^ !$ | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | **NB:** this can go wrong: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -l file1 file2 | ||||||
|  | cat !^ | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Done | ||||||
|  | ---- | ||||||
|  |  | ||||||
|  | `<C-d>` | ||||||
|  |  | ||||||
|  | - If you have a command, Control + d will execute the command. | ||||||
|  | - If you have nothing, `exit`. | ||||||
|  |  | ||||||
|  | Input Run-Commands (`~/.inputrc`) | ||||||
|  | ================================= | ||||||
|  |  | ||||||
|  | Alias Expansion | ||||||
|  | --------------- | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo '"\C- ": shell-expand-line' >> ~/.inputrc | ||||||
|  | exec bash | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Now you can expand all aliases with 'Control + Space'. | ||||||
|  | Try just `ls`, then 'Control + Space'. | ||||||
|  |  | ||||||
|  | Glob Expansion (`*`) | ||||||
|  | -------------------- | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo '"\C-x": glob-expand-word' >> ~/.inputrc | ||||||
|  | exec bash | ||||||
|  | ls *<C-x> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | - Are you sure you want to delete that? | ||||||
|  |     * `rm -r *<C-x>` | ||||||
|  | - Clean up the Downloads folder: | ||||||
|  |     * `rm Downloads/*pdf<C-x>` | ||||||
|  |  | ||||||
|  | Arbitrary Commands | ||||||
|  | ------------------ | ||||||
|  |  | ||||||
|  | Use `\n` as a 'newline' character to automatically press `<Return>`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo 'Control-y: "| lolcat\n"' >> ~/.inputrc | ||||||
|  | exec bash | ||||||
|  | ls<C-y> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | Control-l: "\C-u clear -x && ls\n" | ||||||
|  | exec bash | ||||||
|  | cd /etc/<C-l> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Readline as Vi | ||||||
|  | -------------- | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo 'set editing-mode vi' >> ~/.inputrc | ||||||
|  | echo 'set keymap vi-insert' >> ~/.inputrc | ||||||
|  | exec bash | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The prompt now works according to `vi`-motions. | ||||||
|  | This goes much further than the bash-option, `set -o vi` ('set option: `vi`'). | ||||||
|  | It changes the cursor in the terminal, not just bash. | ||||||
|  |  | ||||||
|  | Try: | ||||||
|  |  | ||||||
|  | - `ls <C-n>` | ||||||
|  | - `ls <C-p>` | ||||||
|  | - Type some words. | ||||||
|  | - `<Esc>0dw$p` | ||||||
|  | - <Esc> to normal-mode, and go back with 'b', and forward with 'e'. | ||||||
|  | - `4b` to step back four times. | ||||||
|  | - `cE` | ||||||
|  | - `<Esc>kcw` | ||||||
|  | - ls -a<Esc>xxxx | ||||||
|  |  | ||||||
|  | Works with `python` too: | ||||||
|  |  | ||||||
|  | ```python | ||||||
|  | im<C-n>os<Return> | ||||||
|  | os.li<C-n><Return> | ||||||
|  | <Esc>kfn | ||||||
|  | <C-d> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Fix Globs! | ||||||
|  | ---------- | ||||||
|  |  | ||||||
|  | If you tried the previous commands then they will not work any more, because the `vi`-commands overwrite the other commands. | ||||||
|  | Remove them. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sed '/ vi/d' ~/.inputrc | ||||||
|  | sed -i '/ vi/d' ~/.inputrc | ||||||
|  |  | ||||||
|  | sed '1 i set editing-mode vi' .inputrc  | ||||||
|  | sed -i '1 i set editing-mode vi' ~/.inputrc  | ||||||
|  | sed -i '2 i set keymap vi-insert' ~/.inputrc  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Vi-sibility | ||||||
|  | ----------- | ||||||
|  |  | ||||||
|  | The `readline` prompt becomes confusing if you don't remember if you're in insert or normal mode. | ||||||
|  | But you can show the  current mode in the prompt: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo 'set show-mode-in-prompt on' >> ~/.inputrc | ||||||
|  | exec bash | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Set new symbols for normal and insert mode: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo 'set vi-ins-mode-string "  "' >> ~/.inputrc | ||||||
|  | echo 'set vi-cmd-mode-string " "' >> ~/.inputrc | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Fuzzy Sort | ||||||
|  | ========== | ||||||
|  |  | ||||||
|  | Check your repos for `sk-im`, and install. | ||||||
|  | The program is called `sk`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | FUZZY=sk | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | If you don't have it, `fzy` or `fzf` should work the same way. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | FUZZY=fzy | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Find some 'read-config' files to check out: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | find . -maxdepth 2 -name "*rc" | ||||||
|  | find . -maxdepth 2 -name "*rc" | $FUZZY | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | And read some: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | PAGER='less -R' | ||||||
|  | $PAGER "$(find . -maxdepth 2 -name "*rc" | $FUZZY)" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Make the change long-term: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | alias rrc='$PAGER "$(find . -maxdepth 2 -name "*rc" | sk)"' | ||||||
|  | alias | grep rrc= >> ~/.bash_aliases | ||||||
|  | ``` | ||||||
							
								
								
									
										72
									
								
								basics/soft_links.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								basics/soft_links.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,72 @@ | |||||||
|  | --- | ||||||
|  | title: "soft links" | ||||||
|  | tags: [ "basics", "links" ] | ||||||
|  | --- | ||||||
|  | A soft link is a file which says how to go to another file. | ||||||
|  | When a program encounters a soft link, it will make a  guess at whether it should ignore it, or try to get to that file. | ||||||
|  |  | ||||||
|  | To make a soft link to a file in the current directory, linking is easy: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | fortune > $file_1 | ||||||
|  | ln -s $file_1 $link_1 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Now imagine your directory looks like this: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | dir_0/ | ||||||
|  | ├── dir_1 | ||||||
|  | │   └── file_1 | ||||||
|  | ├── dir_2 | ||||||
|  | │   └── file_1 | ||||||
|  | ├── file_1 | ||||||
|  | └── link_1 | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Inside `dir_1`, making a soft link to `dir_0/file_1` would mean putting the directions to that file: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cd dir_1 | ||||||
|  | ln -s ../file_1 link_1 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The real content of the file is just '`../file_1`, so making it from another directory would mean writing exactly the same address to that file: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ln -s ../file_1 dir_2/link_2 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Both symlinks are identical, except for the name. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | dir_0/ | ||||||
|  | ├── dir_1 | ||||||
|  | │   ├── file_1 | ||||||
|  | │   └── link_1   <-- This one points to ../file_1 | ||||||
|  | ├── dir_2 | ||||||
|  | │   ├── file_1 | ||||||
|  | │   └── link_2   <-- This one points to ../file_1 as well. | ||||||
|  | └── file_2 | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Since it's just an address, you can delete the original file, then make another. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | rm file_1 | ||||||
|  | ls -l dir_1/ | ||||||
|  | fortune > file_1 | ||||||
|  | cat dir_2/link_2 | ||||||
|  | fortune | tee -a file_1 | ||||||
|  | cat dir_1/link_1 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Last, let's make a link from `dir_2/link_2` to `dir_1/file_1` (this will delete the old link): | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ln -s -f ../dir_1/file_1 dir_2/link_2 | ||||||
|  | cat dir_2/link_2 | ||||||
|  | ``` | ||||||
|  |  | ||||||
| @@ -68,3 +68,11 @@ ntpq -p | |||||||
|  |  | ||||||
| Usually this is run as a service, so just start that service. | Usually this is run as a service, so just start that service. | ||||||
|  |  | ||||||
|  | # Force Reset | ||||||
|  |  | ||||||
|  | If your clock drifts too far from the right time, it will not reset happily. | ||||||
|  | For it to reset like this: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo ntpd -q -g -x -n | ||||||
|  | ``` | ||||||
|   | |||||||
							
								
								
									
										36
									
								
								basics/tree.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								basics/tree.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | --- | ||||||
|  | title: "tree" | ||||||
|  | tags: [ "basics", "tree", "markdown" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | The `tree` utility outputs a full listing of everything in your current directory, and those below. | ||||||
|  |  | ||||||
|  | - Just directories: `tree -d` | ||||||
|  | - Output colour to `less`: `tree -C --info | less -re` | ||||||
|  | - Ignore files in the `.gitignore` file: `tree --gitignore` | ||||||
|  |  | ||||||
|  | You can place information about the files in a directory to use with the `tree --info` option, like this: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | config | ||||||
|  | 	Config files. | ||||||
|  | 	This is a git submodule. | ||||||
|  | README.md | ||||||
|  | 	Summary of the git. | ||||||
|  | *.jpg | ||||||
|  | 	Little picture, does not display | ||||||
|  | 	words well. | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Each description-line starts with a tab. | ||||||
|  |  | ||||||
|  | ## Markdown Conversion | ||||||
|  |  | ||||||
|  | To represent a file structure as a nested series of markdown lists, you can try this horrifying `sed` one-liner: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | tree -tf --dirsfirst --gitignore --noreport --charset ascii  | \ | ||||||
|  |     sed -e 's/| \+/  /g' \ | ||||||
|  |     -e 's/[|`]-\+/ */g' \ | ||||||
|  |     -e 's:\(* \)\(\(.*/\)\([^/]\+\)\):\1[\4](\2):g' | ||||||
|  | ``` | ||||||
							
								
								
									
										24
									
								
								basics/yes.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								basics/yes.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | |||||||
|  | --- | ||||||
|  | title: "yes" | ||||||
|  | tags: [ "basics" ] | ||||||
|  | --- | ||||||
|  | # The Best Linux Program: `yes` | ||||||
|  |  | ||||||
|  | The program `yes` prints the word `yes` to your terminal until you cancel it, perhaps with 'Control + c'. | ||||||
|  | Or technically it prints `yes\n`, meaning `yes` and then a new line (like pressing the Return key). | ||||||
|  |  | ||||||
|  | This is extremely powerful. | ||||||
|  |  | ||||||
|  | If you ever want to automatically install something which persistently nags you with `do you want to do the thing? [y/N]?`, then you can just pipe `yes` into that program, and it will answer 'yes' to all questions. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | yes | $INSTALL_SCRIPT_FILE.sh | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | This works best for disposable systems, like VMs or containers. | ||||||
|  | Try this on a live system, and you might find out that you should have read that message fully. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | yes | yay | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										57
									
								
								chat/profanity-otr.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										57
									
								
								chat/profanity-otr.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,57 @@ | |||||||
|  | --- | ||||||
|  | title: "profanity" | ||||||
|  | tags: [ "Documentation", "Chat", "OTR" ] | ||||||
|  | --- | ||||||
|  | # otr | ||||||
|  |  | ||||||
|  | 'Off The Record' encryption seems mostly dead to me. | ||||||
|  | But this is what I did, back in the day... | ||||||
|  |  | ||||||
|  | Install libotr-dev or libotr5-dev or whatever.. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | sudo apt -y install lib5otr-dev | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Make your otr keys. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr gen | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Then you can start an otr converstation. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr start bob@jobbies.org | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Or if you already have a conversation windows open, switch to our using: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Finally, verify! | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr question "Who are you?" bob | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Bob is verified upon the answer, 'bob'. | ||||||
|  |  | ||||||
|  | ### OTR Finger Prints | ||||||
|  |  | ||||||
|  | Get yours with  | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr myfp | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr theirfp | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | /otr myfp | ||||||
|  | ``` | ||||||
|  |  | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| title: "profanity" | title: "profanity" | ||||||
| tags: [ "Documentation", "Chat" ] | tags: [ "Documentation", "Chat", "omemo" ] | ||||||
| --- | --- | ||||||
| # Setup (Commands) | # Setup (Commands) | ||||||
|  |  | ||||||
| @@ -140,54 +140,6 @@ You can ensure omemo automatcally turns on: | |||||||
| ``` | ``` | ||||||
| /omemo policy automatic | /omemo policy automatic | ||||||
| ``` | ``` | ||||||
|  | --- | ||||||
|  |  | ||||||
| ## otr | 'OTR' encryption is mostly dead, but you can find the old instructions [here](profanity-otr). | ||||||
|  |  | ||||||
| Install libotr-dev or libotr5-dev or whatever.. |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| sudo apt -y install lib5otr-dev |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Make your otr keys. |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr gen |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Then you can start an otr converstation. |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr start bob@jobbies.org |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Or if you already have a conversation windows open, switch to our using: |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Finally, verify! |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr question "Who are you?" bob |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Bob is verified upon the answer, 'bob'. |  | ||||||
|  |  | ||||||
| ### OTR Finger Prints |  | ||||||
|  |  | ||||||
| Get yours with  |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr myfp |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr theirfp |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| /otr myfp |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								data/calcurse.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								data/calcurse.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | --- | ||||||
|  | title: "calcurse" | ||||||
|  | tags: [ "data", "calendar", "daylight savings" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## Setup | ||||||
|  |  | ||||||
|  | The UK government keeps an ics file with clock, [here](https://www.gov.uk/when-do-the-clocks-change/united-kingdom.ics). | ||||||
|  |  | ||||||
							
								
								
									
										73
									
								
								data/email.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								data/email.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | |||||||
|  | --- | ||||||
|  | title: "e-mail" | ||||||
|  | tags: [ "data", "smtp" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | This is bare-bones, original, primitive e-mail. | ||||||
|  |  | ||||||
|  | Install `opensmtpd` (or similar), then `ncat` or `nc` or `netcat` (this mysterious cat has many names). | ||||||
|  |  | ||||||
|  | Start the `opensmtpd` service, then use netcat to speak with the mail-daemon: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | nc localhost 25 | ||||||
|  | ``` | ||||||
|  | The computer should respond with code `220`, which means 'I am listening'. | ||||||
|  |  | ||||||
|  | > 220 hex ESMTP OpenSMTPD | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | HELO gmail.com | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You say `HELO` and say where you are coming from. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | The `smtpd` will not check, so I am going to lie to it. | ||||||
|  | Mail servers are easily impressed, so it will be pleased to meet you. | ||||||
|  |  | ||||||
|  | > 250 hex Hello gmail.com [::1], pleased to meet you | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | MAIL FROM: <admin@gmail.com> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | All the mail commands start with 4 bytes, because it's easier for admins to program. | ||||||
|  | Tell the mail daemon who you are in this format. | ||||||
|  |  | ||||||
|  | > 250 2.0.0 Ok | ||||||
|  |  | ||||||
|  | Then tell it who you're sending to. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | RCPT TO: <www@dmz.rs> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | > 250 2.1.5 Destination address valid: Recipient ok | ||||||
|  |  | ||||||
|  | Finally, tell it that you want to send `DATA`. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | DATA | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | > 354 Enter mail, end with "." on a line by itself | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | Subject: turn off server please | ||||||
|  |  | ||||||
|  | very urgent | ||||||
|  | . | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | > 250 2.0.0 73864a49 Message accepted for delivery | ||||||
|  |  | ||||||
|  | You will find the email under `/var/spool` or `/var/mail` or similar. | ||||||
|  |  | ||||||
|  | If unsure, just take a part of your email, like `FRAGMENT="turn off server please"`, then `grep` for it: | ||||||
|  |  | ||||||
|  |  ```bash | ||||||
|  | sudo grep -r $FRAGMENT /var/spool/* | ||||||
|  |  ``` | ||||||
|  |  | ||||||
| @@ -22,6 +22,7 @@ And overwrite all metadata: | |||||||
| ```bash | ```bash | ||||||
| exiftool -all= -overwrite_original -ext jpg . | exiftool -all= -overwrite_original -ext jpg . | ||||||
| ``` | ``` | ||||||
|  | (NB: This does not work on pdf data. See [here](pdf_erasure.md) for erasing all pdf data) | ||||||
| 
 | 
 | ||||||
| Or just GPS data: | Or just GPS data: | ||||||
| 
 | 
 | ||||||
| @@ -36,3 +37,4 @@ identify -verbose | |||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| @@ -92,7 +92,7 @@ A branch is a full copy of the project to test additional ideas. | |||||||
| You can make a new branch called 'featurez' like this: | You can make a new branch called 'featurez' like this: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git branch *featurez* | git branch $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Have a look at all your branches: | Have a look at all your branches: | ||||||
| @@ -104,19 +104,20 @@ git branch | |||||||
| Switch to your new branch: | Switch to your new branch: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git checkout *featurez* | git checkout $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| And if your changes are rubbish, checkout the "master" branch again, then delete "featurez": | And if your changes are rubbish, checkout the "master" branch again, then delete "featurez": | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git branch -D *featurez* | git branch -D $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Or if it's a good branch, push it to the remote: | Or if it's a good branch, push it to the remote: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git push *origin* *featurez* | remote=origin | ||||||
|  | git push $remote $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Merging | ## Merging | ||||||
| @@ -124,13 +125,13 @@ git push *origin* *featurez* | |||||||
| Once you like the feature, merge it into the main branch.  Switch to master then merge it: | Once you like the feature, merge it into the main branch.  Switch to master then merge it: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git merge *featurez* | git merge $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| and delete `featurez` as you've already merged it: | And delete the branch, as you've already merged it: | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| git branch -d featurez | git branch -d $FEATURE_BRANCH | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| # Subtree | # Subtree | ||||||
| @@ -141,34 +142,6 @@ git branch -d featurez | |||||||
| git subtree add -P config git@gitlab.com:bindrpg/config.git master | git subtree add -P config git@gitlab.com:bindrpg/config.git master | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Pulling a Subtree from an existing git |  | ||||||
| 
 |  | ||||||
| The project has subdirectories sub-1,sub-2,sub-3.  The first should be its own repository, but should also retain its own history. |  | ||||||
| 
 |  | ||||||
| First, we extract its history as an independent item, and make that into a seprate branch. |  | ||||||
| 
 |  | ||||||
| ```bash |  | ||||||
| git subtree split --prefix=sub-1 -b sub |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3 |  | ||||||
| 
 |  | ||||||
| Then go and create a new git somewhere else: |  | ||||||
| 
 |  | ||||||
| ```bash |  | ||||||
| cd ..;mkdir sub-1;cd sub-1;git init --bare |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| Then go back to your initial git repo, and do the following: |  | ||||||
| 
 |  | ||||||
| git push ../subtest sub:master |  | ||||||
| 
 |  | ||||||
| Finally, you can clone this repo from your original. |  | ||||||
| 
 |  | ||||||
| ```bash |  | ||||||
| git clone ../subtest |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| # Tricks | # Tricks | ||||||
| 
 | 
 | ||||||
| ## Delete All History | ## Delete All History | ||||||
							
								
								
									
										9
									
								
								data/git/git_secret.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								data/git/git_secret.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | --- | ||||||
|  | title: "git-secret" | ||||||
|  | tags: [ "data", "git" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | This utility is largely useless, as it can only identify people by their email. | ||||||
|  | So if someone has multiple GPG keys associated with one email, the tool will not work. | ||||||
|  |  | ||||||
|  | A broken tool is better than a tool which will break soon. | ||||||
							
								
								
									
										29
									
								
								data/git/hooks.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								data/git/hooks.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | --- | ||||||
|  | title: "git hooks" | ||||||
|  | tags: [ "Documentation", "data", "git" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Check out the sample hooks: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cd $GIT_REPO | ||||||
|  | ls .git/hooks | ||||||
|  | head .git/hooks/pre-commit.sample | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Add a hook to check the shell scripts in `$GIT_REPO` before making a commit: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo '#!/bin/sh | ||||||
|  | shellcheck *.sh' > .git/hooks/commit-msg | ||||||
|  | chmod u+x .git/hooks/commit-msg | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Committing | ||||||
|  |  | ||||||
|  | Your `git hooks` will not enter the repository, but you can commit them to a repository, then request others add these git hooks to their own branch, by putting a note in the project's `README.md`. | ||||||
|  |  | ||||||
|  | ```markdown | ||||||
|  | The project comes with recommended git hooks. | ||||||
|  | You can activate the hooks with `git config core.hooksPath hooks`. | ||||||
|  | ``` | ||||||
							
								
								
									
										34
									
								
								data/git/subtree.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								data/git/subtree.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | --- | ||||||
|  | title: "git" | ||||||
|  | tags: [ "Documentation", "data", "git", "subtree" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## Pulling a Subtree from an existing git | ||||||
|  |  | ||||||
|  | The project has subdirectories `sub-1`, `sub-2`, `sub-3`. | ||||||
|  | The first should be its own repository, but should also retain its own history. | ||||||
|  |  | ||||||
|  | First, we extract its history as an independent item, and make that into a seprate branch. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | git subtree split --prefix=sub-1 -b sub | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | If you want something a few directories deep, you can use `--prefix=sub-1/dir-2/dir-3 | ||||||
|  |  | ||||||
|  | Then go and create a new git somewhere else: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cd ..;mkdir sub-1;cd sub-1;git init --bare | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Then go back to your initial git repo, and do the following: | ||||||
|  |  | ||||||
|  | git push ../subtest sub:master | ||||||
|  |  | ||||||
|  | Finally, you can clone this repo from your original. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | git clone ../subtest | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										118
									
								
								data/gpg.md
									
									
									
									
									
								
							
							
						
						
									
										118
									
								
								data/gpg.md
									
									
									
									
									
								
							| @@ -1,119 +1,7 @@ | |||||||
| --- | --- | ||||||
| title: "gpg" | title: "gpg" | ||||||
| tags: [ "Documentation", "data" ] | tags: [ "Documentation", "data", "GPG" ] | ||||||
| --- | --- | ||||||
| # Making keys |  | ||||||
|  |  | ||||||
| Generate keys: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --gen-key |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Follow the guide. |  | ||||||
|  |  | ||||||
| # Encrypting a file |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg -r malinfreeborn@posteo.net -e file |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| `-r` specifies the recipient. |  | ||||||
|  |  | ||||||
| Check you have an encrypted version of your file. |  | ||||||
|  |  | ||||||
| # Changing Expiration Dates |  | ||||||
|  |  | ||||||
| gpg --list-keys |  | ||||||
|  |  | ||||||
| ... and then use the second part of 'pub', which is the ID.  But that's not appearing here so... on with gpg2? |  | ||||||
|  |  | ||||||
| # Making encrypted files with a local password |  | ||||||
|  |  | ||||||
| Make a password with a password (cypher encryption). |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg -c --output passwords.txt |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| or  |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg -c > passwords.txt |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Put in a password. |  | ||||||
|  |  | ||||||
| Write message then stop with Ctrl+d. |  | ||||||
|  |  | ||||||
| Get the message back out the file with: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg -d passwords.txt |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| # Circles of Trust |  | ||||||
|  |  | ||||||
| Search for a key at any key store: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --search-keys nestorv |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Once you've made a decision about someone: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --list-keys |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| You get something like this: |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
| pub   rsa3072 2021-08-15 [SC] [expires: 2023-08-15] |  | ||||||
|       CD30421FD825696BD95F1FF644C62C57B790D3CF |  | ||||||
| uid           [ultimate] Malin Freeborn <malinfreeborn@posteo.net> |  | ||||||
| sub   rsa3072 2021-08-15 [E] [expires: 2023-08-15] |  | ||||||
|  |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Notice the long, ugly, string - CD30421FD825696BD95F1FF644C62C57B790D3CF - and how horribly ugly it is. |  | ||||||
| This is a fingerprint. |  | ||||||
|  |  | ||||||
| You can now decide the trust level (this stays on your computer). |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --edit-key *CD30421FD825696BD95F1FF644C62C57B790D3CF* |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Once you're in the interface, type `trust`. |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --sign-key alice@posteo.net |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Then send those trusted keys up to a server, so people can see you have verified them: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --send-keys *024C6B1C84449BD1CB4DF7A152295D2377F4D70F* |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| # Refresh Keys |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --refresh-keys |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| # Export |  | ||||||
|  |  | ||||||
| Your public key: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --output *me*.gpg --armor --export |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| or |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| gpg --export -a *person@email.tld* > *my_key*.pub |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|  | - [Setup](gpg/basics.md) | ||||||
|  | - [Extras](gpg/extras.md) | ||||||
|   | |||||||
							
								
								
									
										146
									
								
								data/gpg/basics.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										146
									
								
								data/gpg/basics.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,146 @@ | |||||||
|  | --- | ||||||
|  | title: "GPG Basics" | ||||||
|  | tags: [ "Documentation", "data", "GPG" ] | ||||||
|  | --- | ||||||
|  | # Making keys | ||||||
|  |  | ||||||
|  | Generate keys: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --full-generate-key | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Follow the guide. | ||||||
|  |  | ||||||
|  | # Encrypting a file | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg -r malinfreeborn@posteo.net -e file | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | `-r` specifies the recipient. | ||||||
|  |  | ||||||
|  | Check you have an encrypted version of your file. | ||||||
|  |  | ||||||
|  | # Changing Expiration Dates | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --list-keys | ||||||
|  | # or... | ||||||
|  | gpg -k | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ... and then use the second part of 'pub', which is the ID.  But that's not appearing here so... on with gpg2? | ||||||
|  |  | ||||||
|  | # Making encrypted files with a local password | ||||||
|  |  | ||||||
|  | Make a password with a password (cypher encryption). | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg -c --output passwords.txt | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | or  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg -c > passwords.txt | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Put in a password. | ||||||
|  |  | ||||||
|  | Write message then stop with Ctrl+d. | ||||||
|  |  | ||||||
|  | Get the message back out the file with: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg -d passwords.txt | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | # Circles of Trust | ||||||
|  |  | ||||||
|  | Search for a key at any key store: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --search-keys nestorv | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Once you've made a decision about someone: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --list-keys | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You get something like this: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | pub   rsa3072 2021-08-15 [SC] [expires: 2023-08-15] | ||||||
|  |       CD30421FD825696BD95F1FF644C62C57B790D3CF | ||||||
|  | uid           [ultimate] Malin Freeborn <malinfreeborn@posteo.net> | ||||||
|  | sub   rsa3072 2021-08-15 [E] [expires: after-forever] | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Notice the long, ugly, string - `CD30421FD825696BD95F1FF644C62C57B790D3CF` - and how horribly ugly it is. | ||||||
|  | This is a fingerprint. | ||||||
|  |  | ||||||
|  | You can now decide the trust level (this stays on your computer). | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --edit-key CD30421FD825696BD95F1FF644C62C57B790D3CF | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Once you're in the interface, type `trust`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --sign-key alice@posteo.net | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | # Swapping Keys | ||||||
|  |  | ||||||
|  | This system relies on a ring of people swapping key information. | ||||||
|  |  | ||||||
|  | ## Sending | ||||||
|  |  | ||||||
|  | Send those trusted keys up to a server, so people can see you have verified them: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --send-keys 024C6B1C84449BD1CB4DF7A152295D2377F4D70F | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Upload Your Keys | ||||||
|  |  | ||||||
|  | ## Add More Key Servers | ||||||
|  |  | ||||||
|  | Key servers often swap keys, but it's best to just send to multiple places immediately. | ||||||
|  | You can add key servers by adding this to `~/.gnupg/gpg.conf`. | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | keyserver hkps://keys.openpgp.org | ||||||
|  | keyserver hkps://mail-api.proton.me | ||||||
|  | keyserver hkps://keys.mailvelope.com | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | # Refresh Keys | ||||||
|  |  | ||||||
|  | Refreshing keys will tell you if some key you have contains a signature from someone you already trust, or if someone has published a revocation certificate (meaning their key should not be trusted any more). | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --refresh-keys | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You can use the [crontab](../../basics/cron.md) to refresh keys, but this will mostly fail, since keyservers often don't hold the right data. | ||||||
|  |  | ||||||
|  | # Export | ||||||
|  |  | ||||||
|  | Your public key: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --output me.gpg --armor --export | ||||||
|  | ``` | ||||||
|  | Alternatively: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gpg --export -a person@email.tld > my_key.pub | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								data/gpg/extras.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								data/gpg/extras.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | --- | ||||||
|  | title: "gpg" | ||||||
|  | tags: [ "Documentation", "vim", "data", "GPG" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | The `vim-gnupg` plugin lets vim edit gpg-encrypted files as if they were unencrypted. | ||||||
|  |  | ||||||
|  | It's probably in your package manager. | ||||||
|  | If not, you'll need to endure the faff of following the [instructions](http://www.vim.org/scripts/script.php?script_id=3645). | ||||||
|  |  | ||||||
							
								
								
									
										25
									
								
								data/pdf_erasure.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								data/pdf_erasure.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | |||||||
|  | --- | ||||||
|  | title: "PDF Metadata Erasure" | ||||||
|  | tags: [ "Documentation", "Metadata", "Ghost Script" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Make a text file called 'pdfmark.txt'. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```text | ||||||
|  | [ /Title () | ||||||
|  | /Author () | ||||||
|  | /Subject () | ||||||
|  | /Creator () | ||||||
|  | /ModDate () | ||||||
|  | /Producer () | ||||||
|  | /Keywords () | ||||||
|  | /CreationDate () | ||||||
|  | /DOCINFO pdfmark | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Then run: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | gs -o output.pdf -sDEVICE=pdfwrite "$FILE".pdf pdfmark.txt | ||||||
|  | ``` | ||||||
							
								
								
									
										122
									
								
								data/radicale.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								data/radicale.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,122 @@ | |||||||
|  | --- | ||||||
|  | title: "radicale and nginx" | ||||||
|  | tags: [ "data", "calendar" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Check before you start: | ||||||
|  |  | ||||||
|  | - you have a normally running site on nginx already. | ||||||
|  | - your server has the directory `/etc/nginx/sites-enabled/` enabled in the nginx config. | ||||||
|  |  | ||||||
|  | ## Installation and Service | ||||||
|  |  | ||||||
|  | Install `radicale` through your package manager (not `pip`). | ||||||
|  | The standard `radicale` package should come with a nice `systemd` service file. | ||||||
|  |  | ||||||
|  | If the service comes already-started, stop it immediately: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo systemctl stop radicale | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## Set up Passwords | ||||||
|  |  | ||||||
|  | Edit `/etc/radicale/config`, changing the `[auth]` section from this: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | #type = none | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ...to this: | ||||||
|  | ``` | ||||||
|  | type = htpasswd | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Make sure the service is off, as people may be able to sign in without a password at this point. | ||||||
|  |  | ||||||
|  | Next, find the `htpasswd` program. | ||||||
|  | You might get it in the `apache` package or similar. | ||||||
|  |  | ||||||
|  | `htpasswd` allows you to generate passwords for users, and place them in `/etc/radicale/users`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | PASS="$(xkcdpass)" | ||||||
|  | htpasswd -nb $USER "$PASS" | sudo tee -a /etc/radicale/users | ||||||
|  | echo "Your username is $USER" | ||||||
|  | echo "Your password is $PASS" | ||||||
|  | ``` | ||||||
|  | Right now, you can't sign into the server except through the localhost, which is pointless. | ||||||
|  | So now we add a subdomain to `nginx`. | ||||||
|  |  | ||||||
|  | ```nginx | ||||||
|  |  | ||||||
|  | echo ' | ||||||
|  |  server { | ||||||
|  |     if ($host = cal.DOMAIN) { | ||||||
|  |         return 301 https://$host$request_uri; | ||||||
|  |     } # managed by Certbot | ||||||
|  |  | ||||||
|  |  | ||||||
|  |      listen 80; | ||||||
|  |      server_name cal.DOMAIN; | ||||||
|  |                                                                                          | ||||||
|  |      location / { | ||||||
|  |          proxy_pass http://localhost:5232; | ||||||
|  |          proxy_set_header Host $host; | ||||||
|  |          proxy_set_header X-Real-IP $remote_addr; | ||||||
|  |          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||||||
|  |      } | ||||||
|  |                                                                                          | ||||||
|  |      return 301 https://$server_name$request_uri; | ||||||
|  |   | ||||||
|  |  | ||||||
|  | } | ||||||
|  |                                                                                          | ||||||
|  |  server { | ||||||
|  |      listen 443 ssl; | ||||||
|  |      server_name cal.DOMAIN; | ||||||
|  |     ssl_certificate /etc/letsencrypt/live/cal.DOMAIN/fullchain.pem; # managed by Certbot | ||||||
|  |     ssl_certificate_key /etc/letsencrypt/live/cal.DOMAIN/privkey.pem; # managed by Certbot | ||||||
|  |                                                                                          | ||||||
|  |      location / { | ||||||
|  |          proxy_pass http://localhost:5232; | ||||||
|  |          proxy_set_header Host $host; | ||||||
|  |          proxy_set_header X-Real-IP $remote_addr; | ||||||
|  |          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||||||
|  |      } | ||||||
|  |   | ||||||
|  | } | ||||||
|  | ' > /etc/nginx/sites-available/radicale | ||||||
|  | sudo ln -s /etc/nginx/sites-available/radicale /etc/nginx/sites-enables/ | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Finally, replace the example `DOMAIN` with your actual domain name. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | DOMAIN=whatever.com | ||||||
|  | sudo sed -i "s/DOMAIN/$DOMAIN/g" /etc/nginx/sites-available/radicale  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | (optional: replace that `cal.` prefix with anything else) | ||||||
|  |  | ||||||
|  | Check nginx is happy: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo nginx -t | ||||||
|  | ``` | ||||||
|  | You will almost certainly need a new SSL certificate for the site: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo certbod -d cal.$DOMAIN | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Start or restart both services: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo systemctl start radicale | ||||||
|  | sudo systemctl restart nginx | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You should now be able to log into your calendar, and add it to a phone. | ||||||
|  |  | ||||||
|  | **NB:** you don't need the port number. | ||||||
| @@ -1,33 +1,47 @@ | |||||||
| --- | --- | ||||||
| title: "sc-im" | title: "sc-im" | ||||||
| tags: [ "Documentation", "data" ] | tags: [ "Documentation", "TUI", "data" ] | ||||||
| --- | --- | ||||||
|  |  | ||||||
|  | - [Sample file](sc-im/sample.sc) | ||||||
|  |  | ||||||
| # Basic Commands | # Basic Commands | ||||||
|  |  | ||||||
| > H = highest part | ## See Cells | ||||||
| > L = lowest part |  | ||||||
| > gg = top |  | ||||||
|  |  | ||||||
| > g$ = most right. | Cells are hard to see. | ||||||
| > g0 = most left. | Change this with `:set autowrap`. | ||||||
|  |  | ||||||
| > \ = insert middle | Make `sc-im` always autowrap: | ||||||
| > \> = insert left |  | ||||||
| > < = insert right |  | ||||||
|  |  | ||||||
| gb4 = to to cell b4 | ```bash | ||||||
|  | mkdir .config/sc-im/bash | ||||||
|  | echo 'set autowrap' >> .config/sc-im/scimrc | ||||||
|  | ``` | ||||||
|  |  | ||||||
| > aa = see all text in cells | ## Movement | ||||||
| > f = format cells so you can see it. |  | ||||||
| > fl = format wider right |  | ||||||
| > fh = format smaller left |  | ||||||
|  |  | ||||||
| > fj = format wider down | | Command                             | Key | | ||||||
| > fk = format smaller down | |:------------------------------------|:---:| | ||||||
|  | | highest part                        | H   | | ||||||
|  | | lowest part                         | L   | | ||||||
|  | | top                                 | gg  | | ||||||
|  | | most right.                         | g$  | | ||||||
|  | | most left.                          | g0  | | ||||||
|  | | insert middle                       | \   | | ||||||
|  | | insert left                         | \>  | | ||||||
|  | | insert right                        | <   | | ||||||
|  | | to to cell b4                       | gb4 | | ||||||
|  | | see all text in cells               | aa  | | ||||||
|  | | format cells so you can see it.     | f   | | ||||||
|  | | format wider right                  | fl  | | ||||||
|  | | format smaller left                 | fh  | | ||||||
|  | | format wider down                   | fj  | | ||||||
|  | | format smaller down                 | fk  | | ||||||
|  |  | ||||||
| # Edit | ## Edit | ||||||
|  |  | ||||||
| ## Text | ### Text | ||||||
|  |  | ||||||
| | Action                | Key | | | Action                | Key | | ||||||
| |:----------------------|:---:| | |:----------------------|:---:| | ||||||
| @@ -35,7 +49,7 @@ gb4 = to to cell b4 | |||||||
| | text (right align)    | >   | | | text (right align)    | >   | | ||||||
| | Edit existing  text   | E   | | | Edit existing  text   | E   | | ||||||
|  |  | ||||||
| ## Meta Actions | ### Meta Actions | ||||||
|  |  | ||||||
| | Action                | Key | | | Action                | Key | | ||||||
| |:----------------------|:---:| | |:----------------------|:---:| | ||||||
| @@ -48,7 +62,7 @@ gb4 = to to cell b4 | |||||||
| |  delete a cell        | x   | | |  delete a cell        | x   | | ||||||
|  |  | ||||||
|  |  | ||||||
| ## Functions | ### Functions | ||||||
|  |  | ||||||
| | Action                          | Key          | | | Action                          | Key          | | ||||||
| |:--------------------------------|:------------:| | |:--------------------------------|:------------:| | ||||||
| @@ -58,7 +72,7 @@ gb4 = to to cell b4 | |||||||
| |  minimumof those numbers        | =@min(B1:B8) | | |  minimumof those numbers        | =@min(B1:B8) | | ||||||
| |  multiply C1 to C8              | =@prod(C1:C8)| | |  multiply C1 to C8              | =@prod(C1:C8)| | ||||||
|  |  | ||||||
| ## Visual | ### Visual | ||||||
|  |  | ||||||
| | Action                          | Key          | | | Action                          | Key          | | ||||||
| |:--------------------------------|:------------:| | |:--------------------------------|:------------:| | ||||||
|   | |||||||
							
								
								
									
										38
									
								
								data/sc-im/sample.sc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								data/sc-im/sample.sc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,38 @@ | |||||||
|  | # This data file was generated by the Spreadsheet Calculator Improvised (sc-im) | ||||||
|  | # You almost certainly shouldn't edit it. | ||||||
|  |  | ||||||
|  | newsheet "Sheet1" | ||||||
|  | movetosheet "Sheet1" | ||||||
|  | offscr_sc_cols 0 | ||||||
|  | offscr_sc_rows 0 | ||||||
|  | nb_frozen_rows 1 | ||||||
|  | nb_frozen_cols 0 | ||||||
|  | nb_frozen_screenrows 2 | ||||||
|  | nb_frozen_screencols 0 | ||||||
|  | format A 14 1 0 | ||||||
|  | format B 18 2 0 | ||||||
|  | format 0 2 | ||||||
|  | freeze 0 | ||||||
|  | label A0 = "Food by Weight" | ||||||
|  | leftstring B0 = "No. Meals" | ||||||
|  | leftstring A1 = "Ajvar" | ||||||
|  | let A1 = 5 | ||||||
|  | let B1 = A1*$A$10 | ||||||
|  | leftstring A2 = "Apples" | ||||||
|  | let A2 = 3 | ||||||
|  | let B2 = A2*$A$10 | ||||||
|  | leftstring A3 = "Rocket" | ||||||
|  | let A3 = 0.2 | ||||||
|  | let B3 = A3*$A$10 | ||||||
|  | leftstring A4 = "Beli Cheese" | ||||||
|  | let A4 = 1 | ||||||
|  | let B4 = A4*$A$10 | ||||||
|  | leftstring A6 = "Total" | ||||||
|  | let A6 = @sum(A1:A4) | ||||||
|  | leftstring B6 = "Total" | ||||||
|  | let B6 = @sum(B1:B4) | ||||||
|  | leftstring A7 = "Average" | ||||||
|  | let A7 = @avg(A1:A4) | ||||||
|  | leftstring A10 = "Weight of Meal" | ||||||
|  | let A10 = 0.3 | ||||||
|  | goto A0 | ||||||
							
								
								
									
										23
									
								
								data/sharing_secrets.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								data/sharing_secrets.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | --- | ||||||
|  | title: "Sharing Secrets" | ||||||
|  | tags: [ "data", "death", "secrets", "ssss" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | You can share parts of a secret with multiple people, so only some of them need to agree to see the secret. | ||||||
|  |  | ||||||
|  | Install `ssss`, then decide on the total number of secrets (`N`), and the threshold of people who must share their shard of the secret in order to reveal the secret. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | N=5 | ||||||
|  | T=3 | ||||||
|  | FILE=secret.txt | ||||||
|  | fortune | ssss-split -t $T -n $N > $FILE | ||||||
|  | ``` | ||||||
|  | Each shard is a line inside secret.txt. | ||||||
|  |  | ||||||
|  | Check it's working: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | head -n $T $FILE | ssss-combine -t $T | ||||||
|  | tail -n $T $FILE | ssss-combine -t $T | ||||||
|  | ``` | ||||||
							
								
								
									
										69
									
								
								data/soft_https.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								data/soft_https.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,69 @@ | |||||||
|  | --- | ||||||
|  | title: "Soft Serve through https" | ||||||
|  | tags: [ "data", "git" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## `http` Setup | ||||||
|  |  | ||||||
|  | In this example, the port used is `23231`, but it can be anything. | ||||||
|  | Open `/var/lib/soft-serve/data/config.yaml` and make sure the `http` section looks like this: | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | # The HTTP server configuration. | ||||||
|  | http: | ||||||
|  |   # The address on which the HTTP server will listen. | ||||||
|  |   listen_addr: ":23232" | ||||||
|  |  | ||||||
|  |   # The path to the TLS private key. | ||||||
|  |   tls_key_path: "" | ||||||
|  |  | ||||||
|  |   # The path to the TLS certificate. | ||||||
|  |   tls_cert_path: "" | ||||||
|  |  | ||||||
|  |   # The public URL of the HTTP server. | ||||||
|  |   # This is the address that will be used to clone repositories. | ||||||
|  |   # Make sure to use https:// if you are using TLS. | ||||||
|  |   public_url: "http://localhost:23232" | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Restart the `soft-serve` service, then check it's working by cloning from localhost: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | git clone http://localhost:23232/${some_repo}.git | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ## `https` Setup | ||||||
|  |  | ||||||
|  | Put this file at `/etc/nginx/sites-enabled/$DOMAIN.tld`, then set up standard certificates with [nginx](../networking/website/nginx.md). | ||||||
|  |  | ||||||
|  | (replace `${DOMAIN_NAME}` with your domain's name). | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  |  server { | ||||||
|  |      listen 80; | ||||||
|  |      server_name ${DOMAIN_NAME}; | ||||||
|  |                                                                                          | ||||||
|  |      location / { | ||||||
|  |          proxy_pass http://localhost:23232; | ||||||
|  |          proxy_set_header Host $host; | ||||||
|  |          proxy_set_header X-Real-IP $remote_addr; | ||||||
|  |          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||||||
|  |      } | ||||||
|  |                                                                                          | ||||||
|  |      return 301 https://$server_name$request_uri; | ||||||
|  | } | ||||||
|  |                                                                                          | ||||||
|  |  server { | ||||||
|  |      listen 443 ssl; | ||||||
|  |      server_name ${DOMAIN_NAME}; | ||||||
|  |  | ||||||
|  |      location / { | ||||||
|  |          proxy_pass http://localhost:23232; | ||||||
|  |          proxy_set_header Host $host; | ||||||
|  |          proxy_set_header X-Real-IP $remote_addr; | ||||||
|  |          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||||||
|  |      } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | ``` | ||||||
							
								
								
									
										21
									
								
								data/sqlite.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								data/sqlite.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | --- | ||||||
|  | title: "sqlite" | ||||||
|  | tags: [ "Documentation", "data" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Work with a database: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sqlite3 "$FILE".sqlite3 | ||||||
|  | ``` | ||||||
|  | Compress the database: | ||||||
|  |  | ||||||
|  | ```sqlite | ||||||
|  | pragma vacuum; | ||||||
|  | ``` | ||||||
|  | Optimize the database: | ||||||
|  |  | ||||||
|  | ```sqlite | ||||||
|  | pragma optimize; | ||||||
|  | ``` | ||||||
|  |  | ||||||
| @@ -1,57 +0,0 @@ | |||||||
| #!/bin/bash |  | ||||||
|  |  | ||||||
| # https://www.unixmen.com/install-arch-linux-raspberry-pi/ |  | ||||||
|  |  | ||||||
| pacman-key --init || echo init fail >> log |  | ||||||
| pacman-key --populate archlinuxarm || echo update fail >> log |  | ||||||
| pacman -Syyuu || echo update fail  >> log |  | ||||||
|  |  | ||||||
| sed -i s/#en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/ /etc/locale.gen |  | ||||||
|  |  | ||||||
| echo 'LANG=en_GB.UTF-8' >> /etc/locale.conf |  | ||||||
|  |  | ||||||
| locale-gen |  | ||||||
|  |  | ||||||
| pacman -S base-devel htop ranger tmux lolcat fortune-mod git figlet rxvt-unicode task timew calcurse fail2ban |  | ||||||
| # texlive-most  |  | ||||||
| if [[ $2 == all || $1 == all ]]; then |  | ||||||
| 	pacman -S nnn feh dmenu rofi xf86-video-fbdev xorg xorg-xinit xorg-server xorg-server-utils xterm |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Audio |  | ||||||
| echo 'dtparam=audio=on' >> /boot/config.txt |  | ||||||
|  |  | ||||||
| if [[ $1 == audio ]]; then |  | ||||||
| 	pacman -S alsa-utils alsa-firmware alsa-lib alsa-plugins  |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| echo 'device_tree_param=spi=on' >> /boot/config.txt |  | ||||||
|  |  | ||||||
| # for a vnc viewer |  | ||||||
| if [[ $1 == vnc ]]; then |  | ||||||
| 	tigervnc gcc geany i3 i3status compton feh sxiv rxvt-unicode  |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| # Swap |  | ||||||
|  |  | ||||||
| cd /var/cache/swap |  | ||||||
|  |  | ||||||
| dd if=/dev/zero of=swapfile bs=1K count=2M |  | ||||||
|  |  | ||||||
| chmod 600 swapfile |  | ||||||
|  |  | ||||||
| mkswap swapfile |  | ||||||
|  |  | ||||||
| swapon swapfile |  | ||||||
|  |  | ||||||
| echo "/var/cache/swap/swapfile none swap sw 0 0" > /etc/fstab |  | ||||||
|  |  | ||||||
| # fail2ban |  | ||||||
|  |  | ||||||
| [ -e sshd.local ] && \ |  | ||||||
| pacman -S fail2ban && \ |  | ||||||
| mv sshd.local /etc/fail2ban/jail.d && \ |  | ||||||
| systemctl start fail2ban |  | ||||||
|  |  | ||||||
| # If it won't reboot, install `arch-install-scripts` then try again and firstly: |  | ||||||
| # genfstab / > /etc/fstab |  | ||||||
| @@ -1,9 +0,0 @@ | |||||||
| #!/bin/sh |  | ||||||
| pacman -S gitea postgresql |  | ||||||
| sudo su postgres -c 'initdb -D /var/lib/postgres/data' |  | ||||||
| sudo systemctl start postgresql |  | ||||||
| sudo su postgres -c 'createuser -P gitea' |  | ||||||
| sudo su postgres -c 'createdb -O gitea gitea' |  | ||||||
| sudo sed -i 's/mysql/postgres/' /etc/gitea/app.ini |  | ||||||
| sudo sed -i 's/root/gitea/' /etc/gitea/app.ini |  | ||||||
| sudo systemctl start gitea |  | ||||||
| @@ -1,79 +0,0 @@ | |||||||
| #!/bin/bash |  | ||||||
|  |  | ||||||
| set -e |  | ||||||
|  |  | ||||||
| yay -S pi-hole-ftl pi-hole-server |  | ||||||
|  |  | ||||||
| # Configuration in /etc/pihole/pihole-FTL.db |  | ||||||
| # You can change DBINTERVAL to 60 or more to limit writes to disk |  | ||||||
|  |  | ||||||
| sudo systemctl disable --now systemd-resolved |  | ||||||
| sudo systemctl enable --now pihole-FTL |  | ||||||
| pihole -g |  | ||||||
| pihole -c |  | ||||||
|  |  | ||||||
| if [ "$1" == "unbound" ]; then |  | ||||||
|  |  | ||||||
| sudo pacman -S unbound |  | ||||||
|  |  | ||||||
| sudo cp /etc/unbound/unbound.conf /etc/unbound/unbound.conf.old |  | ||||||
|  |  | ||||||
| echo "server: |  | ||||||
|     # If no logfile is specified, syslog is used |  | ||||||
|     # logfile: "/var/log/unbound/unbound.log" |  | ||||||
|     verbosity: 0 |  | ||||||
|  |  | ||||||
|     interface: 127.0.0.1 |  | ||||||
|     port: 5335 |  | ||||||
|     do-ip4: yes |  | ||||||
|     do-udp: yes |  | ||||||
|     do-tcp: yes |  | ||||||
|  |  | ||||||
|     # May be set to yes if you have IPv6 connectivity |  | ||||||
|     do-ip6: no |  | ||||||
|  |  | ||||||
|     # You want to leave this to no unless you have *native* IPv6. With 6to4 and |  | ||||||
|     # Terredo tunnels your web browser should favor IPv4 for the same reasons |  | ||||||
|     prefer-ip6: no |  | ||||||
|  |  | ||||||
|     # Use this only when you downloaded the list of primary root servers! |  | ||||||
|     # If you use the default dns-root-data package, unbound will find it automatically |  | ||||||
|     #root-hints: "/var/lib/unbound/root.hints" |  | ||||||
|  |  | ||||||
|     # Trust glue only if it is within the server's authority |  | ||||||
|     harden-glue: yes |  | ||||||
|  |  | ||||||
|     # Require DNSSEC data for trust-anchored zones, if such data is absent, the zone becomes BOGUS |  | ||||||
|     harden-dnssec-stripped: yes |  | ||||||
|  |  | ||||||
|     # Don't use Capitalization randomization as it known to cause DNSSEC issues sometimes |  | ||||||
|     # see https://discourse.pi-hole.net/t/unbound-stubby-or-dnscrypt-proxy/9378 for further details |  | ||||||
|     use-caps-for-id: no |  | ||||||
|  |  | ||||||
|     # Reduce EDNS reassembly buffer size. |  | ||||||
|     # Suggested by the unbound man page to reduce fragmentation reassembly problems |  | ||||||
|     edns-buffer-size: 1472 |  | ||||||
|  |  | ||||||
|     # Perform prefetching of close to expired message cache entries |  | ||||||
|     # This only applies to domains that have been frequently queried |  | ||||||
|     prefetch: yes |  | ||||||
|  |  | ||||||
|     # One thread should be sufficient, can be increased on beefy machines. In reality for most users running on small networks or on a single machine, it should be unnecessary to seek performance enhancement by increasing num-threads above 1. |  | ||||||
|     num-threads: 1 |  | ||||||
|  |  | ||||||
|     # Ensure kernel buffer is large enough to not lose messages in traffic spikes |  | ||||||
|     so-rcvbuf: 1m |  | ||||||
|  |  | ||||||
|     # Ensure privacy of local IP ranges |  | ||||||
|     private-address: 192.168.0.0/16 |  | ||||||
|     private-address: 169.254.0.0/16 |  | ||||||
|     private-address: 172.16.0.0/12 |  | ||||||
|     private-address: 10.0.0.0/8 |  | ||||||
|     private-address: fd00::/8 |  | ||||||
|     private-address: fe80::/10 |  | ||||||
| " | sudo   tee /etc/unbound.conf |  | ||||||
|  |  | ||||||
| 	echo "Make this the  only pihole DNS: PIHOLE_DNS_1=127.0.0.1 in /etc/pihole/setupVars.conf" |  | ||||||
|  |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| @@ -1,8 +0,0 @@ | |||||||
| #!/bin/bash |  | ||||||
|  |  | ||||||
| flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo |  | ||||||
|  |  | ||||||
| flatpak --user install flathub com.valvesoftware.Steam |  | ||||||
|  |  | ||||||
| flatpak run com.valvesoftware.Steam |  | ||||||
|  |  | ||||||
| @@ -1,10 +0,0 @@ | |||||||
| git clone https://aur.archlinux.org/yay.git |  | ||||||
|  |  | ||||||
| cd yay |  | ||||||
|  |  | ||||||
| makepkg -si |  | ||||||
|  |  | ||||||
| yay -S perl-graph-easy signal-desktop sc-im ncpamixer xdg-utils-mimeo torrench |  | ||||||
|  |  | ||||||
| yay -S ttf-tengwar-annatar |  | ||||||
|  |  | ||||||
							
								
								
									
										33
									
								
								distros/void/Brand_Name_Wallpaper.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								distros/void/Brand_Name_Wallpaper.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | |||||||
|  | --- | ||||||
|  | title: "Brand Name Wallpaper" | ||||||
|  | tags: [ "void" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | To automatically stick the logo onto your background, do these commands in the directory. | ||||||
|  |  | ||||||
|  | Get the void linux logo from wikipedia | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | wget https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Void_Linux_logo.svg/256px-Void_Linux_logo.svg.png?20170131170632 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Rename it, and resize it (the standard size is too small for most wallpapers) | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | convert -resize 200% '256px-Void_Linux_logo.svg.png?20170131170632' void-logo.png | ||||||
|  | ``` | ||||||
|  | Download a pretty wallpaper | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | wget http://wallpapercave.com/wp/Wlm9Gv0.jpg | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Put the void logo on all *jpg and *png images | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | for x in *.jpg | ||||||
|  | 	do | ||||||
|  | 	composite -compose multiply -gravity Center void-logo.png "$x" "$x" | ||||||
|  | done | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										54
									
								
								distros/void/locale.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								distros/void/locale.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | |||||||
|  | --- | ||||||
|  | title: "Void locale" | ||||||
|  | tags: [ "void", "locale" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Check the current locales: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | locale -a | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Add the languages you want by editing `/etc/default/libc-locales`, and uncommenting your choice: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | #en_DK.UTF-8 UTF-8   | ||||||
|  | #en_DK ISO-8859-1   | ||||||
|  | en_GB.UTF-8 UTF-8   | ||||||
|  | en_GB ISO-8859-1   | ||||||
|  | #en_HK.UTF-8 UTF-8   | ||||||
|  | #en_HK ISO-8859-1   | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Now you can generate what you need for those languages. | ||||||
|  | However, instead of generating what you need, you're going to generate everything which needs updating: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo xbps-reconfigure glibc-locales | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Finally, select your chosen locale by placing it in `/etc/locale.conf`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | echo "LC_ALL=en_GB.UTF-8 | ||||||
|  | LANG=en_GB.UTF-8 | ||||||
|  | LANGUAGE=en_GB.UTF-8" > /etc/locale.conf | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #en_DK.UTF-8 UTF-8   | ||||||
|  | #en_DK ISO-8859-1   | ||||||
|  | en_GB.UTF-8 UTF-8   | ||||||
|  | en_GB ISO-8859-1   | ||||||
|  | #en_HK.UTF-8 UTF-8   | ||||||
|  | #en_HK ISO-8859-1   | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Check your new locales are available: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | locale -a | ||||||
|  | ``` | ||||||
|  |  | ||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| title: "graph-easy" | title: "Easy Network Graph" | ||||||
| tags: [ "Documentation" ] | tags: [ "Documentation", "Networking" ] | ||||||
| --- | --- | ||||||
| Set up a file like this, called `troubleshooting.txt`. | Set up a file like this, called `troubleshooting.txt`. | ||||||
|  |  | ||||||
| @@ -39,7 +39,7 @@ Try placing this in a file: | |||||||
|  |  | ||||||
| > [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; } | > [ One ] { fill: seagreen; color: white; } -- label --> [ Two ] { shape: triangle; } | ||||||
| >  | >  | ||||||
| > [ One ] => { arrow-style: closed; } [ Three ] | > [ One ] => { arrow-style: closed; } [ Three ] { border-style: none; } | ||||||
| >  | >  | ||||||
| > [ Five ] { fill: maroon; color: yellow; } <=> [ Three ] | > [ Five ] { fill: maroon; color: yellow; } <=> [ Three ] | ||||||
| >  | >  | ||||||
| @@ -54,3 +54,15 @@ Try placing this in a file: | |||||||
| > [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; } | > [ Eight ] .. [ None ] { shape: none; fill: red; color: brown; } | ||||||
| >  | >  | ||||||
| > [ no Network ] --> [ Is there an IP address? ] | > [ no Network ] --> [ Is there an IP address? ] | ||||||
|  |  | ||||||
|  | > [ Little Group: o] | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | echo "( EU [ Madrid ] <---> [ K ] {label: Karlsruhe;} | ||||||
|  |     <== ...O\n ..o\n .O\no \nchoo choo  ==> [ Cern ] [ Cern ] <== ...O\n ..o\n .O\no \nchoo choo  ==> [ Paris ] <...> [ B ] {label: Budapest} ) | ||||||
|  |     [ B ] <---> [ Belgrade ] [ G ] {label: Glasgow; } | ||||||
|  |     <==> [ M ] {label: Manchester }, | ||||||
|  |     [ Madrid ] <---> [ Belgrade ] [ M ] <--> [ London ] <--> [ B ], | ||||||
|  |         [ Belgrade ]" | graph-easy  --boxart | ||||||
|  | ``` | ||||||
|   | |||||||
| @@ -1,27 +0,0 @@ | |||||||
| --- |  | ||||||
| title: "pip" |  | ||||||
| tags: [ "Documentation", "Networking" ] |  | ||||||
| --- |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Searching does not work. |  | ||||||
|  |  | ||||||
| Install with: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| pip install [ package ] |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Upgrade all packages |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| # Troubleshooting |  | ||||||
|  |  | ||||||
| You may need a python3 package. |  | ||||||
| In this case, try: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| pip3 install [ package ] |  | ||||||
							
								
								
									
										89
									
								
								networking/ssh.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								networking/ssh.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,89 @@ | |||||||
|  | --- | ||||||
|  | title: "ssh" | ||||||
|  | tags: [ "networking" ] | ||||||
|  | --- | ||||||
|  | # Basic `ssh` | ||||||
|  |  | ||||||
|  | Try out basic ssh by accessing `git.charm.sh`, without needing authentication: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ssh git.charm.sh | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Start an ssh server to try it out. | ||||||
|  | The ssh server is sometimes in a package called `openssh`, and sometimes only in `openssh-server`. | ||||||
|  |  | ||||||
|  | Once it's installed, check it's working: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo systemctl status ssh | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | If that doesn't work, the service may be called `sshd`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo systemctl status sshd | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Then start that service: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sudo systemctl start sshd | ||||||
|  | ``` | ||||||
|  | Test it works by using ssh into your own system, from inside: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ssh $USER@localhost | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Access the computer from another computer on the same local network by finding your computer's IP address. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ip address | grep inet | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Here is mine: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | > inet 127.0.0.1/8 scope host lo | ||||||
|  | >  | ||||||
|  | > inet6 ::1/128 scope host noprefixroute | ||||||
|  | >  | ||||||
|  | > inet 192.168.0.12/24 brd 192.168.0.255 scope global dynamic noprefixroute en | ||||||
|  |  | ||||||
|  |  | ||||||
|  | The first one starts `127`, which means it returns back to that computer (like `localhost`). | ||||||
|  | The second is an ipv6 address, which is too angelic for this world, and has yet to ascend. | ||||||
|  | The third will work from a remote computer. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ssh $USERNAME@IP_ADDRESS | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Once you have that, generate some ssh keys: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ssh-keygen | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Look at your keys: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls ~/.ssh | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | You can share the one ending in `.pub` freely. | ||||||
|  | The other is secret. | ||||||
|  |  | ||||||
|  | Now send those keys to a remote computer: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ssh-copy-id $USERNAME@IP_ADDRESS | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Now you can log in without a password. | ||||||
| @@ -83,7 +83,7 @@ If the file is in your home - `~` - but `transmission` is not allowed in your ho | |||||||
| Next, find the torrent's number.  You can use multiple numbers, separated with a comma: | Next, find the torrent's number.  You can use multiple numbers, separated with a comma: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| transmission-remote -t 3,5,8 --move /home/alice/music | transmission-remote -t 3,5,8 --move $HOME/music | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Change Default Location | ## Change Default Location | ||||||
| @@ -136,3 +136,32 @@ Without the `--anonymize` flag, the torrent file output will have a 'created by' | |||||||
| - udp://explodie.org:6969/announce | - udp://explodie.org:6969/announce | ||||||
| - https://tracker.gbitt.info:443/announce | - https://tracker.gbitt.info:443/announce | ||||||
| - http://tracker.gbitt.info:80/announce | - http://tracker.gbitt.info:80/announce | ||||||
|  |  | ||||||
|  | ## Verify | ||||||
|  |  | ||||||
|  | Add your torrent and notes its number: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | transmission-remote -a "$file".torrent | ||||||
|  | transmission-remote -l | ||||||
|  | transmission-remote -t "$number" -i | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The information in the last command shows that it's not verified, so you can verify with `-v`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | transmission-remote -t "$number" -v | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | If transmission cannot find it, then tell it where to find the torrent: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | transmission-remote -t "$number" --find "$(pwd)" | ||||||
|  | ``` | ||||||
|  | ...and of course, make sure the permissions allow transmission to see the target. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | ls -ld "$file" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -93,7 +93,9 @@ apt install python3-certbot-nginx | |||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| certbot --nginx -d *mysite.tk* --non-interactive --agree-tos -m *webmaster@email.tld* | domain=example.com | ||||||
|  | my_email=me@posteo.uk | ||||||
|  | certbot --nginx -d "$domain" --non-interactive --agree-tos -m "$my_email" | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| When you are asked about redirecting from HTTP to HTTPS, say yes (option "2"). | When you are asked about redirecting from HTTP to HTTPS, say yes (option "2"). | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								new.sh
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								new.sh
									
									
									
									
									
								
							| @@ -14,7 +14,7 @@ filePath="$category/$(echo $name | sed 's/ /_/g').md" | |||||||
|  |  | ||||||
| tagsList="$(echo \"$category | sed 's#\/#", "#g')\"" | tagsList="$(echo \"$category | sed 's#\/#", "#g')\"" | ||||||
|  |  | ||||||
| [ -e "$filePath" ] && $EDITOR $filePath && exit 0 | [ -e "$filePath" ] && $EDITOR "$filePath" && exit 0 | ||||||
|  |  | ||||||
| echo "--- | echo "--- | ||||||
| title: \"$name\" | title: \"$name\" | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| title: "Terminal Tips" | title: "bash tips" | ||||||
| tags: [ "Documentation", "System" ] | tags: [ "Documentation", "Shell", "POSIX" ] | ||||||
| --- | --- | ||||||
| ## Track Live Changes | ## Track Live Changes | ||||||
|  |  | ||||||
| @@ -12,6 +12,11 @@ See changes in a directory, as it changes: | |||||||
|  |  | ||||||
| `watch -d ls *directory*` | `watch -d ls *directory*` | ||||||
|  |  | ||||||
|  | Or use the `-g` flag to exit once the output changes. | ||||||
|  | This command will look at whether you're connected to the internet, and turn into a rainbow once the connection hits. | ||||||
|  |  | ||||||
|  | > watch -g ip address && clear && ip address | lolcat | ||||||
|  |  | ||||||
| ## Automatic Renaming | ## Automatic Renaming | ||||||
|  |  | ||||||
| There are a bunch of files: | There are a bunch of files: | ||||||
| @@ -34,17 +39,19 @@ done | |||||||
|  |  | ||||||
| IFS is the field separator.  This is required to denote the different files as marked by a new line, and not the spaces. | IFS is the field separator.  This is required to denote the different files as marked by a new line, and not the spaces. | ||||||
|  |  | ||||||
|  | (Alternatively, just install `renameutils` and do `rename Column Alice *`) | ||||||
|  |  | ||||||
| ## Arguments and Input | ## Arguments and Input | ||||||
|  |  | ||||||
| The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm. | The `rm' program takes arguments, but not `stdin' from a keyboard, and therefore programs cannot pipe results into rm. | ||||||
|  | To fix this, use `xargs` to turn the stdin into an argument. | ||||||
| That said, we can sometimes pipe into rm with `xargs rm' to turn the stdin into an argument.  For example, if we have a list of files called `list.txt' then we could use cat as so: | For example, if we have a list of files called `list.txt' then we could use cat as so: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| cat list.txt | xargs rm | cat list.txt | xargs rm | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ... *However*, this wouldn't work if spaces were included, as rm would take everything literally. | Of course if spaces are included in the file, you would have to account for that. | ||||||
|  |  | ||||||
| ## Numbers | ## Numbers | ||||||
|  |  | ||||||
| @@ -60,6 +67,18 @@ Add number to variables with: | |||||||
|  |  | ||||||
| `((n--))` works identically. | `((n--))` works identically. | ||||||
|  |  | ||||||
|  | ### POSIX WARNING | ||||||
|  |  | ||||||
|  | The number commands above work in `bash`, but not in bare-ass POSIX shells, such as `dash`. | ||||||
|  |  | ||||||
|  | Instead, you might do: | ||||||
|  |  | ||||||
|  | ```sh | ||||||
|  | x=2 | ||||||
|  | x=$(( x +1 )) | ||||||
|  | x=$(( x*x )) | ||||||
|  | ``` | ||||||
|  |  | ||||||
| ## Finding Duplicate Files | ## Finding Duplicate Files | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| @@ -71,3 +90,27 @@ find . -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 15 | |||||||
| ```bash | ```bash | ||||||
| cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo | cat /dev/urandom | tr -cd [:alnum:] | dd bs=1 count=200 status=none && echo | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
|  | ## Temporary Working Directory | ||||||
|  |  | ||||||
|  | Try something out in a random directory in `/tmp` so the files will be deleted when you next shut down. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | mktemp -d | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | That gives you a random directory to mess about in. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  |    dir=$(mktemp -d) | ||||||
|  |    for x in {A..Z}; do | ||||||
|  |       fortune > "$dir"/chimpan-$x | ||||||
|  |    done | ||||||
|  |    cd $dir | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | ### POSIX WARNING | ||||||
|  |  | ||||||
|  | These smart-brackets are a bash feature. | ||||||
|  | If you try to use `{A..Z}` in dash, it will think of this as a single item. | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								system/cron.md
									
									
									
									
									
										Symbolic link
									
								
							
							
						
						
									
										1
									
								
								system/cron.md
									
									
									
									
									
										Symbolic link
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | ../basics/cron.md | ||||||
							
								
								
									
										19
									
								
								system/deduplicate.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								system/deduplicate.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | --- | ||||||
|  | title: "deduplicate" | ||||||
|  | tags: [ "system", "deduplicate", "duplicates", "maintenance" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | `rdfind`: find duplicate files, then delete them, or turn them into links. | ||||||
|  |  | ||||||
|  | Ask if a directory has duplicates (`rdfind` will not delete anything): | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | rdfind $dir | ||||||
|  | $EDITOR results.txt | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Replace the duplicated files with [hard links](../basics/hard_links.md). | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | rdfind -makehardlinks true $dir | ||||||
|  | ``` | ||||||
| @@ -13,11 +13,14 @@ The ordering of `/etc/fstab` is | |||||||
| 5. dump | 5. dump | ||||||
| 6. pass | 6. pass | ||||||
|  |  | ||||||
| E.g.: |  | ||||||
|  |  | ||||||
| > UUID=877f14e8-4738-46b0-884f-ba330dad1a7d       /mnt/biggie                     ext4        nofail,rw,relatime      0 2 | *Example:* | ||||||
| >  |  | ||||||
| > UUID=B21648C416488AF5 /mnt/share ntfs       nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0 | ``` | ||||||
|  | UUID=877f14e8-4738-46b0-884f-ba330dad1a7d       /mnt/biggie                     ext4        nofail,rw,relatime      0 2 | ||||||
|  |  | ||||||
|  | UUID=B21648C416488AF5 /mnt/share ntfs       nofail,rw,nosuid,nodev,user_id=0,group_id=0,allow_other,blksize=4096 0 0 | ||||||
|  | ``` | ||||||
|  |  | ||||||
| ## 5: Dump | ## 5: Dump | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										75
									
								
								system/lf.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								system/lf.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,75 @@ | |||||||
|  | --- | ||||||
|  | title: "lf - The Light File Manager" | ||||||
|  | tags: [ "Documentation", "File Browser" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | ## Config File | ||||||
|  |  | ||||||
|  | If you don't have a `~/.config/lf/lfrc` file, you can probably find an example in `/usr/share/examples/lf`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cp -r /usr/share/examples/lf ~/.config/ | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Go straight to root with two keys. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | map g/ cd / | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Have lf open a file with the default program when you press 'o', using the program `mimeo`. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | map o &mimeo $f | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Change that default text editor to look at the extension first. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cmd open ${{ | ||||||
|  |     case $(file --mime-type $f -b) in | ||||||
|  |         application/x-sc) sc-im $fx;; | ||||||
|  |         text/html) w3m $fx;; | ||||||
|  |         text/*) $EDITOR $fx;; | ||||||
|  |         video/*) nohup mpv $fx --really-quiet >/dev/null &;; | ||||||
|  |         *) nohup $OPENER $fx >/dev/null &;; | ||||||
|  |     esac | ||||||
|  | }} | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | The idea here is to use the default `$OPENER` for lf, but first check extensions. | ||||||
|  | Note the extra `mpv` commands to leave the video to play, without blocking the terminal. | ||||||
|  |  | ||||||
|  | ### Interesting Options | ||||||
|  |  | ||||||
|  | You can set the screen ratio with | ||||||
|  | `set ratios 1:2:3` | ||||||
|  |  | ||||||
|  | That leaves it as a small initial pane, a medium pane, and a large pane for file previews. | ||||||
|  |  | ||||||
|  | ### Rename | ||||||
|  |   | ||||||
|  | The standard renaming is bad, because you have to re-type the file extension. | ||||||
|  | Use this instead: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | # rename current file without overwrite | ||||||
|  | cmd rename %echo 'name: ' ; read name ; extension="${f##*.}" && newname="$name.$extension"; [ "$f" = "$extension" ] && newname="$name"; [ ! -e "$newname" ] && mv "$f" "$newname" || echo file exists | ||||||
|  | map r push :rename<enter> | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | If you try to rename `image_1.png` with this command, you can type in `cats`, and the result will be `cats.png`. | ||||||
|  |  | ||||||
|  | ## Image Previews | ||||||
|  |  | ||||||
|  | First, install `ueberzug` (to show images). | ||||||
|  | Then clone the lfrun repo. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | git clone https://github.com/cirala/lfimg.git | ||||||
|  |  | ||||||
|  | cd lfimg | ||||||
|  |  | ||||||
|  | sudo make install | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										29
									
								
								system/monitoring.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								system/monitoring.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | --- | ||||||
|  | title: "Monitoring" | ||||||
|  | tags: [ "Documentation", "System", "CPU", "Memory" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Print the average CPU load over 1 minute, 5 minutes, and 15 minutes: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | watch -d cat /proc/loadavg | ||||||
|  | stress="$(cat /proc/loadavg | awk '{print "Usage:" $2"%"}')" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Show memory usage in Gibitytes. | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | free -g | ||||||
|  | ``` | ||||||
|  | Show low and high gigibtye usage on a *l*ine, and repeat the measurement every 5 seconds: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | REP=5 | ||||||
|  | free --lohi -g -s $REP | lolcat | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Check the next thing cron will do: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | cronnext /var/spool/cron/$USER -l | ||||||
|  | ``` | ||||||
| @@ -2,6 +2,24 @@ | |||||||
| title: "journal" | title: "journal" | ||||||
| tags: [ "Documentation", "systemd" ] | tags: [ "Documentation", "systemd" ] | ||||||
| --- | --- | ||||||
|  |  | ||||||
|  | See a running log of all system messages: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | journalctl -f | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Or just one user: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | journalctl --user -f | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Or just one unit (`sshd`): | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | journalctl -f -u sshd | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| Find errors since November | Find errors since November | ||||||
| @@ -14,3 +32,13 @@ Limit size to 2G. | |||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| journalctl --vacuum-size=2G | journalctl --vacuum-size=2G | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Log the fact that you've installed your own `dnsmasq` on your system to `journalctl`, so that you can notice why your system's broken: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | logger "Installed new dnsmasq" | ||||||
|  | sudo journalctl -f | ||||||
|  | ``` | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,77 +0,0 @@ | |||||||
| # Ubuntu |  | ||||||
| https://linuxconfig.org/vnc-server-on-ubuntu-18-04-bionic-beaver-linux |  | ||||||
|  |  | ||||||
|  |  | ||||||
| # On server |  | ||||||
|  |  | ||||||
| Enable remote desktop access. |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| sudo apt install vnc4server xfce4 xfce4-goodies |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Disable the vncserver desktop: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| vncserver -kill :1 |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Replace the config in ~/.vnc/xstartup with: |  | ||||||
|  |  | ||||||
| `#!/bin/bash` |  | ||||||
|  |  | ||||||
| `startxfce4 &` |  | ||||||
|  |  | ||||||
| # Arch |  | ||||||
|  |  | ||||||
| Install tigervnc, then run it to set a password: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| vncserver |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| You'll get a session number. |  | ||||||
|  |  | ||||||
| Shut it down with the 'kill' command and the session's number: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| vncserver -kill :1 |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| This will forward over port 5900+x where x is the session number.  For the first server, that's port 5901. |  | ||||||
|  |  | ||||||
| # Create a systemd service |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| sudo vim /etc/systemd/system/vncserver@:1.service |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Then enter: |  | ||||||
|  |  | ||||||
| > [Unit] |  | ||||||
| > Description=Remote desktop service (VNC) |  | ||||||
| > After=syslog.target network.target |  | ||||||
| >  |  | ||||||
| > [Service] |  | ||||||
| > Type=simple |  | ||||||
| > User=foo |  | ||||||
| > PAMName=login |  | ||||||
| > PIDFile=/home/%u/.vnc/%H%i.pid |  | ||||||
| > ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' |  | ||||||
| > ExecStart=/usr/bin/vncserver %i -geometry 1440x900 -alwaysshared -fg |  | ||||||
| > ExecStop=/usr/bin/vncserver -kill %i |  | ||||||
| >  |  | ||||||
| > [Install] |  | ||||||
| > WantedBy=multi-user.target |  | ||||||
|  |  | ||||||
| Then enable that service: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| sudo systemctl start vncserver@:1.service |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
							
								
								
									
										19
									
								
								vim/vim_in_bash.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								vim/vim_in_bash.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | --- | ||||||
|  | title: "vim in bash" | ||||||
|  | tags: [ "vim", "bash", "inputrc" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Put bash in vim mode! | ||||||
|  |  | ||||||
|  | Place the following in your `~/.inputrc`: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | set editing-mode vi | ||||||
|  | set show-mode-in-prompt on | ||||||
|  | set vi-ins-mode-string \1\e[33;32m\2[>]=\1\e[0m\2 | ||||||
|  | set vi-cmd-mode-string \1\e[33;1m\2[?]=\1\e[0m\2 | ||||||
|  |  | ||||||
|  | set keymap vi-insert | ||||||
|  | RETURN: "\e\n" | ||||||
|  | ``` | ||||||
|  |  | ||||||
							
								
								
									
										28
									
								
								vision/QR_Codes.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								vision/QR_Codes.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,28 @@ | |||||||
|  | --- | ||||||
|  | title: "QR Codes" | ||||||
|  | tags: [ "Documentation", "qrencode", "zbar" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Make a QR Code image: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o "$FILE".png | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Make a QR Coded message in the terminal: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | qrencode -t ansi "Hello World" | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Read a QR Code image: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | zbarimg $FILE | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | Show wifi QR code (only with Network Manager): | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | nmcli device wifi show-password | ||||||
|  | ``` | ||||||
| @@ -2,7 +2,6 @@ | |||||||
| title: "imagemagick" | title: "imagemagick" | ||||||
| tags: [ "Documentation", "Vision" ] | tags: [ "Documentation", "Vision" ] | ||||||
| --- | --- | ||||||
| [Source](http://lxlinux.com/imagemagick.html) |  | ||||||
|  |  | ||||||
| Convert jpg to png. | Convert jpg to png. | ||||||
|  |  | ||||||
| @@ -41,13 +40,13 @@ convert image.jpg -resize 25% output.jpg | |||||||
|  |  | ||||||
| # Trim images to border | # Trim images to border | ||||||
|  |  | ||||||
| This is generally used for transparrent images. | This is generally used for transparent images. | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| convert -trim image.png output.png | convert -trim image.png output.png | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| Make the white of an image transparrent. | Make the white of an image transparent. | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| convert -transparent white -fuzz 10% input.png output.png | convert -transparent white -fuzz 10% input.png output.png | ||||||
| @@ -101,7 +100,7 @@ See your installed fonts: | |||||||
| convert -list font | convert -list font | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| Make na image showing day of the week: | Make an image showing day of the week: | ||||||
|  |  | ||||||
| ```bash | ```bash | ||||||
| convert -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png | convert -fill blue -font Sauce-Code-Pro-Semibold-Nerd-Font-Complete-Mono -gravity center -pointsize 79 label:$(date +%A) day.png | ||||||
|   | |||||||
							
								
								
									
										29
									
								
								vision/lowdown.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								vision/lowdown.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,29 @@ | |||||||
|  | --- | ||||||
|  | title: "Markdown to PDF" | ||||||
|  | tags: [ "Documentation", "Markdown", "PDF", "Vision" ] | ||||||
|  | --- | ||||||
|  |  | ||||||
|  | Turn a markdown file into a pdf: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | *Example:* put [this Makefile](lowdown/example.txt) in a directory, rename it `Makefile`, then do: | ||||||
|  |  | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | make example | ||||||
|  | make | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | To give the document a title, put that title in the metadata: | ||||||
|  |  | ||||||
|  | ```bash | ||||||
|  | sed -i "1 i---" "$FILE".md | ||||||
|  | sed -i "1 ititle: $TITLE" "$FILE".md | ||||||
|  | sed -i "1 i---" "$FILE".md | ||||||
|  | lowdown -L "$FILE".md | ||||||
|  | lowdown -X title "$FILE".md | ||||||
|  | lowdown -stms "$FILE".md | pdfroff -itk -mspdf > "$FILE".pdf | ||||||
|  | ``` | ||||||
							
								
								
									
										36
									
								
								vision/lowdown/example.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								vision/lowdown/example.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | |||||||
|  | output: all | ||||||
|  |  | ||||||
|  | .PHONY: example | ||||||
|  | example: html/foot.html html/head.html | ||||||
|  | 	mkdir -p articles/ | ||||||
|  | 	fortune > articles/fort_1.md | ||||||
|  | 	fortune > articles/fort_2.md | ||||||
|  |  | ||||||
|  | HTML = $(patsubst articles/%.md,public/%.html,$(wildcard articles/*.md)) | ||||||
|  |  | ||||||
|  | $(HTML): public/ articles/ $(wildcard html/*) | ||||||
|  |  | ||||||
|  | html/head.html: | ||||||
|  | 	@mkdir $(@D) | ||||||
|  | 	echo '<head> Something about CSS probably </head>' > $@ | ||||||
|  | 	echo '<body>' >> $@ | ||||||
|  |  | ||||||
|  | html/foot.html: html/head.html | ||||||
|  | 	echo '</body>' >> $@ | ||||||
|  |  | ||||||
|  | public/%.html : articles/%.md | ||||||
|  | 	cat html/head.html > $@ | ||||||
|  | 	lowdown $< >> $@ | ||||||
|  | 	cat html/foot.html >> $@ | ||||||
|  |  | ||||||
|  | .PHONY: all | ||||||
|  | all : $(HTML) | ||||||
|  |  | ||||||
|  | articles/: | ||||||
|  | 	mkdir $@ | ||||||
|  |  | ||||||
|  | public/: | ||||||
|  | 	mkdir $@ | ||||||
|  |  | ||||||
|  | clean : | ||||||
|  | 	rm -rf public | ||||||
| @@ -1,17 +0,0 @@ | |||||||
| --- |  | ||||||
| title: "qrencode" |  | ||||||
| tags: [ "Documentation", "vision" ] |  | ||||||
| --- |  | ||||||
|  |  | ||||||
| Make a QR Code image: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| qrencode 'https://play.google.com/store/apps/details?id=org.briarproject.briar.android' -o qr_briar.png |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
| Make a QR Coded message in the terminal: |  | ||||||
|  |  | ||||||
| ```bash |  | ||||||
| qrencode -t ansi "Hello World" |  | ||||||
| ``` |  | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user