This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 8008; | |
server_name localhost; | |
add_header 'Access-Control-Allow-Origin' '$http_origin'; | |
add_header 'Access-Control-Allow-Credentials' 'true'; | |
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range'; | |
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH'; | |
location / { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import csv | |
DATA_FOLDER = os.path.join('data') | |
class CsvDB: | |
def __init__(self, dbname: str, verbose: bool=True): | |
self.verbose = verbose | |
self.dbname = dbname | |
os.makedirs(os.path.join(DATA_FOLDER, self.dbname), exist_ok=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from pathlib import Path | |
ROOT = Path(__file__).resolve().parent | |
INPUT_OLD = ROOT / "old.csv" | |
INPUT_NEW = ROOT / "new.csv" | |
OUTPUT = ROOT / "final.csv" | |
# csv data format: | |
# email,zip_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Afghanistan", | |
"flag": "🇦🇫", | |
"code": "AF", | |
"dial_code": "+93" | |
}, | |
{ | |
"name": "Åland Islands", | |
"flag": "🇦🇽", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Create multiple responsive images to generate a srcset | |
# | |
# Usage example: | |
# b64_image = base64.b64decode(b64_image.split(",")[1]) # from base64-encoded image | |
# file_name = "lorem.ipsum.jpeg" | |
# srcset_results = [] | |
# for img in create_srcset_images(BytesIO(b64_image), widths): | |
# srcset_name = f'{".".join(file_name.split(".")[:-1])}-{img["width"]}w.{img["format"]}' | |
# result = upload_file_to_external_service(img["image"], srcset_name) # <--- it must return a URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Virtualenv | |
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 | |
export WORKON_HOME=$HOME/.virtualenvs | |
source /usr/local/bin/virtualenvwrapper.sh | |
# Add git branch if its present to PS1 | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ ' |
OlderNewer