Toolbox
Table of Contents
Table of Contents
Hello
This is a Collection of Notes and Links
This is work in Progress, use at your own Risk
GNU/Linux
Debugging
System Informations:
- inxi
- a full featured system information script
Print system information:
$ uname -a
Network information with iproute2:
$ ip address
- Retrieve and process saved core dumps and metadata:
$ coredumpctl list foo
- VGA Controller:
$ lspci | grep VGA
Wayland
Show applications using Xwayland:
$ xlsclients
Gnome
Assumption: We don't use gnome repositories
- Stuck in "software catalog is being loaded"
$ killall gnome-software
$ rm -rf ~/.cache/gnome-software
- Deactivate Gnome "updates available"
$ settings set org.gnome.software download-updates false
- Find applications behind the desktop entry, linked meme types
$ grep "Name=Disk Usage" /usr/share/applications/*.desktop
Sway
GNOME Keyring integration
https://wiki.archlinux.org/index.php/GNOME/Keyring#PAM_method
in: /etc/pam.d/login
#%PAM-1.0 auth required pam_securetty.so auth requisite pam_nologin.so auth include system-local-login auth optional pam_gnome_keyring.so account include system-local-login session include system-local-login session optional pam_gnome_keyring.so auto_start
misc
circumflex ^ = asciicircum
Java apps, Dialog and Menu rendering
in: /etc/profile
export _JAVA_AWT_WM_NONREPARENTING=1
Debug
$ coredumpctl debug sway
bt full
yay
remove unneeded dependencies
$ yay -Yc
~/yay git rebuild
$ makepkg -si
Pacman
Pacman tools
- Pamac GUI for pacman:
https://gitlab.manjaro.org/applications/pamac
- Yet another Yogurt - An AUR Helper written in Go:
- This repository contains contributed scripts to pacman.
Maintenance
clear cache:
$pacman -Sc
remove orphans:
$sudo pacman -Rs $(pacman -Qqdt)
force refresh of all package lists and do system upgrade
$pacman -Syyu
- update mirror list with https://wiki.archlinux.org/index.php/Reflector
$sudo reflector --country France --country Germany --age 24 --latest 200 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
Remove unused flatpacks:
$flatpak uninstall --unused
Reduce journal logs:
$journalctl --vacuum-size=128M
limit log file size, in: /etc/systemd/journald.conf
SystemMaxUse=128M log file size
then:
$journalctl --verify
Firefox Video Acceleration
check current drivers
sha1sum /usr/lib/dri/* | sort
install drivers
- install extra/libva-mesa-driver
tests for drivers
check VA-API
vainfo
vainfo: VA-API version: 1.9 (libva 2.9.1) vainfo: Driver version: Mesa Gallium driver 20.2.1 for AMD KAVERI (DRM 2.50.0, 5.8.14-arch1-1, LLVM 10.0.1) vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointVLD VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileNone : VAEntrypointVideoProc
set up firefox
about:config
gfx.webrender.all | true | required |
media.ffmpeg.vaapi.enabled | true | required |
media.ffvpx.enabled | false | required |
Required if no AV1 support, see: https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Comparison_tables
media.ffmpeg.enabled | true | true to enables twitch/v.reddit to play w/o hw-acc. |
media.av1.enabled | false | needed for older GPUs, changes codec if available |
Python
Links
Python Notes
" list .append, .count, .index, .insert, .pop, .remove, .reverse, .sort " SUPPLIES = ['pens', 'staplers', 'flamethrower'] " don't for i in range(len(SUPPLIES)): print('indext' + str(i) + ' in supplies is: ' + supplies[i]) better: " for i, e in enumerate(SUPPLIES): print(f'index {i} in supplies is: {e}') print('-------------------') print(list(enumerate(SUPPLIES))) print('-------------------') for num, name in enumerate(SUPPLIES): print(num, name) print('-------------------') print(SUPPLIES.index('pens'))
" Unpacking, * everything / *_ ignores the rest " a, b, *c, d = (1, 2, 3, 4, 5, 6, 7) print(a) print(b) print(c) print(d)
KEYANDVALUE = { 'heaven:'blue, 'fire:'red} for key, value in KEYANDVALUE.items(): print(f'key {key} has value {value}')
print('hello')
-list slicing https://github.com/ostwalprasad/PythonListSlicingCheatsheet
Lisp
(print "hello")
Web
CSS
- auto grid
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); grid-gap: 1rem; } #fallback .auto-grid > * { max-width: 25rem; margin-left: auto; margin-right: auto; } .auto-grid > * + * { margin-top: 1rem; } #revert for grid supported @supports (display: grid) { .auto-grid > * { max-width: unset; margin: 0 } }
Flask
if:
OSError: [Errno 98] Address already in use
ps -fA | grep python
kill -9 pid
Quart is a Python ASGI web microframework
sudo pip install flask
setup debug flask server in virtual environment:
$virtualenv venv
$source venv/bin/activate
$export FLASK_DEBUG=1
$flask run
Hugo
Django
$sudo pacman -S python-virtualenvwrapper
$sudo pacman -S python-django
$virtualenv venv
$source venv/bin/activate
$django-admin startproject mytestsite
$python3 manage.py runserver
Editing
[ S P A C E M A C S ]
- EMAIL
- mbsync
- mailbox syncronizer
- restart/reload/regenerate
spc f e C-e
recreates .env variable filesspc f e r
files - emacs - reloadspc q r
quit, restartspc f e r
emacsdotfile reload - spacemacs config:
spc f e d
open the spacemacs configpacman -S aspell-en
- buffer navigation
spc b b
shows all buffers - help
, h h
shows information relative to current cursor position, g u
reference of the current function, g a
findes assignment - python shell
spc m s i
major - start - inferiorspc m s b
major - send - runs buffer in inferior shellspc m s f
major - send - functionspc m l
major - livespc m c c
executes in comint shell: major execute c-cspc spc k
kill-buffer
Org mode
- calender
C-c . evilify
- Export to Hugo hugo
Using org + ox-hugo to export orgfiles into structured hugo markdown.
At the head of the org document we set things like title, author, contact, setupfiles and other settings:
#+TITLE: Toolbox #+HTML_LINK_HOME: #+LINK_UP: index.html #+OPTIONS: H:4 num:nil toc:n \n:nil ::t |:t ^:t -:t f:t *:t tex:t d:(HIDE) tags:not-in-toc #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate
Sections for export need properties at the beginning:
:PROPERTIES: :EXPORT_HUGO_SECTION: / :EXPORT_FILE_NAME: index :END:
this creates index.md in the root
in .spacemacs:
(defun dotspacemacs/user-config () (use-package ox-hugo :ensure t ;Auto-install the package from Melpa (optional) :after ox))
- don't
org-hugo-export-to-md
- do
C-c C-e HA
- Export to HTML with style
get a theme
this page is build with
https://github.com/fniessen/org-html-themes
and the reference card:
https://github.com/fniessen/refcard-org-mode
Changes to the theme are made in separate branch from the forked repo.
Create folders and place theme dependencies corresponding to the setupfile
In the Org file set path to setupfile, title and more
#+SETUPFILE: styles/theme-readtheorg-local.setup #+TITLE: Toolbox
Using
C-c C-e h h
we export org to html.After everything is done we sync with rclone:
$rclone config
rclone sync ~/Projects/Toolbox/ wtf:/pub/c.haas.wtf
- Text and Files
- Text
- bullet
- bullet
- another bullet
- and done
code
bold
italic
strike troughunderline
verbose
- Images and Links
Figure 1: caption for 300px wide image
#+caption: caption for 300px wide image #+name: city #+attr_html: :width 300px [[file:images/city-q-c-640-480-2.jpg]]
using the name attribute to link a existing reference:
[[city][description]]
and just a image as file:
[[file:images/nature-q-c-640-480-4.jpg]]
- Text
- Source blocks
spc m i b s
- LaTex
\begin{equation} f(x) = x^2 \end{equation} - Flowcharts
- PlantUML
We install plantuml with pacman:
$pacman -S plantuml
execution path looks like:
exec /usr/bin/java -jar '/usr/share/java/plantuml/plantuml.jar' "$@"
With this path we can evaluate this:
(setq org-plantuml-jar-path (expand-file-name "/usr/share/java/plantuml/plantuml.jar")) (add-to-list 'org-src-lang-modes '("plantuml" . plantuml)) (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
And write the flowchart:
start repeat :foo as starting label; :read data; :generate diagrams; backward:This is backward; repeat while (more data?) stop
- ditaa
possible alternative
- mermaid
possible alternative
- PlantUML
- SCAD
- GNUPlot
Requirements: gnu-plot
;; active Babel languages (org-babel-do-load-languages 'org-babel-load-languages '((gnuplot . t))) ;; add additional languages with '((language . t)))
reset set title "Putting it All Together" set xlabel "X" set xrange [-8:8] set xtics -8,2,8 set ylabel "Y" set yrange [-20:70] set ytics -20,10,70 f(x) = x**2 g(x) = x**3 h(x) = 10*sqrt(abs(x)) plot f(x) w lp lw 1, g(x) w p lw 2, h(x) w l lw 3
Vim
vii
select indent block
viI
select indent block including first line
Pandoc
pandoc document.org -f org -t html -s -o website.html --metadata pagetitle="test"
Git gud
Work with a remote repository
This should cover most operations. Everything else is done with magit.
The original repository is upstream, we fork that project and create a new branch for our changes.
A fork is feature of the hosting site, not a git feature.
Get you fork:
$git pull
Create a new branch:
$git checkout -b <branchname>
And push it to the remote:
$git push origin <branchname>
Or get a existing branch:
$git checkout <branch>
List the existing branches:
$git branch -a
Change to the new branch:
$git switch <branch>
Set the location for upstream:
$git remote add upstream <https://>
List the remotes:
$git remote -v
Update the local fork from the upstream:
$git fetch upstream
$git merge upstream/master
Push the updated to your remote:
$git push
If there are changes in upstream while we edit our fork, update again.
After a successful pull request we can delete the branch:
remote:
$git switch <branch>
$git push -d origin <branch>
and local:
$git branch -d <branch>
Or we merge a testing branch:
$git merge testing/master
New repo
$touch README.md
$git init
$git add README.md
$git commit -m "first commit
$git remote add origin git@git...com:User/project.git
$git push -u origin master
Git credentials in PLAIN TEXT:
~/.netrc
machine github.com
login <user>
password <pwd>
Software
- rclone
- like rsync for files and folder on different clouds https://rclone.org/
- wav
- wayland event viewer https://git.sr.ht/~sircmpwn/wev
- dhall
- programmable configuration language, like yaml https://dhall-lang.org/
- buku
- bookmark manager https://github.com/jarun/buku
- Zathura
- minimalistic PDF viewer
- qutebrowser
- minimalistic web browser
- ripgrep
- faster than grep
- ranger
- file browser with vim support
- podman
- container engine
- hastebin
- pastebin from cli
- firefox
– fullscreen to window size: about:config
full-screen-api.ignore-widgets
– firefox wayland about:support window protocol: x11 / wayland
$echo "MOZ_ENABLE_WAYLAND=1" > ~/.config/environment.d/firefox.conf
- thunderbird
$echo "MOZ_ENABLE_WAYLAND=1" > ~/.config/environment.d/thunderbird.conf
- lf
- cli file browser https://github.com/gokcehan/lf
- PASS
- linux replacement for keepass https://www.passwordstore.org/
- Sway Pass script
- https://git.reekynet.com/ReekyMarko/fzf-pass
- firmware for fritzbox and fritzrepeater
- https://openwrt.org/ https://freetz.github.io/
- Freetube
- youtubeviewer with subscription and browser extension (beta) https://github.com/FreeTubeApp/FreeTube
GNU Stow, for dotfile tracking and version history
A stow directory:
mkdir /usr/local/stow
A new package for emacs:
/usr/local/stow/emacs
We put .spacemacs in the stow directory and create the simlinks with stow:
$sudo stow emacs
Run git init, add the files and configure your repo.
Network
FTP
? | Access the help screen. |
append | Append text to a local file. |
ascii | Switch to ASCII transfer mode. |
bell | Turns bell mode on or off. |
binary | Switches to binary transfer mode. |
bye | Exits from FTP. |
cd | Changes directory. |
close | Exits from FTP. |
delete | Deletes a file. |
debug | Sets debugging on or off. |
dir | Lists files if connected. |
dir -C | will list the files in wide format. |
dir -1 | lists the files in bare format in alphabetic order |
dir -r | lists directory in reverse alphabetic order. |
dir -R | lists all files in current directory and subdirectories. |
dir -S | lists files in bare format in alphabetic order. |
disconnect | Exits from FTP. |
get | Grabs file from the computer to which you are connected. |
glob | Sets globbing on or off. When turned off the file name in the put and get commands is taken literally and wildcards are not used. |
hash | Sets hash mark printing on or off. When turned on, for each 1024 bytes of data received, a hash mark (#) is displayed. |
help | Access the help screen and displays information about command if command typed after help. |
lcd | Displays local directory if typed alone, or if path typed after lcd, changes local directory. |
literal | Sends a literal command to the connected computer with an expected one line response. |
ls | Lists files of the remotely connected computer. |
mdelete | Multiple delete. |
mdir | Lists contents of multiple remote directories. |
mget | Get multiple files. |
mkdir | Make directory. |
mls | Lists contents of multiple remote directories. |
mput | Sent multiple files |
open | Opens address. |
prompt | Enables or disables the prompt. |
put | Send one file. |
pwd | Print working directory. |
quit | Exits from FTP. |
quote | Same as the literal command. |
recv | Receive file. |
remotehelp | Get help from remote server. |
rename | Renames a file. |
rmdir | Removes a directory on the remote computer. |
send | Send single file. |
status | Shows status of currently enabled and disabled options. |
trace | Toggles packet tracing. |
Type | Set file transfer type. |
user | Send new user information. |
verbose | Sets verbose on or off. |
Create password protected directory
$mkdir folder
$local working directory
$lcd [directory]
$put filename
create password file:
/path/to/htpasswd -c /etc/htpasswd/.htpasswd user1
/path/to/htpasswd /etc/htpasswd/.htpasswd user2
Mobile
SSH
Termux update with
$pkg upgrade
install:- openssh
- (dnsutils)
get the ip:
ifconfig -a
to send keys:$termux-open --send ~/.ssh/id_rsa
Python to Android
Laptop
Arch BIOSboot with grub2
Troubleshooting:
$wipefs --all /dev/sdaX
remove filesystem
$mount
lists mounting points
$umount -R /mnt
unmounts recursive
Live USB stick:
$dd bs=4M if=path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync
In live boot
Settings
$loadkeys de
$wifi-menu -o
$timedatectl set-ntp true
Partitions
$fdisk /dev/sdx
- boot, 1M (fdisk 04)
- 32G linux, bootable (fdisk 22)
- 2G swap (fdisk 19)
- User (fdisk 28)
No filesystem for boot or swap
$mkfs.ext4 /dev/sdX1
$mkswap /dev/sdX2
$swapon /dev/sdX2
Mount, strap and tab
mount /, /usr, /boot. create folders is necessary
$mount /dev/sdX1 /mnt
$pacstrap /mnt base base-devel linux linux-firmware
$genfstab -U /mnt >> /mnt/etc/fstab
Setup installed system
Bootloader
$arch-chroot /mnt
$pacman -S grub
$grub-install --target=i386-pc /dev/sdX
$grub-mkconfig -o /boot/grub/grub.cfg
Local and user settings
$ln -sf /usr/share/zoneinfo/Region/City /etc/localtime
$pacman -S vim
$vim /etc/locale.gen
For now only en_DK ISO-8859-1
f