Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@starenka
starenka / phonere.py
Created September 20, 2011 21:05
dummy phone nr check
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import unittest
pattern = re.compile(r'^(\+?(00)?\s?\d{2,3}[-\.\s]?)?((\d{2,3})[-\.\s]?){3,}$')
class ReTest(unittest.TestCase):
NOMNOM = ('728 889 137',
@starenka
starenka / justicepy.py
Created October 4, 2011 10:08
justice.cz search "API"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pyquery import PyQuery as pq
class JusticePy(object):
URL = 'http://www.justice.cz/xqw/xervlet/insl/index?sysinf.%%40typ=or&sysinf.%%40strana=searchResults&hledani.%%40typ=subjekt&hledani.podminka.subjekt=%(subject)s&hledani.podminka.ico=%(ic)s&hledani.podminka.obec=&hledani.podminka.spisZnacka.oddil=&hledani.podminka.spisZnacka.vlozka=&hledani.podminka.spisZnacka.soud=0&hledani.format.pocet_polozek=50&hledani.format.trideni=netridit&hledani.format.typHledani=x*&hledani.format.obchodniJmeno=platne&hledani.podminka.pravniForma=-1&hledani.podminka.ulice='
ALLOWED = ('subject', 'ic')
def search(self, **kwargs):
@starenka
starenka / braces.py
Created October 9, 2011 22:31
in your face
starenka@kosmik1:~$ ipython
Python 2.7.2+ (default, Aug 16 2011, 09:23:59)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
@starenka
starenka / battery_status.sh
Created October 22, 2011 00:59
show battery status, you can use it in your prompt f.e like this PS1="[\$(~/bin/battery_status.sh)] \[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
NON='\033[00m'
BLD='\033[01m'
BNK='\e[5m'
NBK='\e[m'
RED='\033[01;31m'
GRN='\033[01;32m'
YEL='\033[01;33m'
declare -A states
states['Charging']="+"
#!/usr/bin/env bash
PROJECTS_DIR="/www/outcomm/"
REPOS="ssh://chrootuser@esrv1.komunikacniagentura.cz//home/chrootuser/repos/"
VENVWRAPPER_SCRIPT="$(which virtualenvwrapper.sh)"
if [ -z "$1" ]; then echo "I need a repo name to setup the project, smeghead! (you can also specify alias as a second arg)"; exit 1; fi
if [ -z "$2" ]; then AS="$1"; else AS="$2"; fi
. $VENVWRAPPER_SCRIPT
TAR=$PROJECTS_DIR$AS
@starenka
starenka / vodapwn.py
Created November 6, 2011 18:56
Scrapes customer phone number and billed amount from Vodafone website. Just login and have fun.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import mechanize
from pyquery import PyQuery as pq
START = 1530680
PAGES = 1e3
@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
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"}'
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import codecs, sys
from optparse import OptionParser
usage = "\n\t$FILE [-i]"
parser = OptionParser(usage)
parser.add_option('-i','--input',action='store',dest='input',default = False, help='input file')
(options,args) = parser.parse_args()
@starenka
starenka / dudlajda.sh
Created December 26, 2011 18:44
fight spam
for i in {1..5000}; do rand=`python -c 'from random import choice;import string;print "".join([choice(string.letters+string.digits) for i in range(20)])'`; curl -X POST -d "{\"email\":\"$rand@alza.cz\"}" --header 'Content-Type: application/json; charset=utf-8' --header 'X-Requested-With: XMLHttpRequest' http://www.alza.cz/Services/EShopService.svc/SendActionEmail; done