Skip to content

Instantly share code, notes, and snippets.

View olegbuevich's full-sized avatar

Aleh Buyevich olegbuevich

View GitHub Profile
# based on: http://www.php2python.com/wiki/function.imap-utf7-encode/
def modified_base64(s):
s_utf7 = s.encode('utf-7') #
aaa = s_utf7[1:-1].decode().replace('/', ',') # rfc2060
return aaa
def modified_unbase64(s):
s_utf7 = '+' + s.replace(',', '/') + '-'
@olegbuevich
olegbuevich / postgres
Last active September 29, 2016 20:36 — forked from mmrwoods/postgres
Postgres maintenance crontab file
# dump all databases once every 24 hours
45 4 * * * root nice -n 19 su - postgres -c "pg_dumpall --clean" | gzip -9 > /var/local/backup/postgres/postgres_all.sql.gz
# vacuum all databases every night (full vacuum on Sunday night, lazy vacuum every other night)
45 3 * * 0 root nice -n 19 su - postgres -c "vacuumdb --all --full --analyze"
45 3 * * 1-6 root nice -n 19 su - postgres -c "vacuumdb --all --analyze --quiet"
# re-index all databases once a week
0 3 * * 0 root nice -n 19 su - postgres -c 'psql -t -c "select datname from pg_database order by datname;" | xargs -n 1 -I"{}" -- psql -U postgres {} -c "reindex database \"{}\";"'
@olegbuevich
olegbuevich / pg_stat_statements
Created September 30, 2016 09:23
Postgresql pg_stat_statements
SELECT query, calls, total_time, rows, 100.0 * shared_blks_hit /
nullif(shared_blks_hit + shared_blks_read, 0) AS hit_percent
FROM pg_stat_statements ORDER BY total_time DESC LIMIT 5;
@olegbuevich
olegbuevich / mattermost.conf
Created March 24, 2017 11:09
centos 6 upstart config for mattermost
start on runlevel [2345]
stop on runlevel [016]
respawn
limit nofile 50000 50000
chdir /opt/mattermost
exec su -c bin/platform mattermost
@olegbuevich
olegbuevich / upgrade.sh
Last active December 13, 2017 12:56
duplicity 0.7 centos 6
# install needed packages
yum install librsync-devel python-devel
# remove old version
yum remove duplicity.x86_64
wget http://savannah-nongnu-org.ip-connect.vn.ua/duplicity/duplicity-0.7.11.tar.gz
tar -zxvf duplicity-0.7.11.tar.gz
cd duplicity-0.7.11/
python setup.py install
@olegbuevich
olegbuevich / tomcat8
Created March 28, 2017 10:47
tomcat 8 init.d script (based on script from tomcat8 package from ubuntu 16.04)
#!/bin/sh
#
# /etc/init.d/tomcat8 -- startup script for the Tomcat 8 servlet engine
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.
# Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>.
# Modified for Tomcat7 by Ernesto Hernandez-Novich <emhn@itverx.com.ve>.
# Additional improvements by Jason Brittain <jason.brittain@mulesoft.com>.
@olegbuevich
olegbuevich / ssl_cert_to_rtN66u.sh
Created May 12, 2017 09:32
update letsencrypt cert on asus RT-N66U
sudo cat /etc/letsencrypt/live/<hostname>/privkey.pem | ssh <router> "cat > /etc/key.pem"
sudo cat /etc/letsencrypt/live/<hostname>/fullchain.pem | ssh <router> "cat > /etc/cert.pem"
ssh <router> service restart_httpd
@olegbuevich
olegbuevich / sent_tg_msg.py
Created May 23, 2017 08:52
[python] send message to telegram chat from bot
# pip install python-telegram-bot
from telegram import bot
# example values
BOT_TOKEN='123456789:jhsagdhg_sakjdKHGKuyasgdkhsabdas'
CHAT_ID='7125376'
tbot = bot.Bot(BOT_TOKEN)
tbot.send_message(chat_id=CHAT_ID, text='Message from python')
@olegbuevich
olegbuevich / rocketchat.conf
Created July 21, 2017 14:06
upstart config for Rocket.Chat (work in Centos 6)
description "rocketchat application server"
# Wait for mongod before starting rocketchat app··
start on (started mongod)
stop on runlevel [!2345]
# Automatically attempt to restart with finite limits
respawn
respawn limit 99 5

Keybase proof

I hereby claim:

  • I am olegbuevich on github.
  • I am obuevich (https://keybase.io/obuevich) on keybase.
  • I have a public key ASDbQbeXTGHIVaIkcqw2-FKcIi6b7jAZ1T-GF_yT1smfbgo

To claim this, I am signing this object: