Backup (clone) all your own gists

You need to have a personal access token to GitHub. In this script I use my token saved in ~/.github_access_token. Also you need to have the git utility on your system. Install PyGithub package to work with GitHub API pip install PyGithub The gist is actually a git repository. All your gists you can clone as regular repositories into a directory called repos. Script clones gists with names contained the IDs....

March 13, 2022

Docker для python. Первые шаги

Если не вдаваться в технические детали Docker ближе всего к VirtualBox, VMware или другим средствам виртуализации. Технические отличия заключаются в других способах изоляции запускаемой гостевой (guest) операционной системы и разделения ресурсов основной (host) операционной системы. Как правило каждый работающий в Docker экземпляр гостевой операционной системы предназначен для запуска одного единственного приложения. При этом задействуется меньше ресурсов, чем при запуске в виртуальной машине. Для этого создается своя файловая система, свои виртуальные сетевые интерфейсы - как бы контейнер внутри которого приложение работает....

January 4, 2022

Snippet for printing a subclass tree

Sometimes I needed to figure out the class hierarchy. For this, I wrote a small piece of code to visualize the class tree. def format_output(class_name, prefix, is_last): left_simbol = "└" if is_last else "├" return prefix + left_simbol + "───" + class_name def print_subclass_tree(thisclass, prefix=""): for count, subclass in enumerate(thisclass.__subclasses__(), start=1): is_last = count == len(thisclass.__subclasses__()) print(format_output(subclass.__name__, prefix, is_last)) devide_simbol = "" if is_last else "│" print_subclass_tree(subclass, prefix + devide_simbol + "\t") print_subclass_tree(BaseException) # ============ OUTPUT ================== # >>> print_subclass_tree(BaseException) # ├───Exception # │ ├───TypeError # │ ├───StopAsyncIteration # │ ├───StopIteration # │ ├───ImportError # │ │ ├───ModuleNotFoundError # │ │ └───ZipImportError # ....

December 9, 2021

Starting a production Django server

I wrote ansible playbook for starting up a production Django server with PostgreSQL, Gunicorn and Nginx. When I tested the script, I used the Ubuntu Server image from this link. All I needed to install additionally was an ssh server for ansible to work. sudo apt update && sudo apt upgrade sudo apt install openssh-server I used a VirtualBox image and set the network settings to bridge mode. The IP address was obtained via the dhcp protocol....

October 15, 2021

Starting a remote docker development server on DigitalOcean droplet

Thanks Fedor Borshev for awesome tutorial “Как писать код на МОЩНОЙ удалённой машине DigitalOcean”. I repeated Fedor’s experience with Windows + WSL2. Video: Link to ansible playbook for for deploying docker on DO droplet and empty django project for testing: github. Links: [1] Ansible playbook for for deploying docker on DO droplet [2] Youtube-канал “Почему не работает?”

August 15, 2021

A dynamic GitHub profile with GitHub Actions

Thanks Yannick Chenot for the article How to Build a Dynamic GitHub Profile with GitHub Actions and PHP! It describes how to set up automatic updating of links to the latest blog posts in the GitHub profile using GitHub Actions. I will not retell the article, and you can read about the profile on GitHub here. Here is my python solution import requests from bs4 import BeautifulSoup url = "https://vostbur.github.io" main_page = BeautifulSoup(requests....

July 22, 2021

Deploying the django app on the DigitalOcean App Platform

For deploying Django apps, I tried PaaS such as Heroku and Pythonanywhere. It’s the turn of the DigitalOcean App Platform. And so far, this is the easiest and fastest way to deploy a Django app in production. There is awesome guide on how to do this on DigitalOcean’s tutorials. For testing, I wrote a small application that generates a configuration snippet for configuring ssh on cisco devices. For simplicity, I didn’t use a database and static content....

July 21, 2021

The best APIs for solving geospatial tasks

In mapquest.com I have found out the best APIs for working with maps and geopositions in my opinion. For example, I wrote a small script to navigate between cities. That is the result for the route from Bryansk to Moscow. The API has many request parameters. JSON response contains a lot of data: Links: [1] developer.mapquest.com [2] Example of using the API

July 18, 2021

Setup a basic workflow using GitHub Actions with Docker

In the continuation of the post “Creating dockerized Django app with VSCode”, I updated the source code to work with GitHub Actions. Setup a basic workflow using GitHub Actions Add to the requirements.txt file the following line to check with linter: flake8>=3.9.2,<3.10 Create a new file at .github/workflows/cd.yml and fill it with the following contents: --- name: Code checks on: push: branches: [ master ] pull_request: branches: [ master ] jobs: test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Test run: docker-compose run --rm ....

June 13, 2021

Creating dockerized Django app with VSCode

Thanks to Mark Winterbottom for the interesting videos and the idea for this post. Creating a Django project Start by creating a new directory for your project (eg: vscode-django-docker), and open it in VSCode. mkdir vscode-django-docker cd vscode-django-docker git init code . Then, add a .gitignore for your project. You can use template for Python provided by GitHub or generate on gitignore.io. Now let’s create a Django project by running the one-line-command below...

June 12, 2021