Skip to content

Instantly share code, notes, and snippets.

{{define "body"}}
This is the start page.
<br><br>
Check out <a href="/user/5">user 5</a> or <a href="/user/7">user 7</a>.
{{end}}
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
# http://stackoverflow.com/questions/748324/python-convert-those-tinyurl-bit-ly-tinyurl-ow-ly-to-full-urls
#############
# urllib2
import urllib2
fp = urllib2.urlopen('http://bit.ly/rgCbf')
fp.geturl()
# ==> 'http://webdesignledger.com/freebies/the-best-social-media-icons-all-in-one-place'
# based on http://amix.dk/blog/post/19574
from datetime import datetime, timedelta
GRAVITY = 0.5 # HN default: 1.8
WINDOW = 36 # max age in hours
now = datetime.now()
def hours_from_dt(dt):
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
@rogeriomarques
rogeriomarques / LazyControllerLoader.py
Created November 4, 2010 17:42 — forked from dound/LazyControllerLoader.py
LazyControllerLoader.py
# 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):
tell application "Safari"
set _source to do JavaScript "window.document.documentElement.outerHTML" in document 1
set _name to name of document 1
end tell
tell application "BBEdit"
make new text window with properties ¬
{contents:_source, source language:"HTML", name:"Generated source: " & _name}
select insertion point before character 1 of text window 1