Skip to content

Instantly share code, notes, and snippets.

@mitrofun
mitrofun / .bash_profile
Created December 17, 2020 20:18 — forked from jonsuh/.bash_profile
Bash echo in color
# ----------------------------------
# Colors
# ----------------------------------
NOCOLOR='\033[0m'
RED='\033[0;31m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
@mitrofun
mitrofun / install_docker.sh
Created November 28, 2020 17:56 — forked from angristan/install_docker.sh
Script to install Docker and Docker-Compose on Debian
#!/bin/bash
apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common sudo
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"
apt-get update
@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