Initial poop

This commit is contained in:
Lauren Toivanen 2025-01-24 05:13:48 +02:00 committed by root
commit ca6dab46f1
3280 changed files with 3759 additions and 0 deletions

14
docs/index.md Normal file
View file

@ -0,0 +1,14 @@
---
icon: material/home
hide:
- navigation
- toc
---
# HOME
We have many things. Yes.
- :simple-forgejo: [git.jakest.us](http://git.jakest.us)
- :simple-matrix: [@jt:neo.jakest.us](https://matrix.to/#/@jt:neo.jakest.us)
- :simple-mastodon: [@jt@bubbler.jakest.us](http://bubbler.jakest.us/@jt)

17
docs/mkdocs/index.md Normal file
View file

@ -0,0 +1,17 @@
# Welcome to MkDocs
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
## Commands
* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.
## Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.

View file

@ -0,0 +1,8 @@
# Installing
## Debian
1. Get Debian (I just had to get some content here to fill out this crap, don't blame me)
1.1. Blame me
2. I suggest using the material theme as it is just wonderful
`sudo apt install mkdocs mkdocs mkdocs-material mkdocs-material-extensions`

View file

@ -0,0 +1,78 @@
# Calling Conventions
## Cheatsheet
| Platform | Return Value | Parameter Registers | Additional Parameters | Stack Alignment | Scratch Registers | Preserved Registers | Call List |
| -------------------------------------------------------------------- | ------------ | -------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------- | ----------------------------------------- | ------------------------------------------- | --------- |
| System V i386 | eax, edx | none | stack (right to left)[1](https://wiki.osdev.org/Calling_Conventions#Note1) | | eax, ecx, edx | ebx, esi, edi, ebp, esp | ebp |
| System V X86_64[2](https://wiki.osdev.org/Calling_Conventions#Note2) | rax, rdx | rdi, rsi, rdx, rcx, r8, r9 | stack (right to left)[1](https://wiki.osdev.org/Calling_Conventions#Note1) | 16-byte at call[3](https://wiki.osdev.org/Calling_Conventions#Note3) | rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11 | rbx, rsp, rbp, r12, r13, r14, r15 | rbp |
| Microsoft x64 | rax | rcx, rdx, r8, r9 | stack (right to left)[1](https://wiki.osdev.org/Calling_Conventions#Note1) | 16-byte at call[3](https://wiki.osdev.org/Calling_Conventions#Note3) | rax, rcx, rdx, r8, r9, r10, r11 | rbx, rdi, rsi, rsp, rbp, r12, r13, r14, r15 | rbp |
| ARM (32-bit) | r0, r1 | r0, r1, r2, r3 | stack | 8 byte[4](https://wiki.osdev.org/Calling_Conventions#Note4) | r0, r1, r2, r3, r12 | r4, r5, r6, r7, r8, r9, r10, r11, r13, r14 | |
## System V i386
- Parametres are pushed to stack from right to left
- Caller cleans the stack
- Callee is free to modify parametres
- Caller must not assume they stayed the same!
- Scratch registers are `EAX`, `ECX` and `EDX`
- Caller must preserve if needed
- Function preserves `EBX`, `ESI`, `EDI` and `EBP`
- Return value in `EAX`
- If 64bit value: higher 32bits in `EDX`
- Functions push `ebp` such that the caller-return-eip is 4 bytes above it, and set `ebp` to the address of the saved ebp.
- Allows iterating through the existing stack frames.
- Can be eliminated by specifying the -fomit-frame-pointer GCC option.
## CDECL
**Caller's responsibilities**
- Push parameters in reverse order (last parameter pushed first)
- Perform the call
- Pop the parameters, use them, or simply increment `ESP` to remove them (stack clearing)
- The return value is stored in `EAX`
**Callee's responsibilities (callee is the routine being called)**
- Store caller's `EBP` on the stack
- Save current `ESP` in `EBP`
- Code, storing local data on the stack
- For a fast exit load the old `ESP` from `EBP`, else pop local data elements
- Pop the old `EBP` and return store return value in `EAX`
**It looks like this in assembly (NASM)**
``` nasm
SECTION .text
caller:
 ; ...
 ; Caller responsibilities:
PUSH 3  ; push the parameters in reverse order
PUSH 2
CALL callee  ; perform the call
ADD ESP, 8  ; stack cleaning (remove the 2 words)
 ; ... Use the return value in EAX ...
callee:
 ; Callee responsibilities:
PUSH EBP  ; store caller's EBP
MOV EBP, ESP  ; save current stack pointer in EBP
 ; ... Code, store return value in EAX ...
 ; Callee responsibilities:
MOV ESP, EBP  ; remove an unknown number of local data elements
POP EBP  ; restore caller's EBP
RET  ; return
```
## Sources
- [https://wiki.osdev.org/Stack](https://wiki.osdev.org/Stack)
- [https://wiki.osdev.org/Calling_Conventions](https://wiki.osdev.org/Calling_Conventions)
- [https://wiki.osdev.org/System_V_ABI](https://wiki.osdev.org/System_V_ABI)
**TODO:** Check if SysV ABI and CDECL are really the same thing?

View file

@ -0,0 +1,21 @@
# Custom default editor
If you'd like to for example open #emacs with `-nw` you need to do some trickery.
Create a script to open the editor and set it executable
``` sh title="/usr/local/bin/emacs-nw"
#!/bin/sh
emacs -nw "$@"
```
Add the script to list of known editors (if using update-alternatives system) and set it default:
``` console
$ sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/emacs-nw 2;
$ sudo update-alternatives --config editor;
```
You may also set variables in `~/.bashrc` like so:
``` sh title="~/.bashrc"
export VISUAL="emacs"
export EDITOR="emacs -nw"
```

24
docs/programming/go.md Normal file
View file

@ -0,0 +1,24 @@
# GO!
On Debian 12 you should probably use GO from backports
to get a newer version.
Set up backports repo and get it with
`sudo apt install -t bookworm-backports golang`
## Packaging DEB
- `sudo apt install git-buildpackage`
- Create directory `./debian`
- Create changelog with `dch --create`
- `sudo apt install dh-golang`
Example rules:
``` make
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@ --builddirectory=_build
```
Check out [Debian Go-Team Packaging](https://go-team.pages.debian.net/packaging.html)

View file

@ -0,0 +1,16 @@
# Crosscompiling
## Linux to Windows
### Dependencies
``` console
$ rustup target list
$ rustup target add x86_64-pc-windows-gnu
$ sudo apt install mingw-w64
```
### Building
``` console
$ cargo build --release --target=x86_64-pc-windows-gnu
```

View file

@ -0,0 +1,3 @@
# Installing
I suggest using [rustup](https://rustup.rs) for this. It is being [packaged](https://packages.debian.org/trixie/rustup) in Debian 13 (Trixie) but meanwhile use `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` which sets up the default toolchain for you.

View file

@ -0,0 +1,18 @@
# Watch directory for changes
Watching directory for changes can be useful for example let's say you have a markdown based knowledgebase and want to automagically rebuild statically served html-site. Like this one right here!
## Script
Use #bash and make a fancy scriptie using `inotify-tools`. This can be installed from debian repos using `sudo apt install inotify-tools`. For example this #mkdocs site uses following at the time of writing:
``` sh
#!/bin/sh
. bin/activate
while true
do
mkdocs build
inotifywait -r dokut
done
```
Main takes here are the infinite loop that rebuilds docs and then waits for any change in directory (recursively) before looping again. Here would also be a good place to setup some `sleep`ing to ratelimit things or a more complex script to even wait no more changes are detected for some time...

13
docs/roska/index.md Normal file
View file

@ -0,0 +1,13 @@
# rOSka
Useless operating system that is *literally* trash
Probably written in FASM, who knows rly?
Source available at [https://git.jakest.us/roska](https://git.jakest.us/roska)
Run with multiboot (for example grub), yeah. It sets us a frmebuffer and stuff.
## Building and Running
- You need FASM to assemble source
- You need to boot the file using multiboot-compatible bootloader (grub is handy-dandy)
- To make a x86 bios compatible disk image for virtual machine or to burn onto a usb you need `grub-pc-bin` and `util-linux` or something along those lines. IDK, just refer the Makefile or something!

View file

@ -0,0 +1,26 @@
# Autostarting apps
!!! note
My modified [Makefile](https://git.jakest.us/suckless/dwm/src/branch/jakefication/Makefile)
installs this file automagically.
Steps below should not be necessary.
If using a display manager make the session execute a script
(refer to [xsession](xsession.md)).
Same could be done with `startx` and `~/.xinitrc`.
My modified version provides my autostarting script
and installs it as `/usr/local/bin/startdwm`
The script could look something like
``` sh title="/usr/local/bin/startdwm"
#!/bin/sh
slstatus &
pasystray &
nm-applet &
exec dwm
```
You might also like the
[systray patch](https://dwm.suckless.org/patches/systray/)
as it just makes sense.

View file

@ -0,0 +1,55 @@
# Cheatsheet
My chosen modification key is ++win++/++super++.
Many functions have multiple shortcuts because every day is different.
I might have forgotten something but [`config.h`](https://git.jakest.us/suckless/dwm/src/branch/jakefication/config.h)
is pretty human-readable.
## Standard keys
| Key combination(s) | Action |
| --------------------------------------------------------- | --------------------------------- |
| ++win+d++<br>++win+space++<br>++alt+space++<br>++win+p++ | Drun |
| ++ctrl+alt+t++<br>++win+shift+enter++ | Terminal |
| ++alt+f4++<br>++win+q++ | Close window |
| ++win+up++<br>++win+down++ | Focuse next/previous window |
| ++win+enter++ | Swap window from/to master |
| ++win+left++<br>++win+right++ | Increase/Decrease master capacity |
| ++win+shift+left++<br>++win+shift+right++ | Resize master/stack |
| ++win+shift+q++ | Quit DWM |
## Workspaces and monitors
| Key combination | Action |
| -------------------- | --------------------------------- |
| `Win`+ `1-9` | Focus workspace |
| `Win`+ `Shift`+`1-9` | Move window to workspace |
| `Win`+`,/.` | Focus left/right monitor |
| `Win`+`Shift`+`,/.` | Move window to left/right monitor |
| `Win`+`0` | Show all workspaces |
| `Win`+`Shift`+`0` | Show window in all workspaces |
## Media controls
In addition to supporting standard volume and mediacontrols
following shortcuts have been configured. You know,
not every keyboard has these keys and it sucks!
| Hotkey | Action |
| ----------- | ---------- |
| ++win+f5++ | Previous |
| ++win+f6++ | Next |
| ++win+f7++ | Play/Pause |
| ++win+f8++ | Stop |
| ++win+f9++ | Mute |
| ++win+f10++ | Vol Down |
| ++win+f11++ | Vol Up |
## Floaty stuff
| Shortcut | Action |
| ------------------------------------------- | ---------------------- |
| ++win+shift+space++<br>++win++ + `Mouse3` | Toggle window floating |
| ++win++ + `Mouse1 Drag` | Move window |
| ++win++ + `Mouse2 Drag` | Resize window |

View file

@ -0,0 +1,33 @@
# Dependencies
Dmenu, slstatus, st and dwm itself are recommended to build yourself from sources. Other packages are installable from Debian-repositories (or whatever distro you are running, you probably know how to get them.)
## Building
- xorg-dev
## Standard functionality
- [dmenu](https://git.jakest.us/suckless/dmenu)
- [slstatus](https://git.jakest.us/suckless/slstatus)
- [st](https://git.jakest.us/suckless/st)
- [slock](https://git.jakest.us/suckless/slock)
- pactl (to control pulseaudio/pipewire, comes with pulseaudio-utils or pipewire-uitils or something, I don't know, just try to find out yourself if volumecontrol is not working)
- playerctl (to control media playback)
- dunst (to show notifications)
- nm-applet (network-manager-gnome)
## Screenshots
- imagemagick
- scrot
- xclip
- xdg-user-dirs
- create a directory `mkdir -p $(xdg-user-dir PICTURES)/scrot/`
- This will be automated at some point. Sorry in the meantime
## What I am supposed to do again?
Here, have a nice command to get dependencies (not dmenu/slstatus/st/dwm) from repositories on Debian: `sudo apt install xorg-dev playerctl imagemagick scrot xclip xdg-user-dirs dunst pulseaudio-utils pasystray pavucontrol network-manager-gnome`
Then dmenu, st, slstatus and dwm itself you pull using git, checkout branch jakefication (if you want the customized versions, otherwice you should maybe use the suckless upstream at https://git.suckless.org/ ) and build using `sudo make clean install` all one-by-one voíla

View file

@ -0,0 +1,7 @@
# DWM
dwm is a dynamic window manager for X.
[![Screenshot of a desktop running DWM with some windows](screenshot.png)](screenshot.png)
Check full official documentation at [https://dwm.suckless.org/](https://dwm.suckless.org/)

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

View file

@ -0,0 +1,61 @@
# XSession
!!! note
My modified Makefile installs DWM as a session automagically. I think.
Maybe check out the [Makefile](https://git.jakest.us/suckless/dwm/src/branch/jakefication/Makefile). Steps below should not be necessary.
You might want to add DWM as a session to start it conveniently from a display manager.
## .desktop file
For displaymanagers that parse these.
As root create a file like this:
``` desktop title="/usr/share/xsessions/dwm.desktop"
[Desktop Entry]
Encoding=UTF-8
Name=dwm
Comment=Dynamic window manager
Exec=dwm
Icon=dwm
Type=XSession
```
with these permissions
``` console
$ ls -l /usr/share/xsessions/dwm.desktop
-rw-r--r-- 1 root root 108 Jun 27 17:24 /usr/share/xsessions/dwm.desktop
```
## Execute a script
Optionally rather than executing dwm directly you could execute a shell script instead that writes stdout / stderr to a file for logging purposes. This also helps to [autostart](autostart.md) apps
So the .desktop file should be modified to have
`Exec=startdwm`
and you need a file with executable permissions
``` sh title="/usr/local/bin/startdwm"
#!/bin/sh
echo "$(date): Starting dwn" >> /path/to/logs/$(date +%Y-%m-%d_%H.dwm.log)
dwm >> /path/to/logs/$(date +%Y-%m-%d_%H.dwm.log) 2>&1
```
``` console
$ ls -l /usr/local/bin/startdwm
-rwxr-xr-x 1 root root 204 Sep 19 14:12 /usr/local/bin/startdwm
```
## Debian alternatives
For some displaymanagers, like XDM.
You may add your session with something like:
``` console
$ sudo update-alternatives --install /usr/bin/x-session-manager x-session-manager /usr/local/bin/startdwm 50
$ sudo update-alternatives --config x-session-manager
```
## Credits
Thank you u/bakkeby for providing some of this information on Reddit [https://www.reddit.com/r/suckless/comments/jj61py/comment/gaanvez/](https://www.reddit.com/r/suckless/comments/jj61py/comment/gaanvez/)

38
docs/suckless/index.md Normal file
View file

@ -0,0 +1,38 @@
# Suckless
Minimal tools that barely do their jobs, written in C, configured by modifying sources and recompiling.
Below is stuff and things copied from [suckless.org](https://suckless.org/) (2024-07-27) because an interesting read.
---
Quality software with a focus on simplicity, clarity, and frugality.
## Philosophy
We are the home of quality software such as [dwm](https://dwm.suckless.org), [dmenu](https://tools.suckless.org/dmenu), [st](https://st.suckless.org/) and plenty of other [tools](https://tools.suckless.org), with a focus on simplicity, clarity and frugality. Our philosophy is about keeping things simple, minimal and usable. We believe this should become the mainstream philosophy in the IT sector. Unfortunately, the tendency for complex, error-prone and slow software seems to be prevalent in the present-day software industry. We intend to prove the opposite with our software projects.
Our project focuses on advanced and experienced computer users. In contrast with the usual proprietary software world or many mainstream open source projects that focus more on average and non-technical end users, we think that experienced users are mostly ignored. This is particularly true for user interfaces, such as graphical environments on desktop computers, on mobile devices, and in so-called Web applications. We believe that the market of experienced users is growing continuously, with each user looking for more appropriate solutions for his/her work style.
Designing simple and elegant software is far more difficult than letting ad-hoc or over-ambitious features obscure the code over time. However one has to pay this price to achieve reliability and maintainability. Furthermore, minimalism results in reasonable and attainable goals. We strive to maintain minimalism and clarity to drive development to completion.
## Manifest
Many (open source) hackers are proud if they achieve large amounts of code, because they believe the more lines of code they've written, the more progress they have made. The more progress they have made, the more skilled they are. This is simply a delusion.
Most hackers actually don't care much about code quality. Thus, if they get something working which seems to solve a problem, they stick with it. If this kind of software development is applied to the same source code throughout its entire life-cycle, we're left with large amounts of code, a totally screwed code structure, and a flawed system design. This is because of a lack of conceptual clarity and integrity in the development process.
Code complexity is the mother of bloated, hard to use, and totally inconsistent software. With complex code, problems are solved in suboptimal ways, valuable resources are endlessly tied up, performance slows to a halt, and vulnerabilities become a commonplace. The only solution is to scrap the entire project and rewrite it from scratch.
The bad news: quality rewrites rarely happen, because hackers are proud of large amounts of code. They think they understand the complexity in the code, thus there's no need to rewrite it. They think of themselves as masterminds, understanding what others can never hope to grasp. To these types, complex software is the ideal.
Ingenious ideas are simple. Ingenious software is simple. Simplicity is the heart of the Unix philosophy. The more code lines you have removed, the more progress you have made. As the number of lines of code in your software shrinks, the more skilled you have become and the less your software sucks.
## Related links
- [The Duct Tape Programmer](http://www.joelonsoftware.com/items/2009/09/23.html)
- [Why should I have written ZeroMQ in C, not C++](http://www.250bpm.com/blog:4)
- [Best practices in application architecture: Use layers to decouple](http://geekandpoke.typepad.com/.a/6a00d8341d3df553ef014e5f920093970c-pi)
- [Facebook's code quality problem](http://www.darkcoding.net/software/facebooks-code-quality-problem/)
- [Minimal Viable Programs](http://joearms.github.io/published/2014-06-25-minimal-viable-program.html)
- [Why I Write Games in C](http://jonathanwhiting.com/writing/blog/games_in_c/)
- [Use of command-line tools for effective data processing](https://adamdrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html)

View file

@ -0,0 +1,6 @@
# ST
st is a simple terminal implementation for X.
[![Screenshot of ST](screenshot.png)](screenshot.png)
Check full official documentation at [https://st.suckless.org/](https://st.suckless.org/)

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View file

@ -0,0 +1,5 @@
# Troubleshooting
## Delete key not working
Edit `/etc/inputrc` or `~/.inputrc` to contain `set enable-keypad on`