This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>{{page_name}}</title> | |
| </head> | |
| <body> | |
| <h1>{{page_name}}</h1> | |
| {% block content %} | |
| {% endblock content %} | |
| </body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ... | |
| SUBDOMAINS = { | |
| 'manager': { | |
| 'urlconf': 'urls', | |
| 'domain': 'manager.domain.com' | |
| }, | |
| 'clients': { | |
| 'urlconf': 'clients.urls', | |
| 'domain': 'clients.domain.com' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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__()) |