WordPress password generate/check from python code

2016-02-15 by romanb password, wordpress

If you want to generate wordpress password from python code (like for updating/reseting user wordpress installs) here's code:

siege [error] socket: connection refused

2015-09-26 by romanb benchmark, hacks, linux

If you testing stuff with siege and it starts throwing socket: connection refused errors first check if you did not run out of ports for outgoing connections, then use this commands:

sysctl net.ipv4.tcp_tw_reuse=1
sysctl net.ipv4.tcp_tw_recycle=1

Bitbucket show hg commands button

2013-07-01 by romanb bitbucket, hacks, mercurial, ui

Steve Losh noted on Twitter that there's no usable URL to pull changes from pull request in your command line. Well, there is, sorta, pull request page html contain hidden "merge-commands" <pre> in case there are conflicts, all you have to do is show it.

I used greasemonkey to add "hg" button between "merge" and "edit" buttons on pull request page. It looks like this:

Here is script source:

Distinguishable colors for stack graphs

2013-06-29 by romanb hacks, ui

I needed to stack some data on single graph (like network traffic from multiple hosts).

Colors on such graphs should be distinguishable, best approach is evenly space (hue-wise) color palette. To enhance separation every odd color has lower brightness.

It will look something like this:

or this:

I needed it for RRDgraph so here's perl version:

Patch django form field for testing

2013-04-15 by romanb django, hacks, testing

In case you're wondering how to patch Django form field for testing purposes (like URLField that passes local uri: file://...) here's how:

from .forms import ThatForm
from django import forms

class MyTests(TestCase):
    def test_pass_url(self):
        orig_url = ThatForm.base_fields['url']
        ThatForm.base_fields['url'] = forms.CharField()

        # ... do your thing #

        # and just in case set original field back,
        # if other tests need it:
        ThatForm.base_fields['url'] = orig_url