Compare commits

...

16 Commits

34 changed files with 822 additions and 30 deletions

4
Irc/libera.md Normal file
View File

@ -0,0 +1,4 @@
# Libera.Chat
## Find Channels
- Use Bot `alis`: `/msg alis LIST *<SEARCH_TERM>*`

6
Router/OpenWrt.md Normal file
View File

@ -0,0 +1,6 @@
# OpenWrt
- scp gives `ash: /usr/libexec/sftp-server: not found`
> Use `-O` flag
- Get public IP: `dig +short myip.opendns.com @resolver1.opendns.com`

View File

@ -9,11 +9,6 @@
- `FB`: function begin
- `FE`: function end
## Calling Conversions
- Args: `RDI, RSI, RDX, RCX, R8, R9`
- System Calls: `R10` (instead of `RCX`)
- Return: `RAX`
## AT&T
- source comes before destination
- mnemonic suffixes indicate the size of the operands (q for quad, etc.)
@ -25,3 +20,34 @@
- Opcodes: <https://www.felixcloutier.com/x86/index.html>
- General Intel instructions: <https://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.html>
- More performance oriented: <https://www.agner.org/optimize/>
## Registers
### Overview
| --- | --- | --- | --- |
| 64-bit register | Lower 32 bits | Lower 16 bits | Lower 8 bits |
| --- | --- | --- | --- |
| rax | eax | ax | al |
| rbx | ebx | bx | bl |
| rcx | ecx | cx | cl |
| rdx | edx | dx | dl |
| rsi | esi | si | sil |
| rdi | edi | di | dil |
| rbp | ebp | bp | bpl |
| rsp | esp | sp | spl |
| r8 | r8d | r8w | r8b |
| r9 | r9d | r9w | r9b |
| r10 | r10d | r10w | r10b |
| r11 | r11d | r11w | r11b |
| r12 | r12d | r12w | r12b |
| r13 | r13d | r13w | r13b |
| r14 | r14d | r14w | r14b |
| r15 | r15d | r15w | r15b |
### Calling Conversions
- Args: `RDI, RSI, RDX, RCX, R8, R9`
- System Calls: `R10` (instead of `RCX`)
- Return: `RAX`
- Callee-Saved: `RBX, RBP, R12, R13, R14, R15`
- Caller-Saved: `RAX, RCX, RDX, RDI, RSI, R8, R9`

20
audio.md Normal file
View File

@ -0,0 +1,20 @@
# Audio
## File Information
- Basic info: `file <fileName>`
- More info: `ffprobe -hide_banner <fileName>`
- Even more info: `ffprobe -show_streams <fileName>`
- Clean info: `soxi <fileName>`
## Conversion
- flac to wav:
- Using flac `flac --decode [<file.flac>]`
- Using sox `sox <file.flac> <file.wav>`
## Burn CD
1. Prepare file: `sox <file.flac> -c 2 -r 44100 -b 16 <file.wav>`
- If clip warning, decrease volume by adding `-v 0.99` before the input file
- Decrease till warning is gone
2. Check if burn would succeed `cdrecord -dummy -v dev=/dev/sr0 -dao -useinfo -pad [file.wav]`
- Make sure the files are ordered correctly
- Remove `-dummy` for actual burn

13
c.md
View File

@ -9,3 +9,16 @@ int option = 1;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &option, sizeof(option));
```
## Formatting
### `clang-format`
- Format all files in-place: `clang-format -i *.c *.h`
- Specify format:
- Predefined style: `-style=<STYLE>`, e.g. `-style=llvm`
- Custom file in current or parent directory: `-style=file`
- Create style file based on default: `clang-format -style=llvm -dump-config > .clang-format`
- If no `-style` is provided, `-style=file` is used. If there is no `.clang-format`, `-style=LLVM` is used
- Use default style, but overwrite some key: `--style={BasedOnStyle: <STYLE>, <KEY>: <VALUE>}`
### Example
- `clang-format --style="{BasedOnStyle: LLVM, IndentWidth: 4, ColumnLimit: 90}" -i *.c *.h`

View File

@ -1,11 +1,46 @@
# Calibrate Monitor
## Steps
- Create new `.icc` profile using DisplayCAL
- Reset current profile: `Tools -> Video Card Gamma Table -> Reset Video Card Gamma Table`
- Select Settings `Default (Gamma 2.2)`
- Display & Instrument
- Display
- Select correct display
- Untick everything
- Output levels `Full Range RGB 0-255`
- Correction `Auto (None)`
- Instrument
- Select correct instrument
- Untick everything
- Select Instrument mode `LCD (generic)`
- Calibration
- (Optional) Enable `Ambinet light level adjustment`
- Determine value using instrument (generally between 120 - 180)
- Profiling
- Enable `Black Point Compensation`
- Connect instrument
- Check if instrument detected by pressing on `Display & Instrument ->` Arrow cycle
- Disable display sleep `xset s off && xset -dpms`
- Disable redshift
- Start by clicking `Callibrate & Profile`
- Make sure display has right settings
- `Start Mesure`
- Make sure brightness and colors of monitor are good
- Disable again
- `Continue on to callbiration`
- Copy profile form `~/.local/share/DisplayCAL/storage/<somePath>/<someFile>.icc` to `/usr/share/color/icc/colord/` (tried `~/.local/share/icc/` but somehow did not work)
- Run `systemctl restart colord` to make colord find new profiles
- Start `xiccd` and let it run
- Figure out `Device ID` from `colormgr get-devices` of desired monitor
- Figure out `Profile ID` from `colormgr get-profiles` of desired profile
- Search for profile `colormgr find-profile-by-filename <ProfileID>`
- Add profile to monitor `colormgr device-add-profile <DeviceID> <ProfileID>`
- Set profile as default for monitor `colormgr device-make-profile-default <DeviceID> <ProfileID>`
- Quit `xiccd`
- Check that profile has successfully been loaded: `xprop -display :0.0 -len 14 -root _ICC_PROFILE`
- Really good article about the matter: <https://web.archive.org/web/20221226110150/https://encrypted.pcode.nl/blog/index.html%3Fp=853.html>

6
commands.md Normal file
View File

@ -0,0 +1,6 @@
# Commands
List of random commands
- Add $20$ to all branch names where the names does not start with the full year:
- `git for-each-ref refs/heads --format "%(refname:short)" | grep -E "^[0-9]{6}_.*" | xargs -n 1 -I % git branch -m % 20%`

7
ctf.md Normal file
View File

@ -0,0 +1,7 @@
# CTF
## General Information about Binary
- `checksec --file <BINARY>`
## PWN-Tools
- Create from template: `pwn template <BINARY> > exploit.py`

View File

@ -5,3 +5,12 @@
- Run script within a container `docker exec -i <containerName> bash < <scriptPath>`
- Update all images: `docker images | grep -v REPOSITORY | awk '{print $1}'| xargs -L1 docker pull`
## Networking
### Access Hosts
- Add
- Connect to hosts's localhost using: `172.17.0.1`
### Intercontainer Communication
- use docker name inside container

9
find.md Normal file
View File

@ -0,0 +1,9 @@
# Find
- Include pipe in exec:
`-exec sh -c "zcat {} | agrep -dEOE 'grep' " \;`
`find -name 'file_*' -follow -type f -exec zcat {} \; | agrep -dEOE 'grep'`
- Convert markdown files in subdirectory to pdf:
`find . -regextype sed -regex ".*/[0-9]*-sol.md" -exec sh -c 'cd $(dirname $0) && pandoc -V geometry:margin=1in --pdf-engine=xelatex --variable mainfont="DejaVu Serif" -o $(basename $0).pdf $(basename $0)' {} \;`

47
gdb.md
View File

@ -8,5 +8,52 @@
- Go to end of function: `finish`
- Create Breakpoint: `break <lineNr>`
- Go on with `start`
- Go no breakpoint: `c`
- Inspect variable: `print <ariable>`
- Refresh window when "broken": `ctrl + L`
- Print: `p`
## Debug Assembly
- Load file
- Enable assembly: `layout asm`
- Start at first instruction: `starti`
- Step through using `stepi (si)` and `nexti (ni)`
- Show top $10$ elements of the stack: `x/10x $sp`
## TUI
- Change window: `CTRL + x o`
- Previous/Next Command: `CTRL + P`/`CTRL + N`
- Change size: `winheight <window> <+/-> <size>`
- When leaving out `<+/->` it is set to absolute size
- Execute command `n` times: `python [gdb.execute('<YOUR_COMMAND>') for x in range(n)]`
##
- Disassemble function: `disassemble <function>`
## Breakpoint
- At function + offset: `b *FUNC+OFFSET`
- At Address: `b *ADDR`
## Stripped Binaries
### Entry Point
- Sometimes this works: `b __libc_start_main`
- Only works when dynamic libraries (libc) were loaded (which is only after start of program)
- When hitting this breakpoint, GDB tells us the location of main, which is the first argument to `__libc_start_main`
- `(gdb) info file` tells the entry point address
x
x/s
x/10xw 32 bit
x/10xX 64 bit
vmmap gives overwie of virtual memory

View File

@ -5,3 +5,134 @@
- Mark the repo `<DEAD_REPO>` as dead: `git dead <UUID_OF_DEAD_REPO>`
- Delete references to it: `git annex forget --drop-dead --force`
- Sync to all repositories
## Appendix
- Setup automatic metadata addition:
- Run `wget https://git-annex.branchable.com/tips/automatically_adding_metadata/pre-commit-annex` in `.git/hooks` and make it executable
- In case the link brakes, the content is added to the appendix
- Set the desired keys: `git config metadata.exiftool "Model ImageSize FocusRange GPSAltitude GPSCoordinates"`
- Gitannex metadata file from [here](https://git-annex.branchable.com/tips/automatically_adding_metadata/pre-commit-annex)
```
#!/bin/sh
#
# Copyright (C) 2014 Joey Hess <id@joeyh.name>
# Copyright (C) 2016 Klaus Ethgen <Klaus@Ethgen.ch>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This script can be used to add git-annex metadata to files when they're
# committed. It is typically installed as .git/hooks/pre-commit-annex
#
# You can also run this script by hand, passing it the names of files
# already checked into git-annex, and it will extract/refresh the git-annex
# metadata from the files.
tool="$(git config metadata.tool || :)"
if [ -z "$tool" ]; then
tool=extract
fi
case "$tool" in
exiftool)
tool_exec="exiftool -unknown -zip -veryShort -ignoreMinorErrors -use MWG -dateFormat '%Y-%m-%dT%H:%M:%S'"
;;
*)
tool_exec="$tool"
;;
esac
extract_fields="$(git config metadata.extract || :)"
if [ -n "$extract_fields" ]; then
tools=extract
extract_want="^($(echo "$extract_fields" | sed -e 's/ /|/g' -e 's/_/ /g'))"
fi
exiftool_fields="$(git config metadata.exiftool || :)"
if [ -n "$exiftool_fields" ]; then
tools="exiftool $tools"
exiftool_want="^($(echo "$exiftool_fields" | sed -e 's/ /|/g' -e 's/_/ /g'))"
fi
if [ -z "$tools" ]; then
exit 0
fi
case "$(git config --bool metadata.overwrite || :)" in
true)
equal="="
;;
*)
equal="?="
;;
esac
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against="HEAD"
else
# Initial commit: diff against an empty tree object
against="4b825dc642cb6eb9a060e54bf8d69288fbee4904"
fi
addmeta() {
file="$1"
field="$2"
value="$3"
afield="$(echo "$field" | tr ' ' '_')"
git -c annex.alwayscommit=false annex metadata \
--set "$afield$equal$value" --quiet -- "$file"
}
process() {
if [ -e "$f" ]; then
echo "adding metadata for $f"
for tool in $tools; do
case "$tool" in
exiftool)
tool_exec="exiftool -unknown -zip -veryShort -ignoreMinorErrors -use MWG -dateFormat '%Y-%m-%dT%H:%M:%S'"
;;
*)
tool_exec="$tool"
;;
esac
LC_ALL=C $tool_exec "./$f" | eval egrep --text -i \""\$${tool}_want"\" | while read line; do
case "$tool" in
extract)
field="${line%% - *}"
value="${line#* - }"
;;
exiftool)
field="${line%%: *}"
value="${line#*: }"
;;
esac
if [ -n "$value" ]; then
addmeta "$f" "$field" "$value"
fi
done
done
fi
}
if [ -n "$*" ]; then
for f in "$@"; do
process "$f"
done
else
git diff-index -z --name-only --cached $against | sed 's/\x00/\n/g' | while read f; do
process "$f"
done
fi
```
Source: https://git-annex.branchable.com/tips/using_gitolite_with_git-annex/

5
git.md
View File

@ -40,3 +40,8 @@
- Checkout branch `git checkout -b <someRemoteName>/<branch> <fullRemoteBranchName>`
- Commit changes
- Push: `git push <someRemoteName> HEAD:<branch>`
## Checkout Github PR
- Checkout with same name as on remote: `git fetch origin pull/$ID/head`
- Checkout with same name `<NAME>`: `git fetch origin pull/$ID/head:<NAME>`

7
grep.md Normal file
View File

@ -0,0 +1,7 @@
# Grep
- Highlight all matches while showing all text: `grep --color '<TERM>\|$'`
- `|` is OR
- `\` is escape
- `$` matches everything that has a new line

82
grub.md Normal file
View File

@ -0,0 +1,82 @@
# Grub
- Get Menu number:
```
#!/bin/bash
# NAME: grub-display-lite.sh
# PATH: $HOME/bin
# DESC: Written for AU Q&A: https://askubuntu.com/q/1019213/307523
# DATE: Mar 26, 2018.
# NOTE: "lite" version written for Ubuntu Server and Lubuntu which do
# not have `dialog` installed by default. `whiptail` is used
# instead. Nice consequences are better resolution, mouse scroll
# wheel and copy to clipboard support.
# $TERM variable may be missing when called via desktop shortcut
CurrentTERM=$(env | grep TERM)
if [[ $CurrentTERM == "" ]] ; then
notify-send --urgency=critical "$0 cannot be run from GUI without TERM environment variable."
exit 1
fi
# Version without upstart and recovery options displayed
awk -F\' '/menuentry / { print i++, $2}' /boot/grub/grub.cfg \
| grep -v upstart | grep -v recovery > ~/.grub-display-menu
# Version with upstart and recovery options displayed
#awk -F\' '/menuentry / { print i++, $2}' /boot/grub/grub.cfg \
# > ~/.grub-display-menu
MenuArr=()
while read -r line; do
MenuNmbr=${line%% *}
MenuName=${line#* }
MenuArr+=($MenuNmbr "$MenuName")
done < ~/.grub-display-menu
rm ~/.grub-display-menu
LongVersion=$(grub-install --version)
ShortVersion=$(echo "${LongVersion:20}")
DefaultItem=0
while true ; do
Choice=$(whiptail \
--title "Use arrow, page, home & end keys. Tab toggle option" \
--backtitle "Grub Version: $ShortVersion" \
--ok-button "Display Grub Boot" \
--cancel-button "Exit" \
--default-item "$DefaultItem" \
--menu "Menu Number ----------- Menu Name ----------" 24 76 16 \
"${MenuArr[@]}" \
>/dev/tty)
clear
if [[ $Choice == "" ]]; then break ; fi
DefaultItem=$Choice
for (( i=0; i < ${#MenuArr[@]}; i=i+2 )) ; do
if [[ "${MenuArr[i]}" == $Choice ]] ; then
i=$i+1
MenuEntry="menuentry '"${MenuArr[i]}"'"
break
fi
done
TheGameIsAfoot=false
while read -r line ; do
if [[ $line = *"$MenuEntry"* ]]; then TheGameIsAfoot=true ; fi
if [[ $TheGameIsAfoot == true ]]; then
echo $line
if [[ $line = *"}"* ]]; then break ; fi
fi
done < /boot/grub/grub.cfg
read -p "Press <Enter> to continue"
done
exit 0
```

View File

@ -18,9 +18,9 @@
\usepackage{pdfpages}
\usepackage{transparent}
\newcommand{\incfig}[1]{%
\def\svgwidth{\columnwidth}
\import{./figures/}{#1.pdf_tex}
\newcommand{\incfig}[2][1]{%
\def\svgwidth{#1\columnwidth}
\import{./figures/}{#2.pdf_tex}
}
\begin{figure}[ht]

139
kernel.md
View File

@ -1,17 +1,119 @@
# Kernel
## Get and compile
- Download kernel from kernel.org
- Uncompress the archive
- `cd <linux-kernel>`
- Configure Kernel: `make ARCH=x86_64 nconfig`
- Config is written to `.config`
- Compile the kernel: `make ARCH=x86_64 -j <numProcesses=numCores+1>`
- Compressed kernel is written to `arch/x86/boot/bzImage`
## Get and Prepare Source
- Download kernel from <https://kernel.org>: `wget https://cdn.kernel.org/pub/linux/kernel/<kernelVersion>.tar.{xz,sign}`
- Uncompress the archive: `unxz linux-<kernelVersion>.tar.xz`
- Verify Signature of tar: `gpg2 --verify linux-<kernelVersion>.tar.sign`
- If there is a key issue, import keys: `gpg2 --locate-keys torvalds@kernel.org gregkh@kernel.org`
- Untar the archive: `tar -xvf linux-<kernelVersion>.tar`
- Change ownership: `chown -R jeanclaude:jeanclaude <linuxKernel>`
- `cd <linuxKernel>`
- Clean source: `make mrproper`
## Run in qemu
## Configure
- Config is written to `.config`
### For Qemu
- Create config file `make defconfig`
- Configure for Qemu `make kvm_guest.config`
### Use Hosts Configuration
- Copy the current hosts config: `zcat /proc/config.gz > .config`
- Changing `CONFIG_LOCALVERSION` is required to prevent overwriting a current kernel
- Can by done by setting `LOCALVERSION=-<someSuffix>` for the compile command
- Some options may have changed, run `make olddefconfig` to accept defaults
### Create own configuration
- Configure Kernel: `make nconfig`
## Compilation
- Compile the kernel: `make -j $(nproc)`
- We can also choose $numCores + 1$
- Compressed kernel is written to `arch/x86/boot/bzImage`
- Prepare Modules: `make modules -j $(nproc)`
- Install Modules: `sudo make modules_install`
- Modules are installed to `/lib/modules/<kernelVersion>`
## Prepare initramfs
- Investigate what is in the initramfs using `lsinitcpio <initramfs>`
- Extract to PWD using `lsinitcpio -x <initramfs>`
### Using Busybox
- Simple but has limited utilities
```
#!/bin/bash
ARCH="x86_64"
BB_VER="1.31.0"
# Dirs
mkdir -p root
cd root
mkdir -p bin dev etc lib mnt proc sbin sys tmp var
cd -
# Utils
if [ ! -f "root/bin/busybox" ]; then
curl -L "https://www.busybox.net/downloads/binaries/${BB_VER}-defconfig-multiarch-musl/busybox-${ARCH}" >root/bin/busybox
fi
cd root/bin
chmod +x busybox
ln -s busybox mount
ln -s busybox sh
cd -
# Init process
cat >>root/init << EOF
#!/bin/busybox sh
/bin/busybox --install -s /bin
mount -t devtmpfs devtmpfs /dev
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mount -t tmpfs tmpfs /tmp
setsid cttyhack sh
exec /bin/sh
EOF
chmod +x root/init
# initramfs creation
cd root
find . | cpio -ov --format=newc | gzip -9 >../initramfs
cd -
```
### Using Arch
- Create `./mkinitcpio.conf` with following content:
```
MODULES=(ext4)
HOOKS=(base systemd modconf sd-vconsole filesystems block keyboard)
```
- Enter fakeroot: `fakeroot`
- Create initramfs: `mkinitcpio --generate initramfs.img --kernel <kernel> --config mkinitcpio.conf`
- `<kernel>` is must be located in `/lib/modules/`
- Leave fakeroot: `exit`
## Run in Qemu Step-by-Step
- Most basic `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage`
- Window opens with dmesg output with a panic
- With terminal but not redirected: `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage -nographic`
- Redirect output using kernel argument: `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage -nographic -append "console=ttyS0"`
- Still get panic as there is no root filesystem => no init to run
- Run with initramfs: `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage -nographic -append "console=ttyS0" -initrd initramfs.img`
- Get same panic as there is not enough RAM
- Allocate more memory: `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage -nographic -append "console=ttyS0" -initrd initramfs.img -m 512`
- For busybox this is all which is required
- For arch we get `Failed to start Switch Root.`
- May have increase memory quite a bit more
- Create spares file: `dd if=/dev/zero of=kernel-hd bs=1M count=2048`
- Create FS on virtual HD: `mkfs.ext4 kernel-hd`
- Start using virtual HD: `qemu-system-x86_64 -kernel ../Kernel/arch/x86_64/boot/bzImage -nographic -append "console=ttyS0 root=/dev/sda rootfstype=ext4 rw" -initrd initramfs.img -m 512 -hda kernel-hd`
Copy
## Run in Qemu
- Create dedicated folder
- Copy the kernel `<linux-kernel>/arch/x86/boot/bzImage` here
- Copy the kernel `<linuxKernel>/arch/x86/boot/bzImage` here
- Copy some suitable disk image here
- Start qemu: `qemu-system-x86_64 -smp 1 -nographic -kernel bzImage -append "root=/dev/sda rootfstype=ext4 rw console=ttyS0" -hda <diskImg>`
- `-hda`: disk image
@ -20,3 +122,20 @@
- `-append`: command line parameters to the kernel
- `-nographic`: disable graphic window and use command line instead
- Quit qemu using `Ctrl-a x`
### SSH Into Kernel
- Add the following to start Qemu
```
-netdev user,id=unet,hostfwd=tcp::2222-:22 \
-net user \
```
- Ssh into kernel usign `ssh root@localhost:2222`
## Other
- Generate JSON Compilation Database: `scripts/clang-tools/gen_compile_commands.py`
# Debian/Ubuntu
- Build for: `make -j`nproc` deb-pkg LOCALVERSION=-choose-your-prefix KDEB_PKGVERSION=$(make kernelversion)-1`
- Install `sudo dpkg -i <out>.deb`
- Uninstall `sudo apt remove --purge <kernelName>`
- Taken from list installed kernels: `dpkg --list | grep linux-image`

View File

@ -169,3 +169,6 @@ url = {http://www.hollywoodreporter.com/news/earthquake-twitter-users-learned
- Lstlisting breakts syntax hightliging when a dollar sign is used
- Reset highlighting using `%stopzone` after `\end{lstlisting}`
## Arch Linux
- Find required package: `tlmgr info <LATEX_PACKAGE> | grep collection`

View File

@ -94,15 +94,41 @@
# Wifi
- Wpa2 Enterprise connection for ETH network. Credits to <https://gist.github.com/mvetsch/9bfdee7c56140eae2baa0be711fc8ded>
```
nmcli connection add type wifi con-name eduroam ifname wlp3s0 ssid "eduroam" -- wifi-sec.key-mgmt wpa-eap 802-1x.eap ttls 802-1x.identity [CUT]@student-net.ethz.ch 802-1x.phase2-auth mschapv2 802-1x.domain-suffix-match radius-service.ethz.ch
nmcli connection add type wifi con-name eth ifname wlp3s0 ssid "eth" -- wifi-sec.key-mgmt wpa-eap 802-1x.eap ttls 802-1x.identity [CUT]@student-net.ethz.ch 802-1x.phase2-auth mschapv2 802-1x.domain-suffix-match radius-service.ethz.ch
```
nmcli connection add \
type wifi \
con-name "eduroam" \
ifname "wl" \
ssid "eduroam"
wifi-sec.key-mgmt "wpa-eap" \
802-1x.eap "ttls" \
802-1x.identity "[CUT]@student-net.ethz.ch" \
802-1x.phase2-auth "mschapv2" \
802-1x.domain-suffix-match "radius-service.ethz.ch"
```
- EPFL
```
nmcli connection add \
type wifi \
con-name "eduroam-epfl" \
ifname "wl" \
ssid "eduroam" \
wifi-sec.key-mgmt "wpa-eap" \
802-1x.eap "peap" \
802-1x.identity "jegraf@student-net.ethz.ch" \
802-1x.phase2-auth "mschapv2" \
802-1x.domain-suffix-match "radius-service.ethz.ch" \
802-1x.system-ca-certs "yes" \
# activate with
nmcli connection up eduroam --ask
nmcli connection up eth --ask
```
nmcli connection add type wifi con-name eth ifname wlp3s0 ssid "eth" -- wifi-sec.key-mgmt wpa-eap 802-1x.eap ttls 802-1x.identity [CUT]@student-net.ethz.ch 802-1x.phase2-auth mschapv2 802-1x.domain-suffix-match radius-service.ethz.ch
# activate with
nmcli connection up eduroam --ask
nmcli connection up eth --ask
```
- Connect to ETH VPN: `sudo openconnect https://sslvpn.ethz.ch`
# Mount luks encrypted lvm partition from live boot
@ -212,8 +238,22 @@ cp /etc/resolv.conf /mnt/<chroot>/resolv.conf
- Set back to internal: `pactl set-card-profile 0 output:analog-stereo`
- Connect iPhone
- Install `ifuse` and `xxx`
- Install `ifuse` and `libimobiledevice`
- Connect iPhone, unlock and select trust
- Run `xxxx paird`
- Run `ifuse <mountpoint>`
- Run `idevicepair pair`
- Run `ifuse -o allow_other <mountpoint>`
- The mount point should be owned by the user and not root
- Get log from `dd` by running `sudo kill -USR1 $(pgrep ^dd$)`
# Print
- Server at: <http://localhost:631>
- Wrong `TERM` on ssh (Terminal)
- Copy terminfo to remote: `infocmp | ssh <remote> tic -`
- Display formatting like `\n`, `\t` in less: `printf "$(< <myfile>)" | less`
- Project dos to linux: `find . -type f -print0 | xargs -0 dos2unix
- See all files an executable touches at start: `strace -e openat <ELF>`

View File

@ -27,3 +27,8 @@
- Create mailboxes: `mbsync -c ~/.config/isync/mbsyncrc <NEW_MAIL>`
- Create missing folder: `mkdir ~/.local/share/mail/<NEW_MAIL>/cur`
## Neomutt
- Tag single message: `t`
- Tag thread: `<ESC>t`
- Apply function to all tagged messaged: `;t`
- Move to folder: `s`

View File

@ -18,5 +18,16 @@
- Find broken symlinks
`find <path> -xtype l`
- Find files not belonging to any package:
`sudo lostfiles`
## Tools
- Used files tree: `baobab`
- Find files not belonging to any package: `lostfiles`
## Packages
- Find no longer needed packages: `pacman -Qtd`
- Remove all `pacman -Qtdq | sudo pacman -Rns -`
- Find packages that are only required by cyclic dependencies: `pacman -Qqd | pacman -Rsu --print -`
- Remove all `pacman -Qqd | sudo pacman -Rsu -`
- Find packages only optionally required : `pacman -Qttd`
- Remove all `pacman -Qttdq | sudo pacman -Rns -`
- Find packages that are no longer in the repo: `pacman -Qm`
- Find packages that are only required by cyclic dependencies: `pacman -Qqd | pacman -Rsu --print -`

7
matlab.md Normal file
View File

@ -0,0 +1,7 @@
# Matlab
## Install
- Fix installer by disabling `libfreetype.so.6`
- <https://ch.mathworks.com/matlabcentral/answers/364551-why-is-matlab-unable-to-run-the-matlabwindow-application-on-linux>
- Preferences not beeing saved: <https://ch.mathworks.com/matlabcentral/answers/1806255-why-aren-t-my-preferences-saving>
- All other issues are described on arch wiki

3
pacman.md Normal file
View File

@ -0,0 +1,3 @@
# Pacman
- Print no version info: Add `q` (quiet)

View File

@ -2,8 +2,12 @@
## Exiftool
- show available previews: `exiftool -preview:all <myImage>`
- Extract embedded jpg: `exiftool -b -<PREVIEW_TYPE> -w out.jpg <myImage>`
## Add IPTC
- `exiv2 -M "add Iptc.Application2.Contact jeanggi90@gmail.com" -M "add Iptc.Application2.Copyright Jean-Claude Graf" <img>`
## Make larger edge equals certain size: `convert <inImage> -resize 64x64\> <outImage>`
- Rename according to datetime `exiv2 -r'%Y_%m_%d__%H_%M_%S' -F <IMAGE_PATHS>`
- Rename according to datetime including file structure: `exiftool -r '-FileName<DateTimeOriginal' -d %Y/%m/%d/%%f%%-c.%%e <IMAGE_PATHS>`

34
pinenote.md Normal file
View File

@ -0,0 +1,34 @@
# PineNote
## Enter Load Mode
- Connect using USB cable
- Monitor USB devices: `watch -n 1 lsusb`
- Place device upside down
- Put pen on device as marked
- Power on device
- Monitor `lsusb` for `Fuzhou Rockchip Electronics Company USB download gadget`
- My require pressing power multiple times
- If successful, `rkdeveloptool list` should output `DevNo=1 Vid=0x2207,Pid=0x350a,LocationID=103 Loader`
## Enter UART
- Connect using USB cable via UART
- Enter `picocom /dev/ttyUSB0 -b 1500000 -l`
- Reboot from Android
- Hold `CTRL+c` in picom terminal until `=> <INTERRUPT>` appears
## Enter Fastboot
- Enter UART
- Enter `fastboot usb 0`
- Disconnect the UART adapter and connect the device directly
## Boot to Linux
- Enter UART
- Enter `sysboot ${devtype} ${devnum}:11 any ${scriptaddr} /boot/extlinux.conf`
## Linux
- Available Users:
- `root:root`
- `alarm:alarm`
## TODO
`/etc/systemd/logind.conf.d/*.conf` seems to be ignored, using `/etc/systemd/logind.conf` instead

25
python.md Normal file
View File

@ -0,0 +1,25 @@
# Python
- Disable request for wallet: `python3 -m keyring --disable`
- <https://stackoverflow.com/a/68760190/5464989>
## Virtualenv
- Of specific version:
- Make sure version is available in `/usr/bin/`
- Create env: `virtualenv -p <version> .venv
## Other
- Show packages imported at startup: `python -X importtime -m <pythonFile>`
- Useful to verify lazy loading
## Profiling
- Run profiler: `python -m cProfile -o out.out -- <FILE> <ARGS>`
- Visualize as flow chart: `python -m gprof2dot -f pstats out.out | dot -Tpng -o out.png `
- Deps: [gprof2dot](https://github.com/jrfonseca/gprof2dot)
- By default, excluded negligible nodes/edges. Set `--node-thres 0` (`-n`) and `--edge-thres 0` (`-e`) to include all
- Visualize as starburst (interactively): `python -m snakeviz out.out`
- Deps: [snakeviz](https://jiffyclub.github.io/snakeviz/)
### Profile single function/method
- Import `from profilehooks import profile`
- Add `@profile` to function to profile

View File

@ -6,3 +6,7 @@ rm -r ~/.local/share/qutebrowser/sessions
rm -r ~/.local/share/qutebrowser/webengine
rm -r ~/.cache/qutebrowser
```
- Clear cache of single site:
- Open `:devtools`
- `Application` -> `Application` -> `Storage` -> `Clear Site Data`

21
rss.md Normal file
View File

@ -0,0 +1,21 @@
# RSS
## Feed of Pages
- Search of:
- `rss`
- `xml`
- `atom`
## Feed of Youtube
- For Channel: <https://www.youtube.com/feeds/videos.xml?channel_id=> + ID
- The ID is the value of the key `externalId` found in the source of the channels site
- For Playlist: <https://www.youtube.com/feeds/videos.xml?playlist_id=> + ID
- ID comes in the URL after <https://www.youtube.com/playlist?list=>
## Feed of Github
- Commits to repo: <https://github.com/OWNER/REPO/commits.atom>
- Commits to certain branch: <https://github.com/OWNER/REPO/commits/BRANCH.atom>
- Releases of a repo: <https://github.com/OWNER/REPO/releases.atom>
- Activities of user: <https://github.com/OWNER.atom>

37
rsync.md Normal file
View File

@ -0,0 +1,37 @@
# Rsync
# Status Meaning
> Taken from <https://stackoverflow.com/a/36851784/5464989>
```
YXcstpoguax path/to/file
|||||||||||
||||||||||╰- x: The extended attribute information changed
|||||||||╰-- a: The ACL information changed
||||||||╰--- u: The u slot is reserved for future use
|||||||╰---- g: Group is different
||||||╰----- o: Owner is different
|||||╰------ p: Permission are different
||||╰------- t: Modification time is different
|||╰-------- s: Size is different
||╰--------- c: Different checksum (for regular files), or
|| changed value (for symlinks, devices, and special files)
|╰---------- the file type:
| f: for a file,
| d: for a directory,
| L: for a symlink,
| D: for a device,
| S: for a special file (e.g. named sockets and fifos)
╰----------- the type of update being done::
<: file is being transferred to the remote host (sent)
>: file is being transferred to the local host (received)
c: local change/creation for the item, such as:
- the creation of a directory
- the changing of a symlink,
- etc.
h: the item is a hard link to another item (requires
--hard-links).
.: the item is not being updated (though it might have
attributes that are being modified)
*: means that the rest of the itemized-output area contains
a message (e.g. "deleting")
```

21
system.md Normal file
View File

@ -0,0 +1,21 @@
# System Stuff
## Cache
### Word
- Can have two meanings:
- In assembly: 2 bytes
- In systems: bitwith (32b or 64b)
### Page
- Granularity of paging.
- 1024 bytes
### Cache Line/Block
- Number of consecutive bytes cached together to exploit spacial locality
- 64 bytes
### Inclusive, Exclusive, Non-Inclusive
- If all blocks in the higher level cache are also present in the lower level cache, then the lower level cache is said to be inclusive of the higher level cache.
- If the lower level cache contains only blocks that are not present in the higher level cache, then the lower level cache is said to be exclusive of the higher level cache.
- If the contents of the lower level cache are neither strictly inclusive nor exclusive of the higher level cache, then it is called non-inclusive non-exclusive (NINE) cache.

40
vim.md
View File

@ -26,3 +26,43 @@
- Count words: press `g` and `ctrl-g`
- Also works with selections
## LSP
- Show which code action are supported by a language server: `:lua print(vim.inspect(vim.lsp.buf_get_clients()[1].resolved_capabilities))`
## Insert Mode Bindings
> From [here](https://www.reddit.com/r/vim/comments/4w0lib/comment/d63baic/?utm_source=share&utm_medium=web2x&context=3)
I would not remap any of these:
- <C-@> and <C-A>: Repeat last insert (and automatically escape with <C-@>). These are basically the same as <C-R>.. Indispensable once you get used to them.
- <C-D> and <C-T>: Change indent level even if you're not at the beginning of the line. Handy, but I don't use it much.
- <C-E> and <C-Y>: Copy character from below/above the cursor. Sort of useful, not terribly. But not having them would drive me nuts.
- <C-G>: A prefix key. I don't really care about <C-G>u to split the insert into multiple undo levels. Almost no one uses <C-G>j/<C-G>k to start a new insert a line down/up at the same column the current insert started on, but I'm a huge fan. I wouldn't touch this.
- <C-I>: This is literally the same as <Tab>. Don't you dare touch this.
- <C-M>: This is literally the same character you get from hitting Enter. Don't you dare touch this.
- <C-N> and <C-P>: Basic word completion. Extremely useful. I would never touch this.
- <C-O>: Return to insert after a single normal command. You can always just use escape. Has its uses though.
- <C-Q> and <C-S>: Since these are used by terminals for the locking feature, they're unbound in basically every terminal program. That makes them great candidates for screen/tmux prefixes (if you disable the locking feature first). Generally not safe for portable remapping though.
- <C-R>: Like pasting registers from insert mode. This is extremely useful and should not be touched.
- <C-U> and <C-W>: Delete line/word. Extremely useful. Works similar but not exactly the same as in cooked terminal though, which is frustrating...
- <C-V>: Insert literal characters. I use this a lot.
- <C-X>: A prefix to several completion functions. I would say <C-X><C-F> is probably the most indispensable (complete filename), but a lot of them are handy. Read :help i^X to learn about them all.
- <C-[>: This is literally <Esc>. Don't you dare touch it.
I wouldn't mind remapping these:
- <C-B>: This is safe.
- <C-C>: Really escape. I'm not a big fan.
- <C-F>: This is safe.
- <C-H> and <C-?>: These behave the same as backspace, but they aren't literally backspace. I wouldn't mind too much if I lost these.
- <C-J>: Literal newline. Not used too much in its own right. If mappings worked in <C-R> pastes, remapping this would mess up your multiline pastes, but since they don't, it should be safe to remap.
- <C-K>: Digraphs. I don't use them. If you just need occasional characters maybe, like a single Greek character or a way to type an em dash, they're fine. If you try to type in a foreign script using this feature, God help you.
- <C-L>: This is safe.
- <C-Z>: In a terminal, backgrounds Vim, though it shouldn't do that in insert mode.
- <C-\>: This is mostly safe. If you're using <C-O> in mappings, you should probably use <C-\><C-O> instead, so the cursor doesn't shift inconsistently if you're at the end of the line. It's very unlikely I'd use that outside of mappings though.
- <C-]>: Abbreviations. I've never used this.
- <C-^>: Useless in insert mode.
- <C-_>: Toggling reverse insert (if you have some special nondefault settings). Useless for almost everyone.
## Performance
- Show startup time using flag `--startuptime <OUT_FILE>`

4
virtualbox.md Normal file
View File

@ -0,0 +1,4 @@
# Virtualbox
## Guest Edition
- Install `virtualbox-guest-iso`

7
x86_64.md Normal file
View File

@ -0,0 +1,7 @@
# x86_64
## User Address Space:
- 0x0000000000000000 to 0x00007FFFFFFFFFFF (0 to 128 TB)
## Kernel Address Space:
- 0xFFFF800000000000 to 0xFFFFFFFFFFFFFFFF