This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Christoph Gerneth' | |
''' | |
Decorators are one of the most powerful patterns. They can be used to | |
inject code in functions, modify them and infuence their beihavior. | |
[wikipedia](https://en.wikipedia.org/wiki/Decorator_pattern) | |
Here is an example: | |
''' | |
class Tools(object): | |
@classmethod | |
def sayhello(self, func): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Christoph Gerneth' | |
class SingletonType(type): | |
def __call__(self, *args, **kwargs): | |
try: | |
return self.__instance | |
except AttributeError: | |
self.__instance = super(SingletonType, self).__call__(*args, **kwargs) | |
return self.__instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\usetikzlibrary{arrows} | |
\begin{document} | |
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=5cm, | |
thick,main node/.style={circle,fill=blue!20,draw, | |
font=\sffamily\Large\bfseries,minimum size=15mm}] | |
\node[main node] (B) {B}; %Bereit | |
\node[main node] [above left of=B](L) {L}; %Laufend | |
\node[main node] [above right of=B](I) {I}; %Inaktiv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c7h in ~/workspace/TimetableParser/examples on master ● λ python read_semesterplan.py -u if1184 | |
Password: | |
Deine Faecher dieses Semester: | |
00: Entwicklung mobiler Anwendung unter iOS bei Mack, Alexander | |
01: Next Generation Networks bei Sós, Eckhard | |
Heute auf dem Plan: | |
---nichts--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#Hashmap example | |
#Author: Christoph Gerneth | |
#usage: python ordinal-hashmap.py map-size x y STR_1 [STR_2 STR_3 .. STR_N] | |
#x and y are K_x K_y (Glaviner Standard values for Hashfunction | |
#example python ordinal-hash.py 13 1 3 Petrus Andreas Jakobus Johannes Phillippus Bartholomaus Thomas Matthaus Jakobus Thaddaus Simon Judas | |
import sys | |
debug=True | |
chars_start = int(sys.argv[2]) | |
chars_end = int(sys.argv[3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_funcs_from_module(self, functionname_prefix, module): | |
"""read methods from module, starting with a given string and return a list""" | |
moduleValues = module.__dict__.values() | |
functions_in_module = filter(lambda obj: hasattr(obj, '__call__'), moduleValues) | |
matching_functions = filter(lambda k: k.__name__.startswith(functionname_prefix), functions_in_module) | |
return matching_functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- schema for exchange: | |
CREATE TABLE exchange(cur VARCHAR(3), rate DECIMAL(12,3)); | |
INSERT INTO exchange VALUES ("eur", 1.00), ("usd", 1.28), ("czk", 25.98); | |
-- stored procedure | |
DELIMITER :-) | |
CREATE PROCEDURE exrate(IN cur_in DECIMAL(12,3), IN currency VARCHAR(3), OUT cur_out DECIMAL(12,3)) | |
BEGIN | |
DECLARE course DECIMAL(12,3) DEFAULT 1; | |
SET course = (SELECT rate FROM exchange WHERE cur = currency); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def authenticate(username, password, fh="fhin"): | |
""" | |
'authenticates' user at hiplan-app | |
@return: session id | |
@raise LoginFailedException: if login fails | |
""" | |
url = "https://www2.primuss.de/stpl/login.php" | |
values = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
''' | |
Created on 05.05.2013 | |
@author: christoph gerneth | |
ugly, short hack! | |
read in firefox bookmarks and | |
download images from maxgif.com | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import sys | |
import csv | |
def convert(filename): | |
reader = csv.reader(open(filename, 'rb')) | |
for row in reader: |