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
class HookedModel(db.Model): | |
def before_put(self): | |
logging.error("before put") | |
def after_put(self): | |
logging.error("after put") | |
def before_delete(self): |
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
// Create a model (with any proxy) | |
Ext.regModel('Car', { | |
fields: ['id', 'name', 'sports'], | |
proxy: { | |
type: 'localstorage', | |
id : 'cars' | |
} | |
}); | |
// Create a store to access the records |
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
SIMPLE_TYPES = (int, long, float, bool, dict, basestring, list) | |
class BaseModel(db.Model): | |
def to_json_friendly_value(self, v): | |
if v is None or isinstance(v, SIMPLE_TYPES): | |
value = v | |
elif isinstance(v, datetime.date): | |
# Convert date/datetime to ms-since-epoch ("new Date()"). | |
ms = time.mktime(v.utctimetuple()) * 1000 |
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 google.appengine.ext import db | |
def each(query, batch_size=100): | |
"""yields each entity in the query over the whole dataset in batches""" | |
entities = query.fetch(batch_size) | |
while entities: | |
for entity in entities: | |
yield entity | |
# if the query was keys only then the entity IS a key | |
if hasattr(entities[-1],"key"): |
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 main(): | |
from lib.xmpplogging import XmppLogHandler | |
XmppLogHandler.add('[email protected]') | |
run_wsgi_app(application) |
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 google.appengine.api import xmpp | |
import logging | |
import logging.handlers | |
import os | |
DEFAULT_FROM_JID = 'logs@%s.appspotchat.com' % os.environ['APPLICATION_ID'] | |
class XmppLogHandler(logging.Handler): | |
def __init__(self, jid, from_jid): |
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 nearly_eq(value,target_value,off_by): | |
""" | |
an equality function with a margin for error (off_by) | |
""" | |
return target_value-off_by < value < target_value+off_by | |
def make_transparent(blob, threshold=210, tolerance=30): | |
r = png.Reader(bytes=blob) | |
(width,height,pixels,meta) = r.asRGBA8() | |
w = png.Writer( |
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
ffmpeg -y -i $input_file$ -pass 1 -passlogfile $private_tmp_path$/$record_id$_2pass -s $width$x$height$ -vcodec libx264 -b 192k -bt 192k -flags +loop -cmp +chroma -partitions 0 -me_method epzs -subq 1 -trellis 0 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 30 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 4:3 -acodec libfaac -ar 22050 -an $private_tmp_path$/$record_id$_pass1.mp4 | |
ffmpeg -y -i $input_file$ -pass 2 -passlogfile $private_tmp_path$/$record_id$_2pass -s $width$x$height$ -vcodec libx264 -b 192k -bt 192k -flags +loop -cmp +chroma -partitions +parti4x4+partp4x4+partp8x8+partb8x8 -me_method umh -subq 7 -trellis 2 -refs 1 -coder 0 -me_range 16 -g 300 -keyint_min 30 -sc_threshold 40 -i_qfactor 0.71 -maxrate 10M -bufsize 10M -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 4:3 -acodec libfaac -ar 22050 -an $private_tmp_path$/$record_id$_noqt.mp4 | |
qt-faststart $private_tmp_p |
NewerOlder