Skip to content

Instantly share code, notes, and snippets.

View messa's full-sized avatar

Petr Messner messa

View GitHub Profile
@messa
messa / lepl-example.py
Created May 5, 2010 12:00
lepl (Python parsing module) example
#!/usr/bin/env python2.6
from lepl import *
retezec = String() | String("'")
cislo = Digit()[1:] > (lambda chars: int("".join(chars)))
slovnik = Delayed()
klicSlovniku = retezec | cislo
hodnotaSlovniku = retezec | cislo | slovnik
all: a b
echo a
time ./a
time ./a
echo b
time ./b
time ./b
a: a.cc
g++ -O2 -o a a.cc
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Až moc jednoduchý textový editor.
Vlevo je seznam úryvků, dvojklikem na nějaký se úryvek vloží do textu.
"""
import pygtk
pygtk.require("2.0")
#! /usr/bin/python
# -*- coding: UTF-8 -*-
import settings
import urllib
import xml.etree.ElementTree as etree
class getTags:
def __init__(self):
@messa
messa / qtexample.py
Created August 5, 2010 12:20
I just wanted to test and show something about processEvents
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import time
from PyQt4 import QtGui, QtCore
app = QtGui.QApplication(sys.argv)
widget = QtGui.QWidget()
@messa
messa / imgresize.py
Created January 11, 2012 16:13
imgresize
#!/usr/bin/env python
import optparse
from PIL import Image
def main():
op = optparse.OptionParser()
options, args = op.parse_args()
def connect(*args):
maps = list()
for collection, keyGetter in args:
m = dict()
for item in collection:
key = keyGetter(item)
m[key] = item
maps.append(m)
@messa
messa / create_report.py
Created May 25, 2012 07:48
Sklik API keyword stats example
#!/usr/bin/env python
"""
Command-line tool for creating Statistical report from Report template
using Sklik.cz API.
Sklik.cz API documentation: http://api.sklik.cz/
Contact: http://bit.ly/sklik-contact-form
"""
@messa
messa / sklik-api-creating-report-example.md
Created July 12, 2012 12:18
How to create report using Sklik API from report template in another account

How to create report from report template in another account using Sklik API

Demonstrated in Python.

>>> import xmlrpclib
>>> from pprint import pprint

Connect to Sklik API:

@messa
messa / inject_ssl_version.py
Created October 10, 2012 14:57
Python snippet for forcing SSL version
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from contextlib import contextmanager
import ssl
@contextmanager
def inject_ssl_version(version=ssl.PROTOCOL_TLSv1):
"""