Skip to content

Instantly share code, notes, and snippets.

View imankulov's full-sized avatar

Roman Imankulov imankulov

View GitHub Profile
@imankulov
imankulov / p12_to_pem.py
Last active August 29, 2015 14:07
Convert PKCS#12 certificate and key files to PEM
#!/usr/bin/env python
"""
Quick, dirty and insecure tool to extract certificate info and private key
from the PKCS#12 certicate and dump it to separate files in PEM format
(because openssl command-line tool is a mess)
Usage: p12_to_pem path/to/file.p12 password
"""
import os
@imankulov
imankulov / the flow™.txt
Created October 17, 2014 14:12
the flow™
* __project notes__
[[NOTE]]: - We use colors (priorities) to mark the complexity of the task - It's okay to change the complexity on the task, as you work on it - We use a flow where tasks "bubble up" from the backlog to done - Depending on the project, you may have more (or less, without "testing", for instance) stages of the flow - One may or may not use tags
...Trivial. It's barely worth creating a separate item
...Easy. No hidden pitfalls, straightforward execution flow, short time to work [[priority 3]]
...Hard. Challenging. Pitfalls expected. Or just long and boring [[priority 2]]
...Super-hard. But you're not scared. Subtasks required [[priority 1]]
* !!Done!!
[[NOTE]]: Move all completed tasks here. They pass the testing phase and are in production, or ready to production. Tasks have to be stricken through
...Trivial task @feature
...Serious bug [[priority 2]]
@imankulov
imankulov / test_pool.py
Created June 10, 2014 08:57
Test generator and releaser which know how to create fixtures in separate threads
"""
Generator and Releaser objects which could be used to create and destroy
objects in separate threads. Generator constantly keeps the pool of N objects
to use by the test function (by default N equals to 1).
How to use them:
You create a session-scope generator and releaser. They are subclasses
of threading.Thread, so you should start them as well.
@imankulov
imankulov / watcher.py
Created November 9, 2013 18:40
Watchers. When something goes wrong, and only restart helps.
#!/usr/bin/env python
import argparse
import shlex
import subprocess
import time
def get_arguments():
parser = argparse.ArgumentParser()
parser.add_argument('-p', '--period', type=int, default=30)
@imankulov
imankulov / db_test.py
Created June 24, 2013 12:44
Performance test for MySQL UPDATE
# -*- coding: utf-8 -*-
"""
Performance test for different types of update
Results sample
-----------------------------------------------
In [1]: import db_test
@imankulov
imankulov / urlunquote.py
Created April 28, 2013 19:36
urlunquote sample
import urllib
urls = [
'http://ru.wikipedia.org/wiki/%D0%91%D0%B5%D0%B4%D1%83%D0%B8%D0%BD%D1%8B',
'http://ru.wikipedia.org/wiki/%C1%E5%E4%F3%E8%ED%FB',
]
def urlunquote(url, guess_charsets=None):
if guess_charsets is None:
guess_charsets = ['utf-8', 'cp1251']
@imankulov
imankulov / watchmedo.sh
Created March 26, 2013 19:37
One-liner. Auto-building Sphinx docs with watchdog. Forked from http://jacobian.org/writing/auto-building-sphinx/
# pip install watchdog
exec watchmedo shell-command --patterns='*.rst;*.py' --ignore-pattern='_build/*' --recursive --command='make html' --wait
@imankulov
imankulov / test_payments_bare.py
Created March 11, 2013 14:54
py.test fixture creation problem.
# -*- coding: utf-8 -*-
# This is how I'd implement this using only bare pytest functionality
import pytest
from user import add_transaction, delete_transaction, get_user_balance
# Attempt 1.
# According to the documentation at http://pytest.org/latest/fixture.html
# try to start with a simple fixture
@imankulov
imankulov / parse_djangocon_eu.py
Last active December 10, 2015 22:28
DjangoCon Europe voting results parser
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# requirements: requests, lxml
import requests
from lxml import html
def get_tree():
resp = requests.get('http://2013.djangocon.eu/vote/')
tree = html.fromstring(resp.text)
@imankulov
imankulov / android2po_plurals.py
Created December 17, 2012 14:54
Get gettext formatted plural forms from CLDR description using android2po (to do the main job) and opterator (for command line parsing)
#!/usr/bin/env python
"""
Requirements:
android2po
opterator
Sample:
$ python android2po_plurals.py pl