Skip to content

Instantly share code, notes, and snippets.

View albsen's full-sized avatar

A. Sebastian Dietzel albsen

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/python
import subprocess
# PyObjC-related imports
from AppKit import NSApplication, NSSystemDefined
from PyObjCTools import AppHelper
KEY_UP = 11
@albsen
albsen / redisdns.py
Created November 12, 2012 10:05
Python DNS server with Redis backend
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <[email protected]>
import socket
@albsen
albsen / hack.sh
Created April 5, 2012 03:27 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@albsen
albsen / pbc_pool_transport.py
Created February 4, 2012 13:46 — forked from jdmaturen/pbc_pool_transport.py
Riak python client PBC connection pooling
import logging
log = logging.getLogger('socrates')
from Queue import Empty, Full, Queue
from riak.transports import RiakPbcTransport
from riak.transports.transport import RiakTransport
class PbcPoolTransport(RiakTransport):
@albsen
albsen / redis_sessions.py
Created October 23, 2011 13:22 — forked from ericflo/redis_sessions.py
A Redis-based Django secure session store.
from django.core.exceptions import SuspiciousOperation
from django.utils.encoding import force_unicode
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
import redis
class SessionStore(SessionBase):
"""
A Redis-based session store.
"""
from django.contrib.admin.views.decorators import staff_member_required
@staff_member_required
def login_using_email(request, email):
'''DONT EVER USE this method for normal purposes. This is only there, for debugging specific problems related to users'''
from django.contrib.auth import get_backends
from django.contrib.auth import login as django_login
from django.contrib.auth.models import User