Use multiple versions of Vagrant on the same machine
Recently I faced an issue of running Vagrant version 1.8 because of plugin incompatibility. I've removed my original installation (which was 2.1) and did the work needed. But a while after that I had to use that old version once again. So not to repeat this boring process once again I decided to make my system work with two different versions of Vagrant simultaneously. To accomplish that we need to throw away regular installation process and build everything from sources. $ cd /opt $ sudo mkdir...
Method overloading in Python
Python does not support method/functions overloading as other languages do. For example in C++ we can define three different methods that will support different types of arguments class printData { public: void print(int i) { cout << "Printing int: " << i << endl; } void print(double f) { cout << "Printing float: " << f << endl; } void print(char* c) { cout << "Printing character: " << c << endl; } }; But in Python only the last dec...
Advanced wtforms usage
WTForms is a powerful form validation and rendering library especially for web development. It's framework agnostic but there are packages that integrate it with popular web frameworks (e.g. Flask WTF ). In this article I'm going to cover some advanced techniques which is not covered in documentation. Creating custom fields If you want to add some non-standard field to your form you can create a custom field. First you need to inherit from appropriate field to describe which type of value you w...
bz2 ModuleNotFoundError
This error means that you have missing bz2 headers (probably because you've built python from sources without this option enabled), so you need to install them first (for Ubuntu/Debian): ```bash apt-get install libbz2-dev Now we need to reconfigure your python and reinstall it once again (version `3.6.5` for example below)bash $ tar -xvf Python-3.6.5.tar.xz $ cd Python-3.6.5/ $ ./configure $ make $ sudo make install Check whether it works properly nowbash $ python3.6 - c "import bz2" should ret...
Django integrity error while running migration
Recently I've got an error when invoking python manage.py migrate Traceback (most recent call last): File "/home/ubuntu/virt/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.IntegrityError: duplicate key value violates unique constraint "django_migrations_pkey" DETAIL: Key (id)=(99) already exists. This one means that you have out of date sequence within your database (improper previous migrations or jumps betwe...
Signing your github commits with GPG keys
If you ever wondered how to sign your commits (to assure others that it was you who really did the commit) or just wanted a nice Verified label right after your commit message on github page - you opened the right article to follow. Installing requirements First you need to install GPG command line tools allowing you to create a personal key which will be using to sign your commits. We need to install libgpg-error, libgcrypt, libksba, libassuan, ntbTLS and nPth. bash $ mkdir /tmp/gpg $ cd /tmp...
Alter field migration with Peewee
Peewee - is very small though powerful ORM for Python. It even support migration within its own playhouse. In the simplest form you can write migrations like this ```python from peewee import CharField, MySQLDatabase from playhouse.migrate import migrate, MySQLMigrator db = MySQLDatabase('db_name', host='127.0.0.1', port='3306', user='db_user', password='db_password') migrator = MySQLMigrator(db) table_name = 'my_table' new_field = CharField(null=False, default='empty', max_le...
Install specific Python version with Ansible
Really quick tutorial of how to install a custom Python version from source code with a help of Ansible. The resulting playbook will help us to install python in automatic mode on any remote machine as well as on virtual machine within Vagrant. So the code of Ansible playbook first followed with a little bit of explanation ```yaml name: Install required packages apt: name={{item}} state=installed with_items: build-essential libssl-dev libreadline-dev openssl become: true name: Downl...
Enhance your developing workflow with notifications on pull requests
How to make your code changes to be delivered faster? How to reduce time your pull requests being in Needs review state? How to ensure developers are not blocked waiting for the feedback from their teammates? In this article we will write simple tool that integrates with your VCS and your messenger and answers to questions above. Quick overview We will be using Python 3/aiohttp/PostgreSQL/Heroku and Github as a platform for our version control system and Slack as a messenger. In a few words the...
Подборочка прикольных номеров Киев #1
Мажорные номера. Выпуск 1 ...и самая крутая маршрутка в Киеве!
Порхай как бабочка, жаль как Киркорову немного жаль твоей надежды
Прояснилось

What's inside?