Skip to content

Instantly share code, notes, and snippets.

View rpromyshlennikov's full-sized avatar

Rodion Promyshlennikov rpromyshlennikov

View GitHub Profile
@rpromyshlennikov
rpromyshlennikov / ssh_remote_port_forwarding
Created August 30, 2024 15:22
SSH remote port forwarding to VM in network
# Purpose:
# You have remoteserver.example.com with up & running Nginx, there is a TLS cert on it. You need to serve something in your localnetwork securely to Internet.
# Terminating HTTPs on remoteserver.example.com: remoteserver.example.com:443/ --proxy_pass--> http://localhost:18089/
# Target host (192.168.0.226) is in your local network (also it could be VM on your machine) behind NAT on your router (it's your gateway for network 192.168.0.0/24)
# Target server runs on target host on port 8089 (192.168.0.226:8089)
#
# That's all.
ssh -NR localhost:18089:192.168.0.226:8089 remoteserver.example.com
@rpromyshlennikov
rpromyshlennikov / check_go_compiler_version.sh
Created November 9, 2021 20:07
Batch check of Golang compiler version used to build binaries
for file in $(find -name 'some-*-binary-name-and-version-*3.0.1-*'); do echo "========================================"; echo $file; echo "========================================"; gdb -ex "p 'runtime.buildVersion'" -ex quit $file 2>&1| grep 'str = '; done
@rpromyshlennikov
rpromyshlennikov / golang_cover_extract_from_html.js
Created September 20, 2021 20:36
Extract coverage of golang files by JS oneliner from HTML cover tool report
[...$('#files').options].map(o => o.text)
@rpromyshlennikov
rpromyshlennikov / replace_GOROOT_GoLand.sh
Created February 17, 2021 19:56
Replace GOROOT in all GoLand projects in directory
find ~/work/go/ \( -name 'workspace.xml' -o -name 'misc.xml' \) -type f | xargs grep GOROOT | cut -d':' -f 1 | grep -v old_repos | xargs sed -e 's/go1.\([0-9]\+\).\([0-9]\+\)/go1.15.7/g' | grep GOROOT
find ~/work/go/ \( -name 'workspace.xml' -o -name 'misc.xml' \) -type f | xargs grep GOROOT | cut -d':' -f 1 | grep -v old_repos | xargs sed -i -e 's/go1.\([0-9]\+\).\([0-9]\+\)/go1.15.7/g'
@rpromyshlennikov
rpromyshlennikov / gitlab_group_dl.sh
Last active August 1, 2020 08:55
Clone all projects of the group in Gitlab
#!/usr/bin/env bash
# Released under MIT License
# Copyright (c) 2020 Rodion Promyshlennikov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@rpromyshlennikov
rpromyshlennikov / table_to_csv.js
Created January 28, 2020 13:01
Convert HTML table to CSV
csv = []
var rows = document.querySelectorAll("table tr");
for (var i = 0; i < rows.length; i++) {
var row = [], cols = rows[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++)
row.push(cols[j].innerText);
csv.push(row.join("|"));
}
@rpromyshlennikov
rpromyshlennikov / start_services.sh
Last active May 22, 2019 12:56
Start services in one xfce4-terminal window in diff tabs
#!/usr/bin/env bash
set -e
xfce4-terminal -e 'env PROMPT_COMMAND="unset PROMPT_COMMAND;docker start <docker_id>" bash'
xfce4-terminal --tab -T nService \
-e 'env PROMPT_COMMAND="unset PROMPT_COMMAND; cd work_dir/nService; source ../prepare_env_.sh; make build && ./nService -console" bash' \
--tab -T mService \
-e 'env PROMPT_COMMAND="unset PROMPT_COMMAND; cd work_dir/mService; source ../prepare_env_.sh; make build && ./mService -console" bash'
@rpromyshlennikov
rpromyshlennikov / grant_all.sql
Last active April 3, 2023 13:56
Grant all on DB to new user
GRANT CONNECT ON DATABASE "db-name" TO "user-name";
\c "db-name"; -- REQUIRED!!
GRANT USAGE ON SCHEMA "schema-name" TO "user-name";
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA "schema-name" TO "user-name";
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA "schema-name" TO "user-name";
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA "schema-name" TO "user-name";
GRANT ALL PRIVILEGES ON DATABASE "db-name" TO "user-name";
REVOKE USAGE ON SCHEMA "schema-name" FROM "user-name";
@rpromyshlennikov
rpromyshlennikov / sync_repos.sh
Created May 13, 2019 21:41
Fetch all repos in directory (recursively by 2 levels)
find /home/user/work/ -mindepth 1 -maxdepth 2 -type d -exec git -C {} fetch --all \;
  • wget https://github.com/pgmodeler/pgmodeler/archive/v0.9.1.zip
  • unzip v0.9.1.zip
  • mv pgmodeler-0.9.1/ pgmodeler
  • cd pgmodeler/
  • sudo apt install qt5-default libpq-dev libxml2-dev qttools5-dev-tools clang qt5-image-formats-plugins libqt5svg5 libqt5svg5-dev
  • ./linuxdeploy.sh
  • cd dist/
  • tar -xzvf pgmodeler-0.9.1-linux64.tgz
  • mv pgmodeler-0.9.1-linux64 /opt/pgmodeler/
  • /opt/pgmodeler/pgmodeler-0.9.1-linux64/start-pgmodeler.sh