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: |
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
''' | |
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
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
#!/usr/bin/perl | |
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 |
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
class BinSearchTreeElement(object): | |
def __init__(self, data, leftTree=None, rightTree=None): | |
self.data = data | |
self.left = leftTree | |
self.right = rightTree | |
def add(self, element): | |
if element <= self.data: | |
self._insertElement(self.left, element) | |
else: |
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' | |
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) | |
csvw.writeheader() |
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): |