Skip to content

Instantly share code, notes, and snippets.

{"schemaVersion":1,"label":"coverage","message":"56%","color":"yellow"}
import random
import re
codes = []
doubles = r"00|11|22|33|44|55|66|77|88|99"
while (codes.__len__() < 90):
code = random.randint(1000, 9999)
if code not in codes and not re.search(doubles, str(code)):
codes.append(code)
@piotr-grzelka
piotr-grzelka / .env
Created January 3, 2022 09:35
pg backup to aws
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_BACKUP_BUCKET=backup
S3_URL=http://localstack:4572
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_USER=postgres
DATABASE_PASS=
DATABASES=db1,db2,db3
"""
Skrypt sprawdzający czy są zmiany w liście egzaminów na stronie PZSS
W przypadku wykrycia zmian wysyła powiadomienie na aplikację pushover
pip install python-pushover
python3 pzss-exams.py
crontab entry every 1h:
1 * * * * python3 /FILE/LOCATION/pzss-exams.py
@piotr-grzelka
piotr-grzelka / \etc\profile.d\notify_log.sh
Created October 16, 2017 20:11
useful scripts for admins
# send informations about new ssh logins to pushover api
who="$(whoami)"
last="$(last -n 5)"
curl -s \
--form-string "token=" \
--form-string "user=" \
--form-string "title=SSH Login: $who" \
--form-string "message=$last" \
# tables
for tbl in `psql -qAt -c "select tablename from pg_tables where schemaname = 'public';" YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to NEW_OWNER" YOUR_DB ; done
# sequences
for tbl in `psql -qAt -c "select sequence_name from information_schema.sequences where sequence_schema = 'public';" YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to NEW_OWNER" YOUR_DB ; done
# views
for tbl in `psql -qAt -c "select table_name from information_schema.views where table_schema = 'public';" YOUR_DB` ; do psql -c "alter table \"$tbl\" owner to NEW_OWNER" YOUR_DB ; done