Skip to content

Instantly share code, notes, and snippets.

def facebook_authorization(request):
url = "https://graph.facebook.com/oauth/authorize"
params = urllib.urlencode({
'client_id': settings.FACEBOOK_APP_ID,
'redirect_uri': settings.FACEBOOK_REDIRECT_URI,
'scope': 'offline_access,read_stream,publish_stream'
})
return redirect(url + '?' + params)
class StatusDate(db.Model):
user = db.ReferenceProperty(User, collection_name='status_dates')
count = db.IntegerProperty(default=0)
tweets_count = db.IntegerProperty(default=0)
plurks_count = db.IntegerProperty(default=0)
fb_posts_count = db.IntegerProperty(default=0)
date = db.DateProperty(required=True)
@tzangms
tzangms / imagick.php
Created August 14, 2011 10:50
generate thumbnail on fly
<?php
/*
Author: tzangms
Email: tzangms@gmail.com
Apache Rewrite rules
=========================================================================================
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=/imagick.php
@tzangms
tzangms / .vimrc
Created January 18, 2012 02:18
my vimrc, with vundle.
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'python.vim'
Bundle 'pyflakes.vim'
Bundle 'scrooloose/nerdtree'
@tzangms
tzangms / http_servlet_handler.rb
Created February 23, 2012 12:54
DjangoHandler for FireApp
module WEBrick
module HTTPServlet
class DjangoHandler < AbstractServlet
def initialize(server, name)
super(server, name) if( server )
@root_path = Compass.configuration.project_path
@script_filename = name
end
@tzangms
tzangms / gist:3852402
Created October 8, 2012 13:02
1px transparent gif with base64 encoded
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
@tzangms
tzangms / python_install.sh
Created October 30, 2012 18:30
One Command line installer for python web development on ubuntu 12.04 LTS
echo "This script requires superuser access to install apt packages."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
# run inside sudo
sudo sh <<SCRIPT
apt-get update -y
apt-get upgrade -y
@tzangms
tzangms / PutIOUpload.py
Created November 21, 2012 02:59
put.io upload
import sys
import requests
import urllib
PUTIO_ACCESS_TOKEN = '<token>'
PUTIO_API_URL = 'https://api.put.io/v2/files/upload'
url = sys.argv[1]
@tzangms
tzangms / cfsign.py
Created November 26, 2012 03:30
Private content signing for CloudFront in python
import Crypto.Hash.SHA
import Crypto.PublicKey.RSA
import Crypto.Signature.PKCS1_v1_5
import base64
import time
KEY_PAIR_ID = "your_key_pair_id"
PRIV_KEY_FILE = "pk-xxxxxxxxxx.pem"
import requests
import urllib
import json
import logging
logger = logging.getLogger(__name__)
class FacebookLike(object):
def __init__(self, access_token, user_id):