Skip to content

Instantly share code, notes, and snippets.

View teserak's full-sized avatar
🏠
Working from home

Konrad Rymczak teserak

🏠
Working from home
View GitHub Profile
@teserak
teserak / staritems.py
Created April 18, 2012 06:17
Migrate stars and likes in Google Reader
#! python2
#
# Gaute Hope <eg@gaute.vetsj.com> 2011
#
# Note: This script was only made to serve its purpose one time, and is not
# necessarily very user friendly. But have been used with success migrating
# Google Reader data to a Google Apps account.
#
# Stars and likes items in Google Reader, used to migrate starred
# and liked items from old account to new. Subscriptions already
@teserak
teserak / simplify.py
Created February 4, 2012 11:14
simplify-py
# python version of http://mourner.github.com/simplify-js/
class Point(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __repr__(self):
return "<Point x=%s y=%s>" % (self.x, self.y)
def sqDist(p1, p2):
@mateuszpohl
mateuszpohl / SimpleFilteringListView.py
Created January 26, 2012 21:38
Django generic list view with simple filtering
from django.views.generic import ListView
class SimpleFilteringListView(ListView):
"""
List view with extra filtering and grouping in context data.
``filters`` dict is created as follows: {'context_variable_name', 'filtering_object_method_name'}
It calls filtering method on each object in object_list and if it returns True - this object is added
to proper context variable.
@wraithan
wraithan / base.html
Created January 23, 2012 00:17
Generic Template with Extra Context
<!doctype html>
<html>
<head>
<title>{{page_name}}</title>
</head>
<body>
<h1>{{page_name}}</h1>
{% block content %}
{% endblock content %}
</body>
@lardissone
lardissone / settings.py
Created January 11, 2012 16:05
Subdomain middleware
# ...
SUBDOMAINS = {
'manager': {
'urlconf': 'urls',
'domain': 'manager.domain.com'
},
'clients': {
'urlconf': 'clients.urls',
'domain': 'clients.domain.com'
@teserak
teserak / yubico_demo.py
Created December 23, 2011 20:35 — forked from dolph/yubico_demo.py
Yubikey Registration & Authentication Demo
# pip install yubico
from yubico import yubico
# Yubico API credentials
YUBICO_CLIENT_ID = '6634'
YUBICO_SECRET_KEY = 'HdRb8AA24+Ud8VL2E+sEEZUiySg='
# Initialize our Yubico API access
YUBICO = yubico.Yubico(YUBICO_CLIENT_ID, YUBICO_SECRET_KEY)
@davesteele
davesteele / gmimap.py
Last active July 17, 2020 04:33
Class and example for using the Gmail IMAP Extensions
#!/usr/bin/python -tt
#
# Note that this uses xlist, which is deprecated.
#
# This also predates the GMail REST API, which is probably a better mechanism
# https://developers.google.com/gmail/api/
#
#
""" Example of how to use Google IMAP Extensions using Python
@niran
niran / generic.py
Created October 14, 2011 22:47
A couple of utility class-based views we use at The Texas Tribune.
from django.http import HttpResponse
from django.shortcuts import redirect
from django.views.generic.detail import BaseDetailView, \
SingleObjectTemplateResponseMixin
from tt.url.unicode import urlencode
class CanonicalUrlBaseDetailView(BaseDetailView):
@leah
leah / json-response.py
Created October 5, 2011 19:08
JSONResponse classes
import re
import simplejson
from django.http import HttpResponse
from django.conf import settings
class JSONResponse(HttpResponse):
def __init__(self, request, data):
indent = 2 if settings.DEBUG else None
@armonge
armonge / fields.py
Created July 18, 2011 14:41
A Django custom modelfield, formfield and formwidget to select and save a set of geographic coordinates using Google Maps
class GoogleMapMarker(object):
def __init__(self, latitude, longitude):
self.latitude = latitude
self.longitude = longitude
def __unicode__(self):
return '%f,%f'%(self.latitude, self.longitude)
def __len__(self):
return len(self.__unicode__())