Electricmonk

Ferry Boender

Programmer, DevOpper, Open Source enthusiast.

Blog

Category: python

bbcloner v1.3 released. BitBucket backup tool.

I’ve just released bbcloner v1.3. bbcloner creates mirrors of your public and private Bitbucket Git repositories and wikis. It also synchronizes already existing mirrors. Initial mirror setup requires you manually enter your username/password. Subsequent synchronization of mirrors is done using Deployment Keys. This release features the following changes: Support for updating over https (patch by msboom) […]

my_indexr: Script to drop and recreate MySQL indexes

As can be read in this article, I was in need of a method to quickly drop all indexes (except primary keys) from a MySQL database. After googling around a bit and being astonished that apparently no-one had written such a thing yet, I wrote the script that can be seen in that article. Unfortunately, […]

Think Bayes: Bayesian Statistics in Python

There’s a free download available of “Think Bayes – Bayesian Statistics in Python” over at it-ebooks.info. A small excerpt from the book: The premise of this book, and the other books in the Think X series, is that if you know how to program, you can use that skill to learn other topics. Most books […]

Increasing performance of bulk updates of large tables in MySQL

I recently had to perform some bulk updates on semi-large tables (3 to 7 million rows) in MySQL. I ran into various problems that negatively affected the performance on these updates. In this blog post I will outline the problems I ran into and how I solved them. Eventually I managed to increase the performance […]

Quick-n-dirty HAR (HTTP Archive) viewer

HAR, HTTP Archive, is a JSON-encoded dump of a list of requests and their associated headers, bodies, etc. Here’s a partial example containing a single request: { “startedDateTime”: “2013-09-16T18:02:04.741Z”, “time”: 51, “request”: { “method”: “GET”, “url”: “http://electricmonk.nl/”, “httpVersion”: “HTTP/1.1”, “headers”: [], “queryString”: [], “cookies”: [], “headersSize”: 38, “bodySize”: 0 }, “response”: { “status”: 301, “statusText”: […]

bbcloner: create mirrors of your public and private Bitbucket Git repositories

  I wrote a small tool that assists in creating mirrors of your public and private Bitbucket Git repositories and wikis. It also synchronizes already existing mirrors. Initial mirror setup requires that you manually enter your username/password. Subsequent synchronization of mirrors is done using Deployment Keys. You can download a tar.gz, a Debian/Ubuntu package or clone […]

python-libtorrent program doesn’t exit

(TL;DR: To the solution) I was mucking about with the Python bindings for libtorrent, and made something like this: import libtorrent fname = ‘test.torrent’ ses = libtorrent.session() ses.listen_on(6881, 6891) info = libtorrent.torrent_info(fname) h = ses.add_torrent({‘ti’: info, ‘save_path’: session_dir}) prev_progress = -1 while (not h.is_seed()): status = h.status() progress = int(round(status.progress * 100)) if progress != […]

Python UnitTest: AssertRaises pitfall

I ran into a little pitfall with Python’s UnitTest module. I was trying to unit test some failure cases where the code I called should raise an exception. Here’s what I did: def test_file_error(self): self.assertRaises(IOError, file(‘/foo’, ‘r’)) I mistakenly thought this would work, in that assertRaises would notice the IOError exception and mark the test […]

Evolutionary Algorithm: Evolving “Hello, World!”

Note: The latest version of this article is always available from the Writings page in HTML, PDF, ePub and AsciiDoc (source) format. My interest in Evolutionary Algorithms started when I read On the Origin of Circuits over at DamnInteresting.com. I always wanted to try something like that out for myself, but never really found the […]

PyWebkitGTK: ‘module’ object has no attribute ‘WebView’

If you’re working with PyWebkitGTK, and you get the following error: Traceback (most recent call last): File “./webkit.py”, line 7, in import webkit File “/home/todsah/webkit.py”, line 18, in class BrowserPage(webkit.WebView): AttributeError: ‘module’ object has no attribute ‘WebView’ … make sure you haven’t named your script ‘webkit.py‘, and there is no other script with the same […]

The text of all posts on this blog, unless specificly mentioned otherwise, are licensed under this license.