Misanthrope's Thoughts

What is the cause for the degradation of environment?
Capitalism, corruption, consuming society? - OVERPOPULATION!
Please, save the Planet - kill yourself...

Tuesday, October 16, 2018

Chaining AND operators in Django

Sometimes in Dango you need to compose query with several  `Q(query) & Q(other_query) &...` and the number of such queries changes dynamically. Here is a quick example how to solve it:

import operator

ids = [1, 2, 3]
queries = [Q(some_m2m_relation__pk=pk) for pk in id]
result = SomeModel.objects.filter(
    reduce(operator.and_, queries)

Tuesday, February 7, 2017

How to Configure Pulseaudio to Work With Subwoofer

What I hate about Pulseaudio is its crappy default configuration. After fresh installation of SUSE Leap 42.2 I encountered an issue that subwoofer didn't work with Amarok... again((( Lucky me, the first link that google provided me with was link to my own(!!!) thread that I started about 6 years ago (sick!!!). In 2011 I encountered the same issue, asked for help, but solved on my own and answered for my own request. And now future me was able to find that long forgotten thread of mine. That's so sweet to recieve a messege to miself )))

This time I will put the answer here to remember it better ;-)

The problem solved, tnx to this post
In /etс/pulse/daemon.conf I've made following changes:

enable-lfe-remixing = yes
default-channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe

Friday, September 23, 2016

Environmental Monitoring App

Python, R, Qt, peewee, bokeh, pandas, SQLite plus couple of sleepless nights and here you are a сute app for the environmental monitoring needs )))
Main window of the application

Wednesday, August 24, 2016

UUID Field for the Peewee ORM

I wanted to have UUID fields in my Peewee-bsead models for the SQLite database. I quickly found ready-to-use code, but it lacked one important thing - automatic uuid generation. Here is the solution:

import uuid
from peewee import Field

class UIDField(Field):
    db_field = 'uid'
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.default = uuid.uuid4

    def db_value(self, value):
        return str(value)  # convert UUID to str
    def python_value(self, value):
        return uuid.UUID(value)  # convert str to UUID

Monday, November 9, 2015

A satisfied customer

Recently I did a QGIS scripting job and here is the feedback from an extremly satisfied customer:

It was fantastic to work with Yury. He provided an excellent product, that went far beyond what I was expecting. I will certainly be contacting Yury in the future for any jobs that relate to GIS and python scripting. Communication was excellent and his ability to understand the job requirement was very impressive. A+++

Guys, if you are in need of geoprocessing tool for your project - don't hesitate to contact me ;-) 

Friday, October 23, 2015

My QGIS Processing Scripts at GitHub

This is probably my shortest post ever.

All my QGIS processing scripts (R and Python) and models that I already blogged about, plus some extra are now available at GitHub.

Thursday, June 18, 2015

A Quick Map With QGIS and OSM

What I love about QGIS is that one is able to create a nice map quickly. The other day I was asked to make a situation map for the project we are working on to include it into presentation. Аll I had was a laptop with no relevant spatial data at all, but with QGIS installed (I even had no mouse to draw something). Though it was more than enough: I loaded OSM as a base layer and used annotation tool to add more sense to it. Voilà: