Latest

Writing

Essays and field notes on software, open source, communities, and the systems around them.

Fragmenting one big nginx config

Getting lost in all glory of big nginx.conf is not that uncommon. I could not stand it anymore, so I wrote this little clever script with support of pyparsing module for Python: from pyparsing import * nginx_conf_expr = OneOrMore(Suppress(SkipTo('server' + White())) + originalTextFor(Word('server ') + nestedExpr('{', '}'))).parseWithTabs() server_name_expr = (Suppress(SkipTo('server_name' + White()) + Word('server_name') + White()) + CharsNotIn(' ;')).parseWithTabs() nginx_conf = open('nginx.conf').read() new_nginx_conf = str(nginx_conf) for server in nginx_conf_expr.parseString(nginx_conf): try: name = server_name_expr.parseString(server)[0] f = open('nginxsite_%s.conf' % name, 'w+') f.write(str(server)) f.close() # update nginx config new_nginx_conf = new_nginx_conf.replace(str(server), '') except: print 'Entry failed:\n', server open('new_nginx.conf', 'w').write(new_nginx_conf) Warning! Do not use that on production data before making a backup copy! Script has been tested on ~1500 long nginx config, and is not bulletproof This script basically extracts all server {} entries and writes them to separate files named "nginxsite_sitename.conf" (all in current working directory). It also produces new_nginx.conf that does not include extracted entries. All you need to do is to add include directive to new_nginx.conf like this:

Read article

Public release of BurnerOnFire

I'm proud to release first public version of BurnerOnFire. BurnerOnFire is written in Python, providing simple GUI(GTK+) and CLI interface to burning .iso images simultaneously to multiple CD/DVD burners. Documentation and install instructions are located at kiberpipa.org. Features: write iso image to multiple CD/DVD burners count number of successfully burned discs option to limit number of discs to be burned detects write speeds and intersect results eject/close tray burner TODO: write multiple iso images from a folder

Read article

Writing post-installation-script to create shortcut on Windows desktop

I'm building an GUI program that will be used on Windows platform. I already accepted the fact that I will need three installers (Python, GTK stuff, and one for my package). Now, I want my installer to place shiny little shortcut on my desktop. Here is the command to generate Window installer: python setup.py egg_info -RDb "" bdist_wininst --install-script postinstall.py egg_info -RDb will clear and developemnt tags from release name, so the output will be package-0.1 instead of package-0.1dev

Read article

vnstat — useful CLI utility to get current network traffic rates

Today I was looking for a GNU tool to output current rates of networking traffic. Seems there is no built-in tool in GNU Linux. I decided to go for third-party software and vnstat does it's job pretty good. $ vnstat -i eth0 -tr 6 packets sampled in 5 seconds Traffic average for wlan0 rx 7.34 kB/s 9 packets/s tx 0.94 kB/s 7 packets/s Add a little of PandoraFMS power, and we have a nice looking graph:)

Read article

Read popen.stdout object asynchronously (or why low level knowledge holes are killing me)

I've been programming for about two years, all this time only in Python. I'll say that those 500 lines I wrote in Flash AS2 before going to Python does not count. I'm fluent with standard library that Python provides, but I've noticed quite a few times now; I'm getting stuck on issues that correlate to low level knowledge. I'm thinking it may trigger someday motivation to learn C. Going on topic, everyone that has used Popen at least once knows that file-alike objects (stdout, stderr, etc.) are blocking. Let me give you an example:

Read article