This file contains 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
# code: utf-8 | |
import json | |
import datetime | |
import pymysql | |
class JSONEncoder(json.JSONEncoder): | |
def default(self, o): | |
if isinstance(o, datetime.datetime): |
This file contains 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/env python | |
import os | |
import sys | |
import hmac | |
import json | |
import time | |
import hashlib | |
import datetime | |
import requests |
This file contains 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 pydouban | |
@route('/login') | |
class Login(WebHandler): | |
def get(self): | |
auth = pydouban.Auth(key, secret) # your consumer key and secret | |
dic = auth.login('http://localhost/auth') | |
memcache.set('douban', dic) | |
return self.redirect(dic['url']) |
This file contains 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 pydouban | |
@route('/me') | |
class Profile(WebHandler): | |
def get(self): | |
qs = db.Douban.get('qs') | |
api = pydouban.Api() | |
api.set_qs_consumer(key, secret, qs) | |
profile = api.get_profile() | |
return self.response(profile) |
This file contains 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/env python | |
# | |
# Copyright 2010 by Marvour | |
# | |
# Under the BSD License | |
""" | |
A simple handler with cookie and session supporting. | |
Here is a simple example: |
This file contains 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
@register.filter | |
def embed(value): | |
#gist | |
value = re.sub(r'(https?://gist.github.com/[\d]+)',r'<small><a rel="nofollow" href="\1">\1</a></small><script src="\1.js"></script>', value) | |
#youtube | |
value = re.sub(r'http://www.youtube.com/watch\?v=([a-zA-Z0-9\-\_]+)', r'<small><a rel="nofollow" href="http://www.youtube.com/watch?v=\1">Youtube Source</a></small><br /><embed src="http://www.youtube.com/v/\1?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385" />', value) | |
#youku | |
value = re.sub(r'http://v.youku.com/v_show/id_([a-zA-Z0-9\=]+).html', r'<small><a rel="nofollow" href="http://v.youku.com/v_show/id_\1.html">Youku Source</a></small><br /><embed src="http://player.youku.com/player.php/sid/\1/v.swf" quality="high" width="480" height="400" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" />', value) | |
#tudou | |
value = re.sub(r'http://www.tudou.com/programs/view/([a-zA-z0-9\-\=]+)/',r'<small |
This file contains 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/env python | |
# -*- coding: utf-8 -*- | |
import datetime | |
from django.utils import simplejson | |
#import simplejson | |
class DateTimeJSONEncoder(simplejson.JSONEncoder): | |
""" |
This file contains 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
" System | |
set nocompatible | |
set backspace=indent,eol,start | |
set nobackup | |
set history=50 | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
set fileencodings=utf-8,cp936 | |
set ff=unix |
This file contains 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
# -*- coding: utf-8 -*- | |
import datetime | |
from django.http import HttpResponse | |
from django.utils import simplejson | |
from django.shortcuts import render_to_response | |
from django.template import RequestContext | |
class DateTimeJSONEncoder(simplejson.JSONEncoder): | |
""" |
This file contains 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
[core] | |
editor=vim | |
[merge] | |
tool = vimdiff | |
[alias] | |
st = status | |
ci = commit -a | |
br = branch | |
df = diff | |
co = checkout |