Skip to content

Instantly share code, notes, and snippets.

View Eduard-gan's full-sized avatar

Eduard Gan Eduard-gan

  • Self employed
  • Russian federation
View GitHub Profile
5288 Python: Экранирование строк от спецсимволов регулярных выражений:
Бывает так что из конфига или от пользователя нужно собрать строку, которая потом идёт в регулярное выражение.
Для того чтобы эффективно и быстро заэскейпить все спецссимволы регулярок в этой сроке используется re.escape(контент) - она возвращает заэкранированный контент.
т.е. реально можно использовать вот так:
re.search(re.escape(resource['mask'])+'.*'+re.escape(resource['format']),object.filename)
5289: Python: Отправка файла по SMB
def send_file(filename):
from smb.SMBConnection import SMBConnection
@Eduard-gan
Eduard-gan / add_screen_resolution
Created October 7, 2018 18:49
Script to add 2560x1400 on vbox linux vm
#! /bin/bash
xrandr --newmode "2560x1440_60.00" 312.25 2560 2752 3024 3488 1440 1443 1448 1493 -hsync +vsync
xrandr --addmode VGA-1 "2560x1440_60.00"
@Eduard-gan
Eduard-gan / gist:0d0ee82ce8138d789dcdac8a8e99e1e7
Created October 10, 2018 09:24
Launch executable detached from terminal which is use
For example "brick" application:
egan@wk149 ~> brick & disown
disown is a unix tool for that so rtfm about it, it cool.
@Eduard-gan
Eduard-gan / gist:4f0f4bcfe5f8af3bf855c21baedee550
Last active October 11, 2018 08:08
Apache: add static file under root of mounted WSGI appilication
It's possible with Alias directive which is used like this
Alias /google_485135.html /usr/egan/google_485135.html
You can get 403 when serving of the file is working
to solve it you need to configure access to file on Apache level.
Alias /google_485135.html /usr/egan/google_485135.html
<Directory /usr/egan>
Require all granted
@Eduard-gan
Eduard-gan / gist:c8cfc481399bbc77b59ba59ae4bac7ba
Created October 31, 2018 05:53
MariaDB: Show all tables engines for database
SELECT TABLE_NAME,
ENGINE
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'YOUR DB NAME';
@Eduard-gan
Eduard-gan / gist:d653389551f9cf0683fdb1ac67a00d8c
Created October 31, 2018 05:58
MariaDB: Chaeck and repair tables
mysqlcheck -h 127.0.0.1 -u root -p -r YOUR_DB_NAME
# This will temporairly create /var/novk/ssl/.well-known/xxxxxx confirmation file and trigger
# external check of it's availiblty and contents from letsencrypt's authority servers.
# This directory simply should be served by some http server when container launches
# This container isn't designed to be persistent and it will exit and removed once command will finish.
# You may simply add it into your crontab
docker run -it --rm --name certbot \
-v /var/novk/ssl:/var/novk/ssl \
-v /etc/letsencrypt:/etc/letsencrypt \
# Filter Delegated log at /usr/share/delegated/log/53120
[Init]
maxlines = 50
[Definition]
datepattern = %%m/%%d %%H:%%M:%%S
failregex = .*?E-P: No permission: <HOST>.*?\(SocksV4 is not acceptable\)
@Eduard-gan
Eduard-gan / Dockerfile
Last active November 4, 2018 13:02
Delegated Socks proxy in Docker container
#
# Dockerfile for delegated
#
FROM debian
MAINTAINER kev <[email protected]>
ENV DG_VERSION 9_9_13
ENV DG_FILE linux2.6-dg${DG_VERSION}.tar.gz
ENV DG_DIR dg${DG_VERSION}
ENV DG_URL http://delegate.hpcc.jp/anonftp/DeleGate/bin/linux/latest/${DG_FILE}
set OVPN_DATA "ovpn-data-dir"
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn ovpn_genconfig -u udp://xl.novk.ga
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn ovpn_initpki
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn easyrsa build-client-full root nopass
docker run -v $OVPN_DATA:/etc/openvpn --log-driver=none --rm kylemanna/openvpn ovpn_getclient root > root.ovpn