-
Caps as Ctrl using udev
# evtest ... /dev/input/event3: AT Translated Set 2 keyboard ... Select the device event number [0-15]: 3 Input driver version is 1.0.1 Input device ID: bus 0x11 vendor 0x1 product 0x1 version 0xab83 ... Press Caps Lock ... Event: time 1724100071.543479, -------------- SYN_REPORT ------------ Event: time 1724100075.002355, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a Event: time 1724100075.002355, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 1 Event: time 1724100075.002355, -------------- SYN_REPORT ------------ Event: time 1724100075.002712, type 17 (EV_LED), code 1 (LED_CAPSL), value 1 Event: time 1724100075.002712, -------------- SYN_REPORT ------------ Event: time 1724100075.260580, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a Event: time 1724100075.260580, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 2 Event: time 1724100075.260580, -------------- SYN_REPORT ------------ Event: time 1724100075.280859, type 4 (EV_MSC), code 4 (MSC_SCAN), value 3a Event: time 1724100075.280859, type 1 (EV_KEY), code 58 (KEY_CAPSLOCK), value 0 Event: time 1724100075.280859, -------------- SYN_REPORT ------------ ...
bus=
0011
vendor=0001
product=0001
version=AB83
scan=3A
/etc/udev/hwdb.d/caps-to-ctrl.hwdb
:evdev:input:b0011v0001p0001eAB83-* KEYBOARD_KEY_3A=leftctrl
systemd-hwdb update udevadm trigger
-
Delete prometheus series
curl -g -i -X POST 'https://prometheus.cmctech.pro/api/v1/admin/tsdb/delete_series?match[]=container_memory_working_set_bytes:max_by_pod_base_name{namespace="loki",pod_base_name="loki"}&end=2024-05-09T20:00:00Z'
-
Using aws cli for S3 inside docker
read AWS_ACCESS_KEY_ID read AWS_SECRET_ACCESS_KEY export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY docker run --rm \ -e 'AWS_ACCESS_KEY_ID' -e 'AWS_SECRET_ACCESS_KEY' \ -v "$PWD:/aws" \ 'docker.io/amazon/aws-cli:latest' \ --endpoint-url='https://archive.pscloud.io' \ --region='kz-ala-1' \ s3 cp './local-file' 's3://bucket/key/name'
-
docker cmd for sleep responding to signals
docker run --rm -it alpine:3 sh -c 'trap true TERM; sleep 1 & while wait $!; do sleep 1 & done'
-
gdb cheatsheet
target remote 127.0.0.1:4242 p/z $r0 # print, z: hex; t: two x/z 0x40021008 # eXamine display/z $r0 display/4i $pc - 1 display/z *((int*)$sp)@4 stepi # step instruction info registers
-
Install homebrew package without homebrew
Example URLs:
https://formulae.brew.sh/formula/stlink https://formulae.brew.sh/api/formula/stlink.json .bottle.stable.arm64_ventura.url: https://ghcr.io/v2/homebrew/core/stlink/blobs/sha256:37bc6182a2709fbcd5046be4c1cb93936475f12d2ee42983e9f7802ed89bc97c https://formulae.brew.sh/api/formula/libusb.json .bottle.stable.arm64_ventura.url: https://ghcr.io/v2/homebrew/core/libusb/blobs/sha256:ea8a4a04b5cc81eff38d0c5cdfe2fbac519ca2c7652c64371074f4abaf766a0b
Keychain Access, Certificate Assistant, Create a Certificate, Code Signing
curl -L -H 'Authorization: Bearer QQ==' -o 'stlink-bottle.tar.gz' 'https://ghcr.io/v2/homebrew/core/stlink/blobs/sha256:37bc6182a2709fbcd5046be4c1cb93936475f12d2ee42983e9f7802ed89bc97c' curl -L -H 'Authorization: Bearer QQ==' -o 'libusb-bottle.tar.gz' 'https://ghcr.io/v2/homebrew/core/libusb/blobs/sha256:ea8a4a04b5cc81eff38d0c5cdfe2fbac519ca2c7652c64371074f4abaf766a0b' tar -x -f stlink-bottle.tar.gz tar -x -f libusb-bottle.tar.gz mkdir stlink-1.7.0 mv stlink/1.7.0/bin/* stlink-1.7.0/ mv libusb/1.0.26/lib/libusb-1.0.0.dylib stlink-1.7.0/ otool -L stlink-1.7.0/st-flash install_name_tool -change '@@HOMEBREW_PREFIX@@/opt/libusb/lib/libusb-1.0.0.dylib' '/opt/stlink-1.7.0/libusb-1.0.0.dylib' stlink-1.7.0/st-flash install_name_tool -change '@@HOMEBREW_PREFIX@@/opt/libusb/lib/libusb-1.0.0.dylib' '/opt/stlink-1.7.0/libusb-1.0.0.dylib' stlink-1.7.0/st-info install_name_tool -change '@@HOMEBREW_PREFIX@@/opt/libusb/lib/libusb-1.0.0.dylib' '/opt/stlink-1.7.0/libusb-1.0.0.dylib' stlink-1.7.0/st-trace install_name_tool -change '@@HOMEBREW_PREFIX@@/opt/libusb/lib/libusb-1.0.0.dylib' '/opt/stlink-1.7.0/libusb-1.0.0.dylib' stlink-1.7.0/st-util codesign -s 'Vladimir Bezhenar' -f stlink-1.7.0/st-flash codesign -s 'Vladimir Bezhenar' -f stlink-1.7.0/st-info codesign -s 'Vladimir Bezhenar' -f stlink-1.7.0/st-trace codesign -s 'Vladimir Bezhenar' -f stlink-1.7.0/st-util sudo cp -r stlink-1.7.0 /opt/stlink-1.7.0
-
keytool cheatsheet
keytool -import -alias alias -keystore keystore.jks -file certificate.der
-
kubectl exec etcdctl
Invoking etcdctl using kubectl for kubeadm cluster
kubectl exec -n kube-system etcd-control-0 -- sh -c 'ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt --key /etc/kubernetes/pki/etcd/server.key member list'
-
maven minimal pom.xml
pom.xml
:<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <groupId>java-21-test</groupId> <artifactId>java-21-test</artifactId> <version>0.0.0-SNAPSHOT</version> <properties> <maven.compiler.release>21</maven.compiler.release> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven-clean-plugin.version>3.3.2</maven-clean-plugin.version> <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version> <maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version> <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> <maven-resources-plugin.version>3.3.1</maven-resources-plugin.version> <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version> <maven-toolchains-plugin.version>3.1.0</maven-toolchains-plugin.version> <versions-maven-plugin.version>2.16.2</versions-maven-plugin.version> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <executions> <execution> <id>enforce-maven</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireMavenVersion> <version>3.9.5</version> </requireMavenVersion> </rules> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-toolchains-plugin</artifactId> <executions> <execution> <goals> <goal>toolchain</goal> </goals> </execution> </executions> <configuration> <toolchains> <jdk> <version>21</version> </jdk> </toolchains> </configuration> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-clean-plugin</artifactId> <version>${maven-clean-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>${maven-compiler-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>${maven-enforcer-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>${maven-jar-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>${maven-resources-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>${maven-surefire-plugin.version}</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-toolchains-plugin</artifactId> <version>${maven-toolchains-plugin.version}</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>versions-maven-plugin</artifactId> <version>${versions-maven-plugin.version}</version> </plugin> </plugins> </pluginManagement> </build> </project>
~/.m2/toolchains.xml
:<?xml version="1.0" encoding="UTF-8"?> <toolchains> <toolchain> <type>jdk</type> <provides> <version>1.8</version> <vendor>openjdk</vendor> </provides> <configuration> <jdkHome>/opt/jdk-1.8/</jdkHome> </configuration> </toolchain> <toolchain> <type>jdk</type> <provides> <version>11</version> <vendor>openjdk</vendor> </provides> <configuration> <jdkHome>/opt/jdk-11/</jdkHome> </configuration> </toolchain> <toolchain> <type>jdk</type> <provides> <version>17</version> <vendor>openjdk</vendor> </provides> <configuration> <jdkHome>/opt/jdk-17/</jdkHome> </configuration> </toolchain> <toolchain> <type>jdk</type> <provides> <version>21</version> <vendor>openjdk</vendor> </provides> <configuration> <jdkHome>/opt/jdk-21/</jdkHome> </configuration> </toolchain> </toolchains>
mvn versions:display-property-updates
-
openssl print utf8
openssl x509 -in cert.pem -nameopt utf8,sep_multiline -text
-
Oracle Linux Cloud default user
cloud-user
-
Idea SLF4J logger live template
``` private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger($CLASS$.class); ``` Applicable in Java: declaration CLASS: className(), Skip if defined -
psql essentials
Invocation:
psql -h host -p port -U user dbname
List tables:
\dt [*tbl*]
Show DDL:
\d tbl
-
Customize fat label with qemu virtual fat driver
-blockdev driver=vvfat,node-name=cidata,read-only=on,dir="$cidata_dir",label='CIDATA' \ -device virtio-blk-pci,drive=cidata \
-
Retrieve graphql schema
npm install gql-sdl npx gql-sdl -H 'Cookie:auth=token' https://example.com/graphql > example.graphql