Skip to content

Instantly share code, notes, and snippets.

@starenka
starenka / columbo.py
Created August 13, 2012 20:51
Walks through django template directory and generates dot file you can use to generate template inheritance/block usage tree with GraphViz. http://junk.starenka.net/columbosvg.png
#!/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] .. " "
@starenka
starenka / showredirects.py
Created August 20, 2012 21:38
shows full redirect path for given url
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
from flask import Flask
import requests
app = Flask(__name__)
app.debug = False
@starenka
starenka / menu.ini
Created August 20, 2012 21:39
opera menu item for calling custom app with url
[Link Popup Menu]
...
Item, "Show Redirects" = Go to page, "javascript:(function(){window.open('http://redirects.lo/url='+encodeURIComponent('%l/'), '_blank', 'width=600,height=500');})()"
...
@starenka
starenka / g.sh
Created August 23, 2012 22:18
shell script to open a new tab with googled term and switch to browser (opera + awesome)
#!/bin/bash
opera --remote "openURL(g $*,new-page)" > /dev/null
echo "awful.tag.viewonly(tags[mouse.screen][4])" | awesome-client
@starenka
starenka / about.md
Created August 30, 2012 20:12 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@starenka
starenka / .gitignore
Created August 30, 2012 22:02
Gets "top" .cz/sk sites as measured by TOPList.cz/sk
.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)
@starenka
starenka / gist:3787412
Created September 26, 2012 11:15 — forked from ehmo/gist:1349819
Request a new IP address from TOR in Python
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
@starenka
starenka / texytypo.py
Created October 1, 2012 09:13 — forked from msgre/texytypo.py
Texy typoška
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