This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| """ | |
| Walks through django template directory and generates dot file | |
| you can use to generate template inheritance/block usage tree | |
| with GraphViz. | |
| application/templates and custom template loaders are not (yet?) supported | |
| """ | |
| import os, sys, re |
| -- Keyboard layout switching | |
| kbdcfg = { | |
| cmd = "setxkbmap", | |
| layout = { "us", "cz -variant qwerty" }, | |
| current = 1, | |
| widget = widget({ type = "textbox", align = "right" }) | |
| } | |
| kbdcfg.switch = function() | |
| kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1 | |
| local t = " " .. kbdcfg.layout[kbdcfg.current] .. " " |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import urllib2 | |
| from flask import Flask | |
| import requests | |
| app = Flask(__name__) | |
| app.debug = False |
| #!/bin/bash | |
| opera --remote "openURL(g $*,new-page)" > /dev/null | |
| echo "awful.tag.viewonly(tags[mouse.screen][4])" | awesome-client |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
| .py[co] | |
| .idea |
| from itertools import izip_longest | |
| def intseparator(value, separator=" ", group_every=3): | |
| if '.' in value or ',' in value: | |
| return value | |
| def grouper(n, iterable, padvalue=None): | |
| return izip_longest(*[iter(iterable)] * n, fillvalue=padvalue) |
| def NewTorIP(): | |
| s = socket.socket() | |
| s.connect(('localhost', 9051)) | |
| s.send("AUTHENTICATE\r\n") | |
| r = s.recv(1024) | |
| if r.startswith('250'): | |
| s.send("signal NEWNYM\r\n") | |
| r = s.recv(1024) | |
| if r.startswith('250'): | |
| return True |
| import re | |
| # sada regularnich vyrazu pro lepsi typosku | |
| # zdroj: texy-2.1/texy/modules/TexyTypographyModule.php | |
| TEXY_CHARS = ur'A-Za-z\u00C0-\u02FF\u0370-\u1EFF' | |
| TEXY_TYPO_PATTERNS = [ | |
| (re.compile(ur'(?<![.\u2026])\.{3,4}(?![.\u2026])', re.M | re.U), u"\u2026"), # ellipsis ... | |
| (re.compile(ur'(?<=[\d ])-(?=[\d ]|$)'), u"\u2013"), # en dash 123-123 | |
| (re.compile(ur'(?<=[^!*+,/:;<=>@\\\\_|-])--(?=[^!*+,/:;<=>@\\\\_|-])'), u"\u2013"), # en dash alphanum--alphanum |