Skip to content

Instantly share code, notes, and snippets.

View thomasyip's full-sized avatar

Thomas Y thomasyip

View GitHub Profile
@thomasyip
thomasyip / common [stash] fields.py
Created July 22, 2012 04:19
Updated version of Django BigInt Patch for 64bit Primary Keys
"""
module mydjangolib.bigint_patch
A fix for the rather well-known ticket #399 in the django project.
Create and link to auto-incrementing primary keys of type bigint without
having to reload the model instance after saving it to get the ID set in
the instance.
Logs:
@thomasyip
thomasyip / storages.py
Created July 20, 2012 23:41
class S3BotoStaticStorage (to deploy of django `media` and `static` into two amazon bucket)
from __future__ import absolute_import
import settings
from storages.backends.s3boto import S3BotoStorage
from boto.s3.connection import SubdomainCallingFormat
def getattr_backup(obj, key, backupkey, default):
result = getattr(obj, key, None)
if result is None:
@thomasyip
thomasyip / config.ru
Created October 31, 2011 03:18
Sinatra + Warden & Rails + Devise Example
# /config.ru
# This file is used by Rack-based servers to start the application.
# File generated by "rails create MyApp"
# For Rails
require ::File.expand_path('../config/environment', __FILE__)
# For Sinatra
require './slim/slim.rb'
# - Make sinatra play nice
@thomasyip
thomasyip / config.ru
Created October 26, 2011 05:46
Config.ru for Rails meets Sinatra
# /config.ru
# This file is used by Rack-based servers to start the application.
# For Rails
require ::File.expand_path('../config/environment', __FILE__)
# For Sinatra
require './slim/slim.rb'
# - Make sinatra play nice
use Rack::MethodOverride
@thomasyip
thomasyip / slim.rb
Created October 26, 2011 05:41
Minimal Sinatra Example
# /slim/slim.rb
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
require 'rubygems'
require 'sinatra'
class AppMain < Sinatra::Application
set :root, APP_ROOT
get '/' do
@thomasyip
thomasyip / apple_theme_boxflex.css
Created November 29, 2010 06:50
Boxflex for iPhone app pane
/**
* Extracted from: https://github.com/beedesk/jQTouch/commit/b5d2fc63fe15acba15c4e8eaafc0e128997f8484
*/
/* ============= from themes/apple/theme.css ============= */
#jqt > * {
-webkit-transform: translate3d(0,0,0);
-webkit-backface-visibility: hidden;
background: rgb(197,204,211) url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAABCAIAAACdaSOZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABdJREFUeNpiPHrmCgMC/GNjYwNSAAEGADdNA3dnzPlQAAAAAElFTkSuQmCC);
-webkit-user-select: ignore;
/**
* Here is the simplified version. Courtesy of Mike Koss.
*
* See, http://labnote.beedesk.com/the-pitfalls-of-html5-applicationcache
*/
function handleAppCache() {
if (applicationCache == undefined) {
return;
}