Skip to content

Instantly share code, notes, and snippets.

Avatar

Petr Messner messa

View GitHub Profile
@messa
messa / sifra.py
Created May 30, 2011
Python example - decryption of simple substitution cipher using recursion
View sifra.py
#!/usr/bin/env python
from StringIO import StringIO
import unittest
import sys
sys.setrecursionlimit(4000)
def resolve(ciphertext, allWords):
View imgresize.py
#!/usr/bin/env python
import optparse
from PIL import Image
def main():
op = optparse.OptionParser()
options, args = op.parse_args()
View connect.py
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
Sklik API keyword stats example
View create_report.py
#!/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 Jul 12, 2012
How to create report using Sklik API from report template in another account
View sklik-api-creating-report-example.md

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 / stream.py
Created Jul 19, 2012
Twitter Streaming API example
View stream.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import json
import oauth2 # https://raw.github.com/brosner/python-oauth2/master/oauth2/__init__.py
from pprint import pprint
import urllib2
stream_url = "https://stream.twitter.com/1/statuses/filter.json"
@messa
messa / inject_ssl_version.py
Created Oct 10, 2012
Python snippet for forcing SSL version
View inject_ssl_version.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from contextlib import contextmanager
import ssl
@contextmanager
def inject_ssl_version(version=ssl.PROTOCOL_TLSv1):
"""
@messa
messa / strhash.txt
Created Sep 30, 2013
To, že mají dva řetězce stejný hash neznamená, že jsou stejné...
View strhash.txt
$ cat Demo.java
class Demo {
public static void main(String args[]) {
System.out.println("Aa".hashCode());
System.out.println("BB".hashCode());
}
}
$ javac Demo.java
$ java Demo
@messa
messa / overeni.py
Last active Dec 24, 2015
Ortogonální pole 2^4 3^2
View overeni.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
tabulka = """
000002
011011
101100
110111
011120
100022
View main_paths.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
fin = ("2",)
dvojice = """
0 1
1 2
1 3
3 4