Disable Internet connection in unittests
Sometimes you can forget to mock all of the functions with side effect within your unittests and that might cause some issue. First it violates unittests principle to be launched in isolated environment and to not strictrly depend on any component that is not tested at the moment. And it might happen that you will not be able to launch unittests after your Internet connection is gone. Solution Obviously you should use pytest for your unittests and it has nice autouse fixtures. We can mock ...
My use case for using AST in production
I am an advocate about not using metaclasses, inspect/ast modules and other cool features in production. In 99% cases its a marker of some workaround/patch or just poor architecture. But recently I had a case which pushed me to use AST module. In short I have a huge list of environment variables which should be reused by other script within docker container. I writethat file using bash script and then invoke a docker run command. The issue is that all the params is defined in ActiveRecord class ...
leak package
Intro In this article Im going to describe small utility that is intended to provide some useful information about packages released to the PyPI. leak is a tool that shows you all the releases of a package specified that can be downloaded and installed. Sometimes its very useful to see a list of them in order to be able install next/previous major/minor release of a package. And therefore to see all the versions available you need to manually go to the projects page and find the version you a...
Custom Celery routing
In this article Im going to share an approach that we use to execute some long running background tasks for our project. So I use Celery as a task executor with a Redis broker backend. I have couple of different environments for my workers so each of those runs within docker container. We want to support hot reloading too. For example we have our environment changed and that would require building new images and running workers within this new environment. At the same time we want currently r...
Ansible + virtualenvwrapper
virtualenvwrapper is a very convenient tool to use. It provides easier access to all the regular features you like in virtualenv. But when it comes to automation with Ansible some issues might occur. You cannot just call workon venvwithin one task and then continue to work in the same context from another task. There are two options how to overcome this issue. Call python executable directly from environment directory In this case you need two extra variables: one for projects root and ...
Поговоримо про Мовчання
Вчора сходив на фільм Мовчання, який змушує мене говорити і написати невеличку рецензію-відгук-огляд на фільм. Одразу до висновків: вибираючи між цим фільмом та фільмом Три ікси в пятницю ввечері - добре подумайте, хоча ні, не думайте взагалі і непохитно обирайте останній - саме те, що потрібно для бездумного перегляду після насиченого робочого тижня. В протилежному випадку вас чекає майже три (!) години нудьги, бажання покинути глядацьке крісло, листати стрічку Інстаграму чи просто заснути прям...
node js автостарт додатку з rc.d в FreeBSD
Нещодавно виникла необхідність запустити веб-додаток на Express (node js) автоматично при старті та перезапуску системи (FreeBSD 10.3). До цього все запускалося за допомогою чудового менеджера процесів для ноди - foreverjs. Він чудово працює з дочірніми процесами і виконує свої функції (старт, перезапуск, перегляд логів, рестарт при зміні коду), але не запускається автоматично з операційною системою. Рішенням став демон системи, що виконує скрипти автозапуску під час старту - rc.d. Проста кон...
Як зробити млинці #1
Черговий раз я вирішив приготувати свої улюблені млинці. Як кажуть практика - шлях до досконалості, що іншими словами означає, що мені не вдалося їх нормально зробити) Отже, необхідні інгредієнти: 2 курячих яйця; 500 мл коровячого молока; столова ложка цукру; половинка чайної ложки солі; пакетик ванільного цукру (для класного аромату і більш солодкого смаку); 250 г борошна; соняшникова олія; Крок 1 Знаходимо посудину (звичайна каструля також підійде) і розбиваємо туд...
Sending sms via Skype api
Recently I faced a problem of sending sms to a number that was not completely known: I had three missing digits. Like you know somebody can leave his number in such way: +380986*581**. I found that Skype provides developer tools for building a bot, but failed to implement anything probably because it was too late at night. So results in google showed that there is another library that can attach to running process of skype - Skype4Py. Simple script came up after couple of minutes # -*- codi...
Replacement for your Makefile
Intro Makefile is a gnu utility that was aimed to simplify compilation process. You can forget long command with dozens of flags or params and with makefile u have targets and they can save your time while typing complicated command. If you familiar with bash aliases then its very similar concept. That helps a lot in day to day tasks. The command below would be easy as make tests tests: @pip install -r requirements/test-requirements.txt @py.test --junitxml=./testResults.xml --cov-con...
Твори как Бог, приказывай как король, работай как раб.
К. Бракази

Інструментарій