Skip to content

Instantly share code, notes, and snippets.

View vakhov's full-sized avatar
💭
learn new

Alex Vakhov vakhov

💭
learn new
View GitHub Profile
@vakhov
vakhov / git tarball
Created June 22, 2022 07:11
How to create a tarball
git archive --format=tar.gz -o /tmp/my-repo.tar.gz --prefix=my-repo/ master

Demo:

Spoiler warning

Spoiler text. Note that it's important to have a space after the summary tag. You should be able to write any markdown you want inside the <details> tag... just make sure you close <details> afterward.

console.log("I'm a code block!");
@vakhov
vakhov / maps_url.py
Created July 2, 2021 10:40 — forked from willcharlton/maps_url.py
Python (3) snippet to generate google maps url and timezone for a given address.
#!/usr/bin/env python3
"""
So far only tested on python3 interpreter.
Given an address, this script outputs a google maps url to the address.
"""
import requests, sys, time
from urllib.parse import quote_plus
@vakhov
vakhov / gitcheats.txt
Created January 22, 2020 04:32 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# git remote all remotes except origin
git remote -v | grep "(fetch)" | sed -e 's#[[:blank:]].*##g' | grep -v "origin" | xargs -n 1 git remote rm
# print all git repos for a user
curl -s https://api.github.com/users/wordpress/repos?per_page=1000 | grep git_url |awk '{print $2}'| sed 's/"\(.*\)",/\1/'
# print all git repos for a user
def wave(word: str):
result = []
for i, let in enumerate(word):
if i == 0:
result.append(word.title())
elif i == len(word) - 1:
result.append(f"{word[:-1]}{word[-1].title()}")
else:
result.append(f"{word[:i]}{word[i].title()}{word[i + 1:]}")
return result
@vakhov
vakhov / hashing.py
Created December 2, 2019 10:16
Hashing a file in Python
def get_hash_file(file_name: str, buf_size: Optional[int] = None) -> Dict[str, str]:
BUF_SIZE = buf_size or 65536
md5 = hashlib.md5()
sha1 = hashlib.sha1()
with open(file_name, 'rb') as f:
while True:
data = f.read(BUF_SIZE)
if not data:
break
md5.update(data)
@vakhov
vakhov / comandline.txt
Created November 29, 2019 03:47
Generate Django secret key (SECRET_KEY) commandline. python 2 and 3
python -c "import random;from string import (ascii_lowercase, digits, punctuation);print(''.join([random.choice(ascii_lowercase + digits + punctuation) for _ in range(50)]))"
@vakhov
vakhov / Конфигурация ckeditor в Django
Created September 17, 2019 09:16
Оптимальная конфигурация CKEDITOR_CONFIGS приложения ckeditor в Django
CKEDITOR_CONFIGS = {
'default': {
'toolbar': [
['Undo', 'Redo',
'-', 'Bold', 'Italic', 'Underline',
'-', 'Link', 'Unlink', 'Anchor',
'-', 'Format',
'-', 'Maximize',
'-', 'Table',
'-', 'Image',
@vakhov
vakhov / Gunicorn.sh
Created June 28, 2019 11:00 — forked from omedhabib/Gunicorn.sh
Gunicorn.sh
#!/usr/bin/env bash
PROCESSOR_COUNT=$(nproc)
GUNICORN_WORKER_COUNT=$(( PROCESSOR_COUNT * 2 + 1 ))
gunicorn -w ${GUNICORN_WORKER_COUNT} -b 0.0.0.0:9808 app:application