Skip to content

Instantly share code, notes, and snippets.

View imankulov's full-sized avatar

Roman Imankulov imankulov

View GitHub Profile
@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 / 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 / dictify.py
Created February 18, 2015 18:01
dictify.py -- extract "__dict__" contents from all objects recursively, and build a tree of them.
import json
def dictify(obj):
"""
Recursively find all dicts in a stricture, and convert them to attr dict
"""
if isinstance(obj, (list, tuple, set)):
return obj.__class__([dictify(item) for item in obj])
if isinstance(obj, dict):
@imankulov
imankulov / status.py
Created January 18, 2011 08:53
Status object which can be used as boolean or string (useful to allow / reasonable forbid an action)
"""
Example
Create objects:
>>> status = Status(False, u'You are not allowed to do this')
>>> status = Status(True)
Use objects:
@imankulov
imankulov / htmldiff.py
Created January 24, 2012 04:18
Simple script to show diff between two HTML pages in understandable format
#!/usr/bin/env python
""" Simple script to show diff between two HTML pages in understandable format """
import urllib2, tidy, sys, subprocess
tidy_kwargs = dict(
output_xml=1,
indent=1,
indent_attributes=1,
wrap=80,
char_encoding='raw',
@imankulov
imankulov / htmldiff.py
Created January 24, 2012 04:18
Simple script to show diff between two HTML pages in understandable format
#!/usr/bin/env python
""" Simple script to show diff between two HTML pages in understandable format """
import urllib2, tidy, sys, subprocess
tidy_kwargs = dict(
output_xml=1,
indent=1,
indent_attributes=1,
wrap=80,
char_encoding='raw',
@imankulov
imankulov / gist:2145938
Created March 21, 2012 10:08
Python hook skeleton for gitolite
#!/usr/bin/env python
"""
Python hook skeleton for gitolite.
- Place this file as ~/.gitolite/hooks/common/<hook-name> (i.e. as
~/.gitolite/hooks/common/post-receive)
- Run "gl-setup" in console
- Define a number of function with @hook() decorators inside
Providing such configuration, every function is executed as a hook for a
@imankulov
imankulov / registrar.py
Created April 18, 2012 11:26
Registrar decorator
"""
Registrar decorator can be used to add objects (function and classes) to the
registry.
>>> reg = Registrar()
>>> @reg('foo')
... def foo():
... print 'foo'
...
>>> @reg('bar')
@imankulov
imankulov / memcached_test.py
Created April 27, 2012 04:08
Find out why this script doesn't work (memcached test)
# -*- coding: utf-8 -*-
"""
Why memcached doesn't work?
We observe weird behaviour of the function save_object_to_cache(...)
--------------------------------------------------------------------------------
$ python /tmp/memcached_test.py
A new object <__main__.Wrapper object at 0x925f60c> with value "bar" has been created
@imankulov
imankulov / menu.py
Created April 30, 2012 08:09
Simple django templatetag for menu items
# -*- coding: utf-8 -*-
"""
Templatetag to be used in Django templates along with Twitter bootstrap CSS
library.
To make it work you must make sure that settings.py file contains a line like
this:
TEMPLATE_CONTEXT_PROCESSORS = (