Skip to content

Instantly share code, notes, and snippets.

@mitrofun
mitrofun / init.vim
Created November 25, 2020 14:24 — forked from celso/init.vim
Neovim setup for OSX users
syntax on
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set textwidth=0 " Hard-wrap long lines as you type them.
set modeline " Enable modeline.
set esckeys " Cursor keys in insert mode.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
" More natural splits
set splitbelow " Horizontal split below current.
@mitrofun
mitrofun / osx_reset_cups
Created September 30, 2020 12:10 — forked from onecooltaco/osx_reset_cups
OS X reset CUPS
# Stop the CUPS daemon with the following command.
launchctl stop org.cups.cupsd
wait
# Rename the old CUPS configuration file.
mv /etc/cups/cupsd.conf /etc/cups/cupsd.conf.backup
wait
# Restore the default settings file.
cp /etc/cups/cupsd.conf.default /etc/cups/cupsd.conf
wait
# Rename printers file.
@mitrofun
mitrofun / download_zip.js
Created September 14, 2020 14:01 — forked from raymondpittman/download_zip.js
Download a .zip file from a blob URL using Javascript with Fetch.
/*
* @Author Raymond Pittman
* @Github: https://github.com/raymondpittman
*/
function download(url, filename) {
fetch(url, {
mode: 'no-cors' /*{mode:'cors'}*/
}).then((transfer) => {
return transfer.blob();
}).then((bytes) => {
@mitrofun
mitrofun / README.md
Created September 12, 2020 22:01 — forked from mau21mau/README.md
Configure Celery + Supervisor With Django
@mitrofun
mitrofun / remove-from-git-index.txt
Created September 2, 2020 16:35 — forked from bendasvadim/remove-from-git-index.txt
GIT. Как полностью удалить файл из истории
1. Нужно найти все коммиты, которые изменяли файл:
git log --pretty=oneline --branches -- BIGFILE.ZIP
2.1 Удалить ссылки на файл из всей истории коммитов, начиная с последнего (пусть, хеш последнего коммита - 6df7640):
git filter-branch --index-filter 'git rm --cached BIGFILE.ZIP --ignore-unmatch' --prune-empty --tag-name-filter cat -- --all
2.2 Удалить ссылки на каталог из истории коммитов:
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch BIG/DIR' --prune-empty --tag-name-filter cat -- --all
3. Отправляем изменения на сервер:
@mitrofun
mitrofun / task.yml
Created August 31, 2020 17:30 — forked from lxsameer/task.yml
Adding github to known_hosts with ansible
- name: ensure github.com is a known host
lineinfile:
dest: /root/.ssh/known_hosts
create: yes
state: present
line: "{{ lookup('pipe', 'ssh-keyscan -t rsa github.com') }}"
regexp: "^github\\.com"
@mitrofun
mitrofun / gist:62a9607e21a720b617b27848cf45d5d7
Created August 24, 2020 13:13 — forked from igorpronin/gist:d1cdea867adc091668e78e5a6eba0a00
Как делать код-ревью, статья понравилась
https://toster.ru/q/276441
Отсюда, есть и другие рекомендации от др авторов.
Я когда делаю Code Review критерии следующие:
* Безопасность:
- Каждый аргумент метода простого типа должен проверяться на тип в случае его проксирования и на граничные значения в случае обработки. Чуть что не так - бросается исключение. Если метод с кучкой аргументов на 80% состоит из поверки из аргументов - это вполне норм))
- Никаких trigger_error, только исключения.
- Исключения ДОЛЖНЫ быть человеко-понятны, всякие "Something went wrong" можно отдавать пользователю, но в лог должно попасть исключение со стектрейсом и человеко-понятным описанием, что же там пошло не так.
- Каждый аргумент (объект) метода должен быть с тайпхинтингом на этот его класс, или интерфейс.
@mitrofun
mitrofun / .flake8
Created August 12, 2020 23:50 — forked from krnd/.flake8
(Python) Flake8 configuration file
# .flake8
#
# DESCRIPTION
# Configuration file for the python linter flake8.
#
# This configuration is based on the generic
# configuration published on GitHub.
#
# AUTHOR
# krnd

Certbot и nginx, как обратный прокси в Docker (пример с 2 react проектами)

В результате будет 2 react проекта на 1 сервере доступных по разным ссылкам

Цели

  • Запустить nginx в одном контейнере
  • Запустить другие проекты в других контейнерах
  • Научить nginx перенаправлять запросы с разных доменов на разные проекты
  • Получить ssl сертификаты для всех проектов
@mitrofun
mitrofun / urls.py
Created July 4, 2020 22:01 — forked from iMerica/urls.py
Email verification in Django Rest Framework, Django All-Auth, Django Rest-Auth. Suitable for Single Page Applications
urlpatterns = [
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', ConfirmEmailView.as_view(), name='account_confirm_email'),
]