Skip to content

Instantly share code, notes, and snippets.

View mator's full-sized avatar
🏠
Working from home

Anatoly Pugachev mator

🏠
Working from home
  • Russia, Moscow
View GitHub Profile
@mator
mator / gist:b981ad3bb26655d52252743a6515c1c8
Last active September 20, 2023 10:48
sed escaped replace
https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern
ESCAPED_REPLACE=$(printf '%s\n' "$REPLACE" | sed -e 's/[\/&]/\\&/g')
# Now you can use ESCAPED_REPLACE in the original sed statement
sed "s|KEYWORD|${ESCAPED_REPLACE}|g"
if you have "base64 -w 0" string (even multiline), it does not needs to be escaped
@mator
mator / gist:14e7a6155bce5f967250a5432199e6c4
Last active August 29, 2023 08:03
archlinux pacman resync missing files
check first
pacman -Qk 2>/dev/null | awk -F: '! /0 missing files$/ {print $1}' | xargs pacman -S
then use `--noconfirm` as last option
@mator
mator / gist:319a8a3d1c2bcd2fb4ebfd96c78da941
Last active August 14, 2023 09:58
macbook pro, 16 inch 2023, Apple M2 Max + hashcat
see as well
https://gist.github.com/mator/783c6672158bd0d584b0a6c87f1d681c
running on macbook pro, 16" 2023, Apple M2 Max, Ventura 13.5
% brew install hashcat
...
read-only доступ для пользователя readonly до базы db1 для PostgreSQL версии меньше чем 14.x:
\c db1
CREATE USER readonly WITH PASSWORD 'xxx';
GRANT CONNECT ON DATABASE db1 TO readonly;
GRANT USAGE ON SCHEMA public TO readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
с версии 14.x появилась возможность использовать predefined role "pg_read_all_data" (заменяющая последние две команды SQL: USAGE/SELECT) :
GRANT pg_read_all_data TO userA;
@mator
mator / ttip-dmesg-boot-log
Last active October 4, 2021 12:38
ttip domain (sparc64) without perf-counters set, message "NMI appears to be stuck"
setting domain perf-counters to strand, fixes issue:
$ ldm set-domain perf-counters=strand ttip
Linux LDOM boot logs:
$ dmesg
[ 0.000017] PROMLIB: Sun IEEE Boot Prom 'OBP 4.38.17 2019/01/25 08:22'
[ 0.000020] PROMLIB: Root node compatible: sun4v
[ 0.000055] Linux version 5.9.0-4-sparc64-smp (debian-kernel@lists.debian.org) (gcc-10 (Debian 10.2.0-19) 10.2.0, GNU ld (GNU Binutils for Debian) 2.35.1) #1 SMP Debian 5.9.11-1 (2020-11-27)
[ 0.000349] printk: bootconsole [earlyprom0] enabled
[ 0.000394] ARCH: SUN4V
@mator
mator / gist:783c6672158bd0d584b0a6c87f1d681c
Created August 18, 2021 16:21
NVIDIA Tesla T4 benchmark (hashcat 6.2.3)
Testing Nvidia Tesla T4 with hashcat under Centos Linux 7
Actually, the server has 2 tesla's installed, and first one is occupied with the task,
so we testing and showing info on the second tesla.
linux:
```
$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
$ uname -a
@mator
mator / gist:112d2bdde984a9824a7e0ed236dd6ab8
Last active June 15, 2021 13:40
Centos 7 / Amazon Linux sshguard install (without repo)
Probably the easiest way to install latest version of sshguard (at the time of writting, sshguard 2.4.0)
on Amazon Linux (v2) or Centos 7, is to use fedora src.rpm package. Since there's no available repos,
probably except of http://download.opensuse.org/repositories/home:/blarson:/sshguard/ which is outdated anyway.
Fedora packages are available at [Fedora package sources](https://src.fedoraproject.org/rpms/sshguard)
So using 'Fedora EPEL 7' package.
You could use binary package there, or follow steps below to compile it locally on your machine.
@mator
mator / gist:4c223e8da0402fb8ef83bf368894589e
Created May 30, 2021 22:21
sparc64 stress-ng 0.12.09 run
mator@ttip:/1/mator/stress-ng$ ./stress-ng --version
stress-ng, version 0.12.09 (gcc 10.2, sparc64 Linux 5.13.0-rc3-00261-g97e5bf604b7a) 💻🔥
mator@ttip:/1/mator/stress-ng$ ./stress-ng --sequential -1 --oomable --pathological --timeout 15s --timestamp -v --metrics-brief
stress-ng: 01:19:53.69 debug: [1482450] system: Linux ttip 5.13.0-rc3-00261-g97e5bf604b7a #222 SMP Fri May 28 18:27:24 MSK 2021 sparc64
stress-ng: 01:19:53.69 debug: [1482450] RAM total: 33.5G, RAM free: 32.6G, swap free: 724.2M
stress-ng: 01:19:53.69 debug: [1482450] 16 processors online, 256 processors configured
...
@mator
mator / stress-ng-sequential.log
Last active April 14, 2021 07:02
stress-ng run log in sequential mode from non-root user on sparc64 linux
mator@ttip:/1/mator/stress-ng$ git desc
V0.12.06-45-gef68f05b
$ ./stress-ng --sequential 2 --timeout 90s --pathological --metrics -v
stress-ng: debug: [4015818] system: Linux ttip 5.12.0-rc7 #206 SMP Mon Apr 12 14:10:06 MSK 2021 sparc64
stress-ng: debug: [4015818] RAM total: 33.5G, RAM free: 32.6G, SWAP free: 731.6M
stress-ng: debug: [4015818] 24 processors online, 256 processors configured
stress-ng: info: [4015818] apparmor: stressor will be skipped, AppArmor is not available
stress-ng: info: [4015818] binderfs stressor will be skipped, need to be running with CAP_SYS_ADMIN rights for this stressor
stress-ng: info: [4015818] chroot stressor will be skipped, need to be running with CAP_SYS_ADMIN rights for this stressor
@mator
mator / gist:a44eb39d5103aaaea2f1b2f3856c391d
Created December 14, 2020 15:44
[sparc64] ftrace: kernel logs after enabling CONFIG_FTRACE_STARTUP_TEST
-- Journal begins at Mon 2020-10-12 23:40:31 MSK, ends at Mon 2020-12-14 17:36:21 MSK. --
Dec 14 13:48:15 kernel: PROMLIB: Sun IEEE Boot Prom 'OBP 4.38.17 2019/01/25 08:22'
Dec 14 13:48:15 kernel: PROMLIB: Root node compatible: sun4v
Dec 14 13:48:15 kernel: Linux version 5.10.0 (mator@ttip) (gcc (Debian 10.2.1-1) 10.2.1 20201207, GNU ld (GNU Binutils for Debian) 2.35.1) #155 SMP Mon Dec 14 13:32:10 MSK 2020
Dec 14 13:48:15 kernel: printk: bootconsole [earlyprom0] enabled
Dec 14 13:48:15 kernel: ARCH: SUN4V
Dec 14 13:48:15 kernel: Ethernet address: 00:14:4f:fa:06:f2
Dec 14 13:48:15 kernel: MM: PAGE_OFFSET is 0xfff8000000000000 (max_phys_bits == 47)
Dec 14 13:48:15 kernel: MM: VMALLOC [0x0000000100000000 --> 0x0006000000000000]
Dec 14 13:48:15 kernel: MM: VMEMMAP [0x0006000000000000 --> 0x000c000000000000]