IT notes

ddcctl

To share one monitor, keyboard and mouse between two devices, mac mini and a macbook try: brew cask install barrier Then to avoid changing the input source by using the buttons in the monitor try https://github.com/kfix/ddcctl: cd /tmp git clone https://github.com/kfix/ddcctl.git cd ddcctl make && make install In my case to switch from the mac mini (HDMI) to the laptop via (DP) I use: ddcctl -d 1 -i 15 From the laptop (USB-C -> DP) to HDMI, switch back to the mac mini:

timestamp

To get the current unix timestamp: date +%s To get the date from a timestamp: date -r 1559591041 In Linux: date -d "@1559591041"

docker prune

Docker cleanup:  docker system prune -a

rust docker

Dockerfile to create small rust docker images: FROM clux/muslrust RUN mkdir /source WORKDIR /source COPY . . RUN cargo build --release RUN strip ./target/x86_64-unknown-linux-musl/release/myapp FROM scratch COPY --from=0 /source/target/x86_64-unknown-linux-musl/release/myapp / CMD ["./myapp"] Image compatible with cloud foundry: FROM rust:1.35 WORKDIR /usr/src/myapp COPY . . RUN cargo build --release FROM debian:latest RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y openssl ca-certificates COPY --from=0 /usr/src/myapp/target/release/myapp / CMD ["./myapp"]

mysql pager

To use less command to vie the output of a mysql result you could use: mysql> \P less or mysql> pager less Then run something like: mysql> show engine innodb status\G In some cases you may need to search for something in specific for this grep could be used, for example: mysql> \P grep -A7 "ROW OPERATIONS" PAGER set to 'grep -A7 "ROW OPERATIONS"' Then when running the command it will only return 7 lines after “ROW OPERATIONS”

//+build disable

In go if need to sketch something and end having func main() in two files, you could ignore building one by adding at the top of the file: // +build disable This is a build constraint. A build constraint, also known as a build tag, is a line comment that begins: // +build

delete file

Ways to delete a file starting with a dash / hyphen: rm -- -file The option -- means the end of options for the command. Another option is to indicate where is the file: rm ./-file . is current directory , path to -file is ./-file Using find: find . -type f -exec rm {} \; Finding the inode: ls -li Then using find and the inode it can be removed with:

galera SOS

Check status of cluster: https://nbari.com/post/galera/ Find process list not sleeping: SELECT user, time, state, info FROM information_schema.processlist WHERE command != 'Sleep' AND time >= 2 ORDER BY time DESC, id; Get locked tables: show open tables where in_use > 0; Finding locks: show engine innodb status; At the end: ---TRANSACTION 1135701157, ACTIVE 6768 sec MySQL thread id 5208136, OS thread handle 0x7f2982e91700, query id 882213399 xxxIPxxx 82.235.36.49 my_user cleaning up kill the transaction thread:

pigz

To compress using gzip format but using all your available cores: tar --use-compress-program=pigz -cf archive.tgz /path/to/source Or if you want to pipe it: tar -cf - source | pigz > archive.tgz To decompress use tar -xvf archive.tgz as usual. The output of pigz is compatible with gzip

zsh

Edit environment variables: vared PATH Diff command output creating temporary normal files vimdiff =(ls /bin) =(ls /usr/bin) Print path print -l $path Run a command detached &! or &| put it in background and disown the process, exiting the shell will leave it running: sleep 300 &!