Skip to content

Instantly share code, notes, and snippets.

Shipping up to Boston

Christoph Gerneth c7h

View GitHub Profile
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:
c7h / gist:096f09925cbbea8fb11b
Created May 29, 2015
Process States in LaTeX with tikz
View gist:096f09925cbbea8fb11b
\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
c7h /
Created Jun 14, 2015
the _drop-method is used for unittesting. Easy way to get rid of all your old instances.
__author__ = 'Christoph Gerneth'
class SingletonType(type):
def __call__(self, *args, **kwargs):
return self.__instance
except AttributeError:
self.__instance = super(SingletonType, self).__call__(*args, **kwargs)
return self.__instance
View gist:e2c73880159ab3502539
__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.
Here is an example:
class Tools(object):
def sayhello(self, func):
c7h / gist:e0aa37201f255fd5e92a
Created Jul 3, 2015
CSV DictWriter Example
View gist:e0aa37201f255fd5e92a
__author__ = 'Christoph Gerneth'
from csv import DictWriter
from random import randrange
filename = 'data.csv'
label = ['x-axis', 'y-axis']
with open(filename, 'w') as f:
csvw = DictWriter(f, fieldnames=label)
c7h /
Created Nov 16, 2015
understanding binary search trees
class BinSearchTreeElement(object):
def __init__(self, data, leftTree=None, rightTree=None): = data
self.left = leftTree
self.right = rightTree
def add(self, element):
if element <=
self._insertElement(self.left, element)
c7h /
Created Dec 9, 2015
logfile evaluation
my $user_c = 0;
my $user_min = 0;
my @ip = ();
while(<>) {
if (m/(^\w+).*(\d{2}:\d{2})/) {
if ($1 eq 'christoph'){
$user_c++; # user_zaehler erhöhen
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)]
You can’t perform that action at this time.