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

05 Mar'12

Python hostname

from socket import gethostname

print gethostname()

if 'prod' in gethostname:

Continue reading

08 Feb'12

Generating keyboard events

import pyatspi
reg = pyatspi.Registry.generateKeyboardEvent
reg(36, None, pyatspi.KEY_preSSRELEASE) #Enter

Continue reading


08 Feb'12

Python chroot

What is important to remember is that chroot will allow you cd into /, and that will correspond to the dir you chrooted in:

for opt in glob.glob("/*"):
    print "\t-> %s" % opt

    print "Chroot FAIL"
    print os.getcwd()
except Exception as e:
    print "Chroot OK"

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