Skip to content

Instantly share code, notes, and snippets.

View mdornseif's full-sized avatar

Maximillian Dornseif mdornseif

View GitHub Profile
@mdornseif
mdornseif / huLint.py
Created May 3, 2012 18:20
This program analyzes Python code with pylint and calculates a credit for the code, depending on a miimum required score and the previous run.
#!/usr/bin/env python
"""
Credit System for Python Code
This program analyzes Python code with pylint
and calculates a credit for the code, depending
on a miimum required score and the previous run.
"""
import sys
def versionsverbesserung_fuer_sofort([{'artnr': menge}, ...]):
ret = defaultdict(0)
erfuellbar = True
# wir koennen ja theoretisch mehrfach auf den selben Artikel zugreifen
# deswegen merken wir uns, was wir schon an freier menge "verbruacht"
# haben.
freimengenspeicher = {}
for artnr, menge in ...:
eap = get_eap(artnr)
if eap.fuer_kunde:
@mdornseif
mdornseif / -
Created February 15, 2016 09:51
diff --git i/modules/market/mk_controllers.py w/modules/market/mk_controllers.py
index 6334a83..90903ce 100644
--- i/modules/market/mk_controllers.py
+++ w/modules/market/mk_controllers.py
@@ -16,6 +16,7 @@ from google.appengine.ext import ndb
from huTools import postmark
import config
+
from modules import bot
diff --git i/modules/market/mk_forms.py w/modules/market/mk_forms.py
index dd3646a..e78a8d8 100644
--- i/modules/market/mk_forms.py
+++ w/modules/market/mk_forms.py
@@ -6,6 +6,8 @@ modules/market/mk_forms.py
Created by Christian Klein on 2015-12-01.
Copyright (c) 2015 HUDORA GmbH. All rights reserved.
"""
+import logging
+
#!/usr/bin/env python
# encoding: utf-8
"""
paffrater.py - Dieses Progrtamm liesst Volksbank Kontoauszüge und konvertiert sie in OFX.
OFX wurde mit xero.com getestet.
Created by Maximillian Dornseif on 2010-06-05.
Copyright (c) 2010, 2013 HUDORA. All rights reserved.
"""
@mdornseif
mdornseif / Makefile
Last active December 27, 2015 08:59
Makefile snippet to ensure python code quality
# Dateien, die wir strenger checken.
STRICT_LINT_FILES= views/admin.py modules/beliza
# Alle Projektdateien
LINT_FILES= $(STRICT_LINT_FILES) *.py controllers/ modules/ views/ bin/import_rechnung.py
LINT_LINE_LENGTH= 110
LINT_FLAKE8_ARGS= --max-complexity=18 --builtins=_ --max-line-length=$(LINT_LINE_LENGTH)
GOOD_NAMES=_,setUp,application,fd,gaetk_replication_SQL_INSTANCE_NAME,gaetk_replication_SQL_DATABASE_NAME,gaetk_replication_SQL_QUEUE_NAME
def ig2adn(profile):
logging.debug(profile)
instagram_client = InstagramAPI(access_token=profile.ig_access_token)
try:
media, next = instagram_client.user_recent_media()
except InstagramAPIError, msg:
if 'The "access_token" provided is invalid.' in str(msg):
# profile.ig_access_token = None
# profile.put()
return
class UeCheckin2(gaetk.handler.BasicHandler):
def put(self, uuid):
key = "sekrit" # determined by some other process
bodyhash = base64.b64encode(hashlib.sha256(self.request.body).digest())
toBeSigned = "&".join([self.request.method, self.request.path, bodyhash])
signature = base64.b64encode(hmac.new(key, toBeSigned, hashlib.sha256).digest())
header = self.request.headers['Authorization']
typ, value = header.split()
if typ != 'X-Signature':
raise gaetk.handler.HTTP401_Unauthorized
@mdornseif
mdornseif / appengine_config.py
Created September 24, 2013 10:20
Limiting certain countries
class RateLimitTimeMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
if environ.get('HTTP_X_APPENGINE_COUNTRY', '??') in ['KW', 'CN']:
start_response('429 Too Many Requests', [('Content-type', 'text/html')])
return ["""<html><head><title>429 Too Many Requests, sorry...</title>
<style>body { font-family: verdana, arial, sans-serif; background-color: #fff; color: #000; }</style>
</head><body><div style="margin-left: 4em;"><h1>We're sorry...</h1>
#!/usr/bin/env python
# encoding: utf-8
import sys
def main():
if len(sys.argv) < 2:
sys.stderr.write('Usage: %s filename\n' % sys.argv[1])
sys.exit()