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 time | |
import inspect | |
start_time = time.time() | |
debuglevel = 2 #e.g: 0=no 1=error 2=info ... | |
def printdebug(level, message): | |
if debuglevel >= level: | |
curr_time = time.time() - start_time | |
caller = inspect.stack()[1][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
''' | |
Created on Feb 6, 2013 | |
@author: Christoph Gerneth | |
''' | |
import time | |
import inspect | |
class SingletonType(type): |
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
n = 8 #format | |
[line[i:i+n] for i in range(0, len(line), n)] |
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: |
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
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
-- 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
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
#!/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
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--- |
OlderNewer