Donate to support Ukraine's independence.

03 Oct'13

Pelican on Windows

I enjoy using pelican so for so much. However, few issues hit my mind recently:

  • Medium is such a nice place to write that I can merely resist my temptation;
  • There is no ability to run person search across the static website;
  • I’m tied to UNIX environment in order to run the Pelican development server for preview.

I recalled a great quote:

Once you say you’re going to settle for second, that’s what happens to you in life.

—John F. Kennedy

So I decided to see if it’s possible to resolve all of that issues for …

Continue reading

03 Mar'13

Latest software sources

Continue reading

05 Mar'12

Django fails with DEBUG=False on production

First, be sure to eliminate this issue:

Next, enable logging of all events. That will save you plenty of time.

Next, be sure to include both 404.html and 500.html in the root of your templates’ folder. See here and here for details.

If you are using nginx, be sure to include correct fastcgi configuration file: (post before the last). Fairly equal to But extensive configuration didn’t work for me.

Continue reading

05 Mar'12

MySQL with Django on Debian

First, install MySQL driver for Python:

sudo apt-get install python-mysqldb

Next, modify your config of MySQL:

If you’ve already messed up the install, you can either drop/create database from scratch, or apply the following script to every table of your DB:


Alternative mirgation path:

Continue reading

05 Mar'12

Python hostname

from socket import gethostname

print gethostname()

if 'prod' in gethostname:

Continue reading

08 Feb'12

Nonblocking console input in Python

By Nemesis Fixx:

import sys
import select
import tty
import termios
from threading import Thread

program_run = True
input_thread_timeout = 0.005 #seconds
quit_key = '\x1b' # x1b is ESC

#check stdin for input...
def isData():
        return[sys.stdin], [], [], 0) == ([sys.stdin], [], [])

#check n terminate program on terminal condition,
#from a separate thread
class waitOnInput(Thread):
    def run(self):
        old_settings = termios.tcgetattr(sys.stdin)
            global program_run
            thread_run = True
            while thread_run:
                if isData():
                    c =
                    if c == quit_key:
                        thread_run = False
                        program_run = False
            termios.tcsetattr(sys.stdin, termios.TCSADRAIN, old_settings)
            thread_run = False

t …

Continue reading

11 Jan'12

PyOpenCl on x64 system

UPD: I found unofficial binary builds here:, use x86 builds.

Do not forget to install pytools.

I’ve been into some difficulties since i began installing that software, even with help of

First, easy_install won’t work on x64 systems if installed by executable installer. Instead, use which will determine the correct version of the software.

Next, install numpy.

finally, i’ve got a problem with module compilation. Let’s split it into two problems:

  1. wrong path to vcvarsall.bat (try to add …

Continue reading

24 May'11

Scrapy 0.12 Parsing with python

Based on Scrapy Tutorial (dead link:

  1. Install scrapy and dependencies
sudo apt-get install python-lxml
sudo easy_install -U Scrapy
  1. Create project
scrapy startproject dmoz
  1. Create item models
from scrapy.item import Item, Field

class DmozItem(Item):
    title = Field()
    link = Field()
    desc = Field()
  1. Create spiders (in projname/spiders/)
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from dmoz.items import DmozItem

class DmozSpider(BaseSpider):
    name = ""
    allowed_domains = [""]
    start_urls = [

    def parse(self, response):
        hxs …

Continue reading