Skip to content

Instantly share code, notes, and snippets.

# Adapted from http://appengine-cookbook.appspot.com/recipe/lazy-loading-webapp-handler/
def _istring(import_name):
"""Imports an object based on a string.
@param import_name the dotted name for the object to import.
@return imported object
"""
module, obj = import_name.rsplit('.', 1)
# __import__ can't handle unicode strings in fromlist if module is a package
if isinstance(obj, unicode):
"""Implements a request handler which caches the response to GET requests.
Big Picture:
* memcache is used to cache generated content.
* Task queue is used to regenerate the content when it expires.
* When a page expires, the old page is continued to be served until the new
page is ready (to minimize downtime).
* A new page will be generated only if the old page has expired AND someone is
requesting the page.
import urllib2, urllib
class RecaptchaResponse(object):
def __init__(self, is_valid, error_code=None):
self.is_valid = is_valid
self.error_code = error_code
def submit (recaptcha_challenge_field,
recaptcha_response_field,
private_key,
application: zip-site
version: main
runtime: python
api_version: 1
handlers:
- url: /.*
script: main.py
# Copyright (C) 2010 David Underhill [email protected]
# This module is released under the MIT license:
# http://www.opensource.org/licenses/mit-license.php
"""
This module provides a wrapper around the urlfetch API which maximizes the
concurrency of asynchronous urlfetch requests (within app engine limits).
To start asynchronous fetch(es), first create an AsyncURLFetchManager and then
call call fetch_asynchronously() as many times as needed. For optimal
performance, start the fetches which are fastest first.
@tomcritchlow
tomcritchlow / 7books.py
Created November 9, 2010 23:23
The main code for 7books (www.7bks.com)
import cgi
import os
from google.appengine.ext.webapp import template
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.api import urlfetch
@roncioso
roncioso / 20thingsilearned.js
Created November 18, 2010 22:16
20thingsilearned.com - Nice to study. Original here http://www.20thingsilearned.com/js/twentythings.min.js
/*
Nice to study. Original here http://www.20thingsilearned.com/js/twentythings.min.js
*/
var TT = TT || {};
TT.PAGE_WIDTH = 800;
TT.PAGE_HEIGHT = 500;
TT.PAGE_MIN_WIDTH = 1000;
TT.PAGE_MIN_HEIGHT = 680;
TT.PAGE_MARGIN_LEFT = 32;
@medecau
medecau / opcp.md
Last active March 7, 2024 18:11
Online Programming Contests and Puzzles
Copyright (c) 2012, Miguel Araujo
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: