Skip to content

Instantly share code, notes, and snippets.

View petrikoz's full-sized avatar

Petr Zelenin petrikoz

View GitHub Profile
@petrikoz
petrikoz / .bashrc
Last active December 11, 2020 07:15
Simple config for hostings: .bashrc, .vimrc
################################################################
# Utilities
################################################################
function hsi() {
history | grep -i $1
}
################################################################
# Aliases
@petrikoz
petrikoz / emperor.ini
Last active June 13, 2019 08:05
uWSGI config for ItCase projects
[uwsgi]
emperor-tyrant = true
emperor = %dvassals
emperor-pidfile = %demperor.pid
uid = web
gid = www-data
vassals-include = %dvassals-include.ini
@petrikoz
petrikoz / pre-commit
Last active December 12, 2017 10:27
Git's hook
#!/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 / goose.py
Created September 12, 2016 06:38
Гусятник в туристических группах
'''
Случайное распрделение участников для "гуся".
На выходе получаем спиоск пар "дарящий - получающий":
[(5, 4), (3, 2), (4, 7), (2, 1), (6, 3), (7, 5), (1, 6)]
Нужно просто задать количество участников в группе.
И потом просто распределить их в какую-нить таблицу. Например:
@petrikoz
petrikoz / snippets.md
Last active February 21, 2021 09:39
Some snippets for use in anywhere

Postgres

Dump

PROJECT=project; pg_dump -h localhost -U $PROJECT -d $PROJECT -f /tmp/$PROJECT.sql -bcOv --column-inserts
@petrikoz
petrikoz / acme.conf
Last active August 15, 2018 09:55
Nginx config for ItCase projects
# /etc/nginx/snippets/letsencrypt.conf
location /.well-known {
root /var/www/html;
}
@petrikoz
petrikoz / config.ini
Last active February 24, 2022 08:55
Renew SSL certificates on NetAngels.ru via API
[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 / Dockerfile
Created January 23, 2020 08:45
Dockerfile for run uWSGI with PHP plugin in Alpine
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 / reload.sh
Created February 12, 2020 09:36
Add support Django RQ to uWSGI reload on NetAngels hosting
#!/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 / root.sh
Last active March 5, 2022 11:23
Simple production server for ITCase's projects
# ****************************************************************
# PROFILE
# включаем поддержку цветов в терминале
sed -i 's/xterm-color)/xterm-color|*-256color)/g' ~/.bashrc
# подсвечиваем root'а красным
sed -i 's/033\[01;32m/033\[01;31m/g' ~/.bashrc
# подкрашиваем: @ — белым, hostname — жёлтым
sed -i 's/\]\\u@\\h/\]\\u\\\[\\033\[00m\\\]@\\\[\\033\[33;1m\\\]\\h/g' ~/.bashrc