Skip to content

Instantly share code, notes, and snippets.

View reclosedev's full-sized avatar

Roman Haritonov reclosedev

  • Russia, Nizhny Novgorod
View GitHub Profile
@idan
idan / oauthlib_twitter_example.py
Created May 2, 2012 22:50
Requests + OAuth, sample usage
import requests
from requests.auth import OAuth1
url = u'https://api.twitter.com/1/account/settings.json'
client_key = u'...'
client_secret = u'...'
resource_owner_key = u'...'
resource_owner_secret = u'...'
@e000
e000 / socks.py
Created March 14, 2011 20:21
socksipy + urllib2 handler
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@rozza
rozza / auth_backend.py
Created May 11, 2010 20:24
Custom auth backend with an extended AnonymousUser
from django.contrib.auth import SESSION_KEY, BACKEND_SESSION_KEY, load_backend
from users.models import AnonymousUser
def get_user(request):
try:
user_id = request.session[SESSION_KEY]
backend_path = request.session[BACKEND_SESSION_KEY]
backend = load_backend(backend_path)
user = backend.get_user(user_id) or AnonymousUser()
except KeyError: