About | Blog | xapy

ropevim: vim, one step closer to and IDE

Every vim user, at some point requires the functionality that is well-known from “big” IDEs. A lot of people stop at built-in capabilities, like keyword completion seen in opened buffers, built-in got-to-definition etc. which are limited by their attempt to be universal. In this post I’ll take a look at the tool, designed for working on python code and at the same time providing means of “smart” autocomplete, jumping to identifier’s definition etc.

My own interpretation of rather laconic documentation follows.

 continue reading

Domesticating py-rrdtool

One proverb says: you can watch three things forever: water flowing, fire flaming and rrdtool drawing graphs. This post is about the latter. So what is rrdtool? rddtool — is a wonderful utility, that allows to manipulate the data, stored in rrd (round-robin database). This format is notable for being initially designed for storing periodic information, keeping database size fixed (rather small) independently of data quantity, but you still have the ability to retrieve reports for long periods with any accuracy. The most obvious use-case is in monitoring systems, as it is better to see the picture once, than reading logs hundred times. In the end of this post you can get something similiar to

sample

 continue reading

xapy — yet another chat-bot in python

Some time ago, while beginning using Python PL, i’ve decided to use new skills, porting the simplest irc-bot from php. As time went on, it has developed and grown to another small chat-bot project, but multiprotocol with plugins system, which is introduced here. The main ideas are: simple usage/extension, multiprotocol, abstract plugins: write once, use anywhere. Currently it works with IRC and XMPP (Jabber) networks, and about 20 plugins available, all written in Python, as is the core of the application, allowing to implement the whole power and flexibility, that python offers. Here the first intriduction finishes, leaving links: xapy + hg repository

Angstrom Linux + iPAQ h5450

This is the next attempt to make my HP iPAQ h5450 friends with Linux. Last time I tried Familiar Linux, and though I had some success with it, it seemed too raw to be human-usable, as got neither wifi, nor usb working, so no networking. This time I’ve decided to try The Ångström distribution.

 continue reading

Running Matlab with xmonad WM

A quick note about setting up Matlab to run on xmonad wm. The problem I encountered is clearly described in xmonad FAQ. That is Java applications’ gui is not working in xmonad. I found many solutions, but only one helped me — using jre1.7. Got it from java.net, compiled and put in /tmp/jdk1.7. The trickiest part is starting Matlab after this. It was export MATLAB_JAVA=/tmp/jdk1.7.0/jre && matlab. I hope this can help somebody and save time.

Django ManyToMany field with custom column names

Some time ago i had a task, similar to that, described in django’s Integrating with a legacy database. Among other, i had a task to integrate django admin with existing database, and a small question appeared, which was not answered on the net that time. The question was: We have a table with many-to-many mapping in the database (model1 <-> model2). We want to describe this, using django usual relations. Of course, the best description is the standard ManyToManyField, but one issue appeared: by default it creates a table (with name, configurable with keyword-argument db_table) containing fields, called model1_id and model2_id respectively. As i had pre-defined db schema, its fields’ names, of course, didn’t fit this naming convention, so it required some other solution. So the task is: there is
Product model with guid field and Category model with id field. By default we have a table with columns product_id, category_id and want: guid, manual_classification. And the simple solution is:

class ManyToManyFieldWithCustomColumns(models.ManyToManyField):
    def _get_m2m_column_name(self, related):
        return related.model._meta.pk.db_column
    def _get_m2m_reverse_name(self, related):
        return self.db_column

This can be used as:

categories = ManyToManyFieldWithCustomColumns(Category,db_column='manual_classification',              
                                              db_table='product_classification')

I’m sure there must be a better way of achieving this, for example improving other column’s name (i’ve taken pk’s name). If anybody have something to say — welcome to comments :)

pastebin at fingertips

A simple script for sending files to pastebin. Code inside

 continue reading

My Vim

Some time ago I’ve decided to listen many developers’ experience, about working and everyday-using the Vim text editor. In this post I’d like to describe what I did with my editor for increasing its convenience to the level of almost(?) fully-functional IDE. This is what my editor can do now:

  • Syntax highlight
  • Comfortable color scheme
  • Code folding
  • Code auto-completion
  • Organizing files into projects
  • Exploring code structure
  • Checking python code with pylint and pychecker

Lots of mentioned above is included in standard distribution, all you have to do — set and wind it up. On this and on some manually-installed extensions - inside.

 continue reading

Semi-automatic captcha processing

From time to time we have to automate something - from some simple daily actions to rather difficult, requiring much attention tasks. Naturally our developing, programming skills help us with this. In a perfect world we would also attach mathematical approach, and then such product becomes much more valuable.

In this post i’d like to share my solution, which could help many autoьфеук. The following script is a small module, which can help delegate captcha processing to the user, allowing your scripts to take care about some algorithmic actions surrounding this captcha. The interface is dramatically simplified - from inside it is a function called do_stuff(file), which actually does all stuff :). It takes a file or a file-like object as an argument (for example StringIO(image_buffer) ). In fact - anything Image.open() understands. From the outside - user interface is a simplest Tk window with your image, tet input field and a counter of images currently queued. Also this window has a multi functional checkbox :) In my case, multi threaded processing, it was used to signal current thread to stop. Yep, the module is willing to serve many threads simultaneously.

As an example for the following image:

Captcha image

the result is:

Script result

$ python captcha_dialog.py  
('dvcv', 0)

the code - inside

 continue reading

Hello world

How it usually happens, launching a blog means a first pointless post. As everybody used to it is called ‘Hello world’. Nevertheless, welcome!

P.S. talmuth, happy birthday!