Skip to content

Instantly share code, notes, and snippets.

View kyberorg's full-sized avatar

Aleksandr Muravja kyberorg

View GitHub Profile
@kyberorg
kyberorg / postgresql-docker.sh
Created April 23, 2021 13:23
Dump (Backup) and Restore dockerized PostgreSQL
# Backup
docker exec -t your-db-container pg_dumpall -c -U your-db-user > your_dump.sql
# Restore
cat your_dump.sql | docker exec -i your-db-container psql -U your-db-user -d your-db-name
@kyberorg
kyberorg / grafana_telegram_bot.md
Created February 17, 2021 15:24 — forked from ilap/grafana_telegram_bot.md
Grafana Telegram Alert

Config Telegrambot for grafana's alerts.

1. Create bot

Open Telegram and search for @BotFather user and message them the following:

You
/newbot 

BotFather
@kyberorg
kyberorg / gist:1c335cbb1be6972b5f20e9d24886a475
Created February 8, 2021 14:37
GraalVM 21.0.0 + Docker
FROM ghcr.io/graalvm/graalvm-ce:21.0.0 AS build-aot
RUN curl https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -o /tmp/maven.tar.gz
RUN tar xf /tmp/maven.tar.gz -C /opt
RUN ln -s /opt/apache-maven-3.6.3 /opt/maven
RUN ln -s /opt/graalvm-ce-java11-21.0.0 /opt/graalvm
RUN gu install native-image
ENV JAVA_HOME=/opt/graalvm
ENV M2_HOME=/opt/maven
@kyberorg
kyberorg / a.sh
Created December 27, 2020 18:49
Debugging OpenJ9 in Docker
$ cd /tmp
$ curl -L https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11_openj9-0.23.0/OpenJDK11U-jdk_x64_linux_openj9_11.0.9_11_openj9-0.23.0.tar.gz --output jdk.tgz
$ tar -zxvf jdk.tgz
$ jdk-11.0.9+11/bin/jps -l
687 jdk.jcmd/openj9.tools.attach.diagnostics.tools.Jps
7 /opt/webservice/webservice.jar
$ jdk-11.0.9+11/bin/jcmd 7 GC.heap_dump /tmp/heapdump
Dump written to /tmp/heapdump
@kyberorg
kyberorg / dump.sh
Last active September 30, 2020 07:28
PostgreSQL new DB and Dump
/usr/local/pgsql-12/pg_dumpall --file "/var/lib/pgadmin/storage/tech_yadev.eu/dump-12.3.sql" --host "db-postgre.db.svc.cluster.local" --port "5432" --username "toor" --no-password --database "postgres" --verbose
@kyberorg
kyberorg / grant.sql
Created July 24, 2020 12:53
MySQL Grant
GRANT ALL PRIVILEGES ON *.* TO 'toor'@'10.x.x.x' IDENTIFIED BY 'xxxxxpassword' WITH GRANT OPTION;
flush privileges;
@kyberorg
kyberorg / a.MD
Last active July 13, 2020 13:57
PostgreSQL vs. MySQL
MySQL PostgreSQL Description
mysql -u -p<password psql -U -P Start command line client, and connect to
SHOW DATABASES; \l Show available databases
SHOW TABLES; \dt Show available tables
USE ; \c Connect to
DESCRIBE ;
\d
Describe structure
SHOW FULL PROCESSLIST; SELECT * FROM pg_stat_a

Keybase proof

I hereby claim:

  • I am kyberorg on github.
  • I am kyberorg (https://keybase.io/kyberorg) on keybase.
  • I have a public key ASCyQp6QJdevXfRTT_CmsnU7yFZ4pMsq9NjuZCU3dBcydAo

To claim this, I am signing this object:

@kyberorg
kyberorg / a.txt
Created July 1, 2020 08:18
HeapDumps from Docker
# docker exec 0c34 ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 2388 764 ? Ss 08:11 0:00 /bin/sh -c ./docker-entrypoint.sh
root 6 47.8 7.0 7887600 1134504 ? Sl 08:11 2:06 java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:8000 -Djava.security.egd=file:/dev/./urandom --add-opens java.base/java.lang=ALL-UNNAMED -XX:+UseContainerSupport -XX:+AlwaysActAsServerClassMachine -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/dumps -jar /app/yals.jar
root 487 0.0 0.0 9392 3088 ? Rs 08:16 0:00 ps aux
# docker exec 0c34 jcmd 6 GC.heap_dump /opt/dumps/test.dump
6:
Heap dump file created
@kyberorg
kyberorg / a.txt
Created June 30, 2020 08:33
Bash Params Magic
+--------------------+----------------------+-----------------+-----------------+
| Expression | FOO="world" | FOO="" | unset FOO |
| in script: | (Set and Not Null) | (Set But Null) | (Unset) |
+--------------------+----------------------+-----------------+-----------------+
| ${FOO:-hello} | world | hello | hello |
| ${FOO-hello} | world | "" | hello |
| ${FOO:=hello} | world | FOO=hello | FOO=hello |
| ${FOO=hello} | world | "" | FOO=hello |
| ${FOO:?hello} | world | error, exit | error, exit |
| ${FOO?hello} | world | "" | error, exit |