Skip to content

Instantly share code, notes, and snippets.

View mdornseif's full-sized avatar

mdornseif mdornseif

View GitHub Profile
for incoice in ecommerce_invoices_created_in_the_last_48_hours:
results = xero.search_by_invoice_number(incoice.number)
if len(results) == 0:
# There is a race condition between these two calls.
xero.insert_new_invoice(incoice.number, incoice)
@mdornseif
mdornseif / gist:894134
Created March 30, 2011 09:39
Find Invoices to get a Payment reminder
def get_invoices(datum):
"""Returns a dict if invoices generated before `datum` and unpayed."""
# Create your consumer with the proper key/secret.
consumer = oauth.Consumer(key=CONSUMER_KEY, secret=CONSUMER_SECRET)
client = oauth.Client(consumer, token=oauth.Token(key=CONSUMER_KEY, secret=CONSUMER_SECRET))
client.set_signature_method(XeroOAuthSignatureMethod_RSA_SHA1())
urlbase = 'https://api.xero.com/api.xro/2.0/Invoices'
datum = datum.strftime('%Y-%m-%dT00:00:00')
query = 'Date<=DateTime.Parse("%s")&&Status=="AUTHORISED"&&AmountPaid==0' % datum
@mdornseif
mdornseif / replication.py
Created May 1, 2011 20:35
Replication of AppEngine & Minimal implementation for generating zipfiles. See also http://mdornseif.github.com/2011/05/01/writing-zipfiles-to-blobstore.html
#!/usr/bin/env python
# encoding: utf-8
"""
replication.py - extport data to external systems
Created by Maximillian Dornseif on 2011-05-01.
Copyright (c) 2011 HUDORA. All rights reserved.
"""
from __future__ import with_statement
@mdornseif
mdornseif / zib_datastore.py
Created May 1, 2011 20:44
This is shows how to generate ZIP files in the blobstore.
def store_pdfs_in_zip():
docs = Dokument.all().order('updated_at')
file_name = files.blobstore.create(mime_type='application/zip',
_blobinfo_uploaded_filename='test.zip')
with files.open(file_name, 'w') as f:
z = blobstoreZipFile(f)
for doc in docs.fetch(75):
pdf = doc.data
fname = "%s-%s.pdf" % (doc.designator, doc.updated_at)
fname = fname.encode('ascii', 'replace')
@mdornseif
mdornseif / gitinfo.sh
Created May 5, 2011 05:55
Änderungen an einem Software Projekt darstellen.
#!/bin/sh
RANGE="0df535ff5b8730a7241d3ff79e6957cfb12a12b3..HEAD"
START=`echo $RANGE | cut -d '.' -f 1`
PWD=`pwd`
PROJECT=`basename $PWD`
git --no-pager log --date=short "--pretty=tformat:%ad $PROJECT %h %d %s (%an)" $RANGE
for SUBINFO in `git submodule summary $START | grep -E '^\* lib/' | cut -d ' ' -f 2-3 | perl -npe 's/ /:/'`
do
@mdornseif
mdornseif / palfakt.diff
Created July 13, 2011 09:58
Probleme bei der Palettenkatorermittlung / Versandkosten
diff --git a/cs/kostenschaetzung.py b/cs/kostenschaetzung.py
index e7c332d..e728eee 100644
--- a/cs/kostenschaetzung.py
+++ b/cs/kostenschaetzung.py
@@ -226,7 +226,20 @@ class AusgangskostenReport(object):
ve1 = 0
rest = 0
- kalkulatorische_paletten = float(menge) / artikelpass.palettenfaktor
+ try:
@mdornseif
mdornseif / latitudedumper.py
Created July 13, 2011 21:43
Moving Google Latitude Data from one user to an other
# Google latitude backup
#
# This is a little helper to backup your location from Google Latitude to local disk.
# It saves data as JSON and as GPX.
# Usage is somewhat annoying:
#
# 1. get OACurl http://code.google.com/p/oacurl/
# 2. follow the steps in http://code.google.com/apis/latitude/oacurl.html to get strarted
# You will have to register a domain with Google Apps and jump through hoops
# 3. Renerate a Key and a Secret for "installed applications" on the google API console,
@mdornseif
mdornseif / bejeweled.py
Last active September 26, 2015 19:08
simple bot to play Bejeweled 3 on a Mac for you - something like http://www.youtube.com/watch?v=nhgWLZFn-PM
#!/usr/bin/env python
# encoding: utf-8
"""
bejeweled.py - simple bot to play Bejeweled 3 on a Mac for you
Created by Maximillian Dornseif on 2011-08-09.
"""
import sys
import os
@mdornseif
mdornseif / doit_gource.sh
Created September 6, 2011 13:27
Projektstatistik anlegen
set -e
set -x
# damit dass alles klappt, muss man git, subversion, gnuplot und gource installiert haben
# 1. Step Create a clean Git repository with all our git repositories in it
function handle_repos {
ssh-add -k
git clone [email protected]:hudora/$1.git
@mdornseif
mdornseif / diff.patch
Created September 9, 2011 07:02
versionsdokumentation
mooncrusher:EDIhub md$ git diff main.py
diff --git a/main.py b/main.py
index 2d7e3e7..86b870b 100755
--- a/main.py
+++ b/main.py
@@ -10,6 +10,7 @@ Copyright (c) 2010, 2011 HUDORA. All rights reserved.
import config
config.imported = True
+import gaetk.handler