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
""" Automatically load settings arguments from environment settings and set as locals variables | |
* os.environ.get('DJANGO_CONF', 'default') | |
Author : Hao Chen ([email protected]) """ | |
DJANGO_CONF = os.environ.get('DJANGO_CONF', 'default') | |
if DJANGO_CONF != 'default': | |
module = __import__(DJANGO_CONF, globals(), locals(), ['*']) | |
for k in dir(module): | |
locals()[k] = getattr(module, k) |
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
""" WSGI configure file for django application | |
Default configure file path: /etc/httpd/conf.d/wsgi.conf """ | |
import os | |
import sys | |
## setup path for mod_wsgi | |
sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
# add more path here |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<title>Bootstrap Plugin Test Suite</title> | |
<!-- jquery --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
<!-- qunit --> | |
<link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" /> |
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 −*− | |
""" ModelField resources | |
Author : Hao Chen ([email protected]) """ | |
from tastypie.resources import Resource | |
from tastypie.constants import ALL, ALL_WITH_RELATIONS | |
from tastypie import fields |
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
from tastypie.serializers import Serializer | |
import json | |
class CustomJSONSerializer(Serializer): | |
""" Custom JSON Serializer | |
Replace the default simplejson.DjangoJSONEncoder in tastypie with json.JSONEncoder | |
USAGE: avoid json encoding error in django 1.5+ | |
Author: [email protected] """ |
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 socket | |
import sys | |
from thread import * | |
HOST = '' # Symbolic name meaning all available interfaces | |
PORT = 8888 # Arbitrary non-privileged port | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print 'Socket created' |
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
/* Name | |
* | |
* Description | |
* | |
* Created by Hao Chen on 11/04/2012. | |
* Version 1.0 (c) 2012 __MyCompanyName__.All rights reserved. | |
* Released under Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0.html. | |
*/ | |
/* style name |
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
''' Django ORM don't support to pull id from sequence by default.''' | |
def update_id(func): | |
'''A decorator for pulling a data object's ID value out of a | |
user-defined sequence. This gets around a limitation in | |
django whereby we cannot supply our own sequence names.''' | |
def decorated_function(*args): | |
# Grab a reference to the data object we want to update. | |
data_object = args[0] |
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
def decorator(function): | |
''' A general decorator implementation | |
author : [email protected] ''' | |
def wraper(*arg,**kargs): | |
''' actual function logic here ''' | |
# more codes here | |
# ... | |
# if calling original function here then the code defined in original function will run |
OlderNewer