Skip to content

Instantly share code, notes, and snippets.

Shipping up to Boston

Christoph Gerneth c7h

View GitHub Profile
c7h / gist:4722329
Last active Dec 12, 2015
primitive built-in debugging w. execution time measurement.
View gist:4722329
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]
c7h / gist:4730089
Created Feb 7, 2013
primitive debugging class as Singleton
View gist:4730089
Created on Feb 6, 2013
@author: Christoph Gerneth
import time
import inspect
class SingletonType(type):
c7h / gist:5003772
Created Feb 21, 2013
split string - fixed format
View gist:5003772
n = 8 #format
[line[i:i+n] for i in range(0, len(line), n)]
View gist:5396518
import sys
import csv
def convert(filename):
reader = csv.reader(open(filename, 'rb'))
for row in reader:
c7h / gist:5521563
Created May 5, 2013 image download script (via firefox bookmarks)
View gist:5521563
#! /usr/bin/env python
Created on 05.05.2013
@author: christoph gerneth
ugly, short hack!
read in firefox bookmarks and
download images from
c7h / gist:5526802
Last active Dec 17, 2015
authenticates user at HI-PLAN
View gist:5526802
import requests
def authenticate(username, password, fh="fhin"):
'authenticates' user at hiplan-app
@return: session id
@raise LoginFailedException: if login fails
url = ""
values = {
c7h / gist:5943777
Last active Dec 19, 2015
different usage of SQL's stored functions and stored procedures
View gist:5943777
-- 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
CREATE PROCEDURE exrate(IN cur_in DECIMAL(12,3), IN currency VARCHAR(3), OUT cur_out DECIMAL(12,3))
SET course = (SELECT rate FROM exchange WHERE cur = currency);
c7h / gist:6421212
Created Sep 3, 2013
read methods from module, starting with a given string and return a list
View gist:6421212
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
c7h / gist:8670768
Last active Jan 4, 2016
Hashmap Example - Understanding Hashmap - linear probing
View gist:8670768
#!/usr/bin/env python
#Hashmap example
#Author: Christoph Gerneth
#usage: python 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 13 1 3 Petrus Andreas Jakobus Johannes Phillippus Bartholomaus Thomas Matthaus Jakobus Thaddaus Simon Judas
import sys
chars_start = int(sys.argv[2])
chars_end = int(sys.argv[3])
View gist:55399f00a956260a30cb
c7h in ~/workspace/TimetableParser/examples on master ● λ python -u if1184
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:
You can’t perform that action at this time.