Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr Zelenin petrikoz

View GitHub Profile
@petrikoz
petrikoz / etc---logrotate.d---uwsgi
Last active Jul 3, 2020
Simple production server for ITCase's projects
View etc---logrotate.d---uwsgi
/var/log/uwsgi/*.log {
compress
copytruncate
dateext
rotate 3
size 1M
}
@petrikoz
petrikoz / reload.sh
Created Feb 12, 2020
Add support Django RQ to uWSGI reload on NetAngels hosting
View reload.sh
#!/usr/bin/env bash
project_base="$HOME/SITE-FOLDER"
# Restart RQ
rqworker_name="$(basename $project_base)-rqworker"
rqworker_pidfile="$project_base/etc/rqworker.pid"
pkill -e -F "$rqworker_pidfile" || true
"$project_base/.env/bin/python" "$project_base/app/manage.py" \
rqworker --name "$rqworker_name" --pid "$rqworker_pidfile" \
@petrikoz
petrikoz / Dockerfile
Created Jan 23, 2020
Dockerfile for run uWSGI with PHP plugin in Alpine
View Dockerfile
FROM alpine
MAINTAINER Petr Zelenin (https://github.com/petrikoz)
# uWSGI
ENV UWSGI_SRC_DIR /opt/uwsgi
ENV UWSGI_USER uwsgi
ENV UWSGI_VASSAL /etc/uwsgi/conf.d/vassal-php.ini
COPY --chown=nobody:nobody alpine.buildconf ${UWSGI_SRC_DIR}/alpine.buildconf
RUN set -x \
@petrikoz
petrikoz / config.ini
Last active Oct 14, 2019
Renew SSL certificates on NetAngels.ru via API
View config.ini
[API]
API_KEY = Get API_KEY from https://panel.netangels.ru/api_keys/
DOMAINS = example.com,пример.рф
Archive_path = /root/ssl-renew
Archive_type = tar
Nginx_ssl = /etc/nginx/ssl
@petrikoz
petrikoz / acme.conf
Last active Aug 15, 2018
Nginx config for ItCase projects
View acme.conf
# /etc/nginx/snippets/letsencrypt.conf
location /.well-known {
root /var/www/html;
}
@petrikoz
petrikoz / snippets.rst
Last active Jun 14, 2018
Some snippets for use in anywhere
View snippets.rst

Postgres

Dump

PROJECT=project; pg_dump -h localhost -U $PROJECT -d $PROJECT -f /tmp/$PROJECT.sql -bcOv
@petrikoz
petrikoz / goose.py
Created Sep 12, 2016
Гусятник в туристических группах
View goose.py
'''
Случайное распрделение участников для "гуся".
На выходе получаем спиоск пар "дарящий - получающий":
[(5, 4), (3, 2), (4, 7), (2, 1), (6, 3), (7, 5), (1, 6)]
Нужно просто задать количество участников в группе.
И потом просто распределить их в какую-нить таблицу. Например:
View pre-commit
#!/usr/bin/env sh
# Put this file in 'project/src/.git/hooks' folder
# Change author in Python's source code
my_credits='My Name (my.email@example.com)'
company_credits='Company (info@example.com)'
find . -type f -iname '*.py' -exec sed -i -e "s/$my_credits/$company_credits/g" {} +
# Sort Python's imports in source code
find . -type f -iname '*.py' -exec isort {} +
@petrikoz
petrikoz / emperor.ini
Last active Jun 13, 2019
uWSGI config for ItCase projects
View emperor.ini
[uwsgi]
emperor-tyrant = true
emperor = %dvassals
emperor-pidfile = %demperor.pid
uid = web
gid = www-data
vassals-include = %dvassals-include.ini
@petrikoz
petrikoz / .bashrc
Last active Dec 11, 2020
Simple config for hostings: .bashrc, .vimrc
View .bashrc
################################################################
# Utilities
################################################################
function hsi() {
history | grep -i $1
}
################################################################
# Aliases
You can’t perform that action at this time.