Archive for the ‘Uncategorized’ Category.

Pinyin Tones Transformation

Well this is for those of you who learn Mandarin. Sometimes you need to type a phrase in pinyin and add some tone marks because digital notation (Wo3 shi4 Mei3guo2 ren2) looks ugly (Wǒ shì Měiguó rén is a way better). I’ve just made a WordPress plugin for this. This is a plugin homepage, but if you want to know how it works or just need code not-for-wordpress, please read the rest of this entry.
Continue reading ‘Pinyin Tones Transformation’ »

Yahoo Search Marketing: Python SOAP binding

Recently, I’ve been trying to make Yahoo Search Marketing API work with Python. SOAPpy, you know, as it is used by Adwords API and thus seemed fine to me. But the very first API call using SOAPpy (getCampaignsByAccountID) failed with the message “Account ID specified in the header does not match the one specified in the parameter.” although they both were fine. Yahoo team refused to give any support on this. Long story short, I’ve found out that YWS API really does care about the parameter order.
Continue reading ‘Yahoo Search Marketing: Python SOAP binding’ »

Text generation with Markov chains

Markov chains can be used by spammers (a bit outdated approach) to generate random texts from real ones. Not so useful for spammers though, so I did it actually for lulz. Here are some examples and some code follows.
Continue reading ‘Text generation with Markov chains’ »

How to draw a smooth curve chart

Some of us need to draw charts from time to time. Usually you have little choice, you either use a bar chart:

vbarchart

or a polygon chart:

linechart

In this post I will describe how to draw a pretty smooth curve chart using python and cairo. You can adapt this routine to be used with django, pycha or any other image creation library, code snippets in comments are appreciated.
Continue reading ‘How to draw a smooth curve chart’ »