Skip to content

Instantly share code, notes, and snippets.

View blacktrub's full-sized avatar

blacktrub blacktrub

View GitHub Profile
@blacktrub
blacktrub / docker-compose.yml
Created November 28, 2022 15:27
Hitchhiker
version: '2'
services:
hitchhiker:
image: brookshi/hitchhiker:v0.14
container_name: hitchhiker
environment:
- HITCHHIKER_DB_HOST=localhost
- HITCHHIKER_APP_HOST=http://localhost:9999/
ports:
- "9999:9999"
Разница между процессом и тредом
Виртуализация, разница между контейнеризация и вирт
В каком случае python не совсем интерпритируемый
Микросервисы vs монолит
Python GIL
Файловые дескрпторы
Типы данных Python
ООП и функциональный стиль
Замыкания и partial
SQL и NoSQL, разница
@blacktrub
blacktrub / init.lua
Created November 16, 2021 21:40
init.lua
local Plug = vim.fn['plug#']
vim.call('plug#begin', '~/.config/nvim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'kyazdani42/nvim-web-devicons' -- for file icons
Plug 'kyazdani42/nvim-tree.lua'
Plug 'goolord/alpha-nvim'
Plug 'marko-cerovac/material.nvim'
Plug 'romgrk/barbar.nvim'
Plug 'akinsho/toggleterm.nvim'
Plug 'nvim-lua/plenary.nvim'
# install dependencies
pip install requests bottle
# server.py
import json
from bottle import run, response, post
@post("/test")
def index():
@blacktrub
blacktrub / mergesort.py
Created July 12, 2020 12:17
merge sort algorithm
import math
def merge(one, two):
n = max(len(one), len(two))
i, j = 0, 0
result = []
for _ in range(n * 2):
a = one[i] if len(one) > i else None
b = two[j] if len(two) > j else None
@blacktrub
blacktrub / karatsuba.py
Last active July 11, 2020 18:12
karatsuba algorithm
import math
def karatsuba(x, y):
if (x < 10) and (y < 10):
return x * y
n = max(len(str(x)), len(str(y)))
n2 = int(math.ceil(float(n) / 2))
# create .pgpass in your home directory with same content
localhost:5432:your_db_name:your_db_username:password
# set required permissions for this file
sudo chmod 600 .pgpass
# set PGPASSFILE variable in your .bashrc or in .zshrc
export PGPASSFILE='/home/your_user/.pgpass'
# test your .pgpass
@blacktrub
blacktrub / gist:96e62d245b3f72c7f73ccb86de51a4bd
Created September 28, 2018 08:41
enable pg_stat_statements
# paste this in your postgresql.conf
# in my way it is in /etc/postgresql/9.5/main/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
track_activity_query_size = 2048
pg_stat_statements.track = all
# after this you must restart postgresql daemon
sudo service postgresql restart
# connect to your db with psql and create extension
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.yandex.ru'
EMAIL_HOST_USER = '[email protected]'
EMAIL_HOST_PASSWORD = 'your_password'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
CREATE USER 'username' WITH PASSWORD 'password';
ALTER USER 'username' SUPERUSER;
CREATE DATABASE 'dbname' WITH ENCODING 'UTF8' LC_CTYPE 'en_US.UTF-8' LC_COLLATE 'en_US.UTF-8' TEMPLATE template0 OWNER 'username';