Skip to content

Instantly share code, notes, and snippets.

View mdornseif's full-sized avatar

Maximillian Dornseif mdornseif

View GitHub Profile
#!/usr/bin/env python
# c.klein: Django tool for pro-active bug fixing and support:
# find out to which user a session is bound.
from django.core.management import setup_environ
import settings
setup_environ(settings)
from django.contrib.sessions.models import Session
from django.contrib.auth.models import User
c0ldcut:hdMashup md$ git config --global color.diff=auto
c0ldcut:hdMashup md$ git config --global color.status=auto
c0ldcut:hdMashup md$ git config --global color.branch=auto
c0ldcut:hdMashup md$ echo 'EDITOR=/usr/local/bin/mate_wait' >> ~/.bash_profile
c0ldcut:hdMashup md$ echo 'VISUAL=$EDITOR' >> ~/.bash_profile
@mdornseif
mdornseif / appengine_pagination.py
Created October 2, 2010 16:03
Shows how to realize simple pagination on Appengine
import os
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template
class Homepage(webapp.RequestHandler):
def render(self, values, template_name):
path = os.path.join(os.path.dirname(__file__), template_name)
self.response.out.write(template.render(path, values))
def paginate(self, query):
deploy:
appcfg.py update .
check: lib/google_appengine/google/__init__.py
pep8 -r --ignore=E501 views/ *.py views
sh -c 'PYTHONPATH=`python ./config.py` pyflakes *.py views/'
-sh -c 'PYTHONPATH=`python ./config.py` pylint -iy --max-line-length=110 *.py' # -rn
lib/google_appengine/google/__init__.py:
curl -O http://googleappengine.googlecode.com/files/google_appengine_1.3.8.zip
@mdornseif
mdornseif / do_openid_login.py
Created October 17, 2010 16:10
Appengine Authentifizierung gegen Google Apps
#!/usr/bin/env python
# encoding: utf-8
"""
do_openid_login.py
Created by Maximillian Dornseif on 2010-09-24.
Copyright (c) 2010 HUDORA. All rights reserved.
"""
@mdornseif
mdornseif / MyHandler1.py
Created October 17, 2010 19:52
HTTP-Auth & Mehr mit AppEngine
class MyHandler(webapp.RequestHandler):
def __init__(self):
self.credential = None
def initialize(self, request, response):
super(MyHandler, self).initialize(request, response)
uid, secret = None, None
if self.request.headers.get('Authorization'):
auth_type, encoded = self.request.headers.get('Authorization').split(None, 1)
if auth_type.lower() == 'basic':
dependencies: update_submodules update_virtualenv
update_virtualenv:
virtualenv --python=python2.5 --no-site-packages --unzip-setuptools pythonenv
pythonenv/bin/pip -q install -E pythonenv -r requirements.txt
update_submodules: clean
git submodule update --init lib/jinja2/
git submodule update --init lib/CentralServices/
git submodule update --init lib/DeadTrees/
@mdornseif
mdornseif / replicate.py
Created December 18, 2010 08:07
This script replicates databases from one CouchDB server to an other.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2009 Maximillian Dornseif <md@hudora.de>
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution.
"""
This script replicates databases from one CouchDB server to an other.
@mdornseif
mdornseif / sucker.py
Created December 18, 2010 08:10
Eine AS/400 Datenbank auf PostgreSQL spiegeln
#!/usr/bin/python
# Das Python-Setup auf balancer ist beinahe
# totally fucked up
# /usr/local/bin/ liegt im PATH vor /usr/bin,
# aber mit dem von Hand installierten Python
# dort klappt die Geschichte nicht...
# Datenbank als Unicode erzeugen:
# $ createdb softmmirror --encoding=UNICODE -O softm -e
# CREATE DATABASE softmmirror OWNER softm ENCODING 'UNICODE';
@mdornseif
mdornseif / dedupe.sql
Created December 25, 2010 10:05
Dedutpe Table buchdurchschnittspreis2
DELETE FROM buchdurchschnittspreis2
WHERE id in
(SELECT buchdurchschnittspreis2.id FROM buchdurchschnittspreis2
LEFT OUTER JOIN (select min(id) as id from buchdurchschnittspreis2
GROUP BY (artnr, datum) as KeepRows
ON buchdurchschnittspreis2.id=KeepRows.id
WHERE KeepRows.id IS NULL);