This file contains hidden or 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 _shard_array(inlist, shard_size): | |
# inlist = 150-element list | |
# shard_size = 40 | |
num_shards = len(inlist) / shard_size | |
# num_shards == 3 | |
shards = [] | |
for i in range(num_shards): | |
# i == 0 | |
start = shard_size * i # start == 0, then 40, then 80... |
This file contains hidden or 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> | |
<meta charset="utf-8"> | |
<title>Archive - {{ site.title }}</title> | |
<meta name="author" content="{{ user.display_name }}"> | |
<meta name="description" content="{{ site.description }}"> | |
<meta name="viewport" content="width=device-width; initial-scale=1; maximum-scale=1"> | |
<link href="/atom.xml" rel="alternate" title="{{ site.url }} feed" type="application/atom+xml"> |
This file contains hidden or 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 sync_templates(client, uid, template_name=None): | |
templates = UserTemplate.query() | |
for t in templates.iter(): | |
if not template_name or t.name == template_name: | |
try: | |
tresp, meta = client.get_file_and_metadata( | |
"/templates/" + t.name) | |
t.content = tresp.content.decode('utf8') | |
t.put() | |
except: # template doesn't exist for new users sometimes |
This file contains hidden or 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 post(self): | |
uid = self.account.dropbox_uid | |
action = self.request.get('action', '') | |
if action != 'save': | |
self.error_out(500, 'Bad request, not action provided.') | |
template_name = self.request.get('template_name') | |
template_content = self.request.get('content') |
This file contains hidden or 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | |
<meta name="generator" content="Echoloquation - http://echoloquation.com" /> | |
<title>{{ site.title }}</title> | |
<style type="text/css"> | |
body { | |
margin-top: 0px; |
This file contains hidden or 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
app = WSGIApplication([ | |
DomainRoute('<subdomain>.' + config.APP_HOST, [ | |
# request for sub.foo.com passes subdomain=sub to IndexHandler | |
Route('/', blog.IndexHandler, name='blog'), | |
# request for sub.foo.com/path passes path=foo to PostHandler | |
# but NOT the subdomain | |
# I expected this route to get subdomain=sub, path=path | |
Route('/<path:.+>', blog.PostHandler, name='post'), | |
]), | |
], config=config.webapp_cfg, debug=True) |
This file contains hidden or 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 testbed | |
from google.appengine.ext import ndb # SDK 1.7, OS X | |
import unittest | |
from webtest import TestApp | |
from main import app | |
from models import compute_hash #, Subscription |
This file contains hidden or 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 nose.tools import ok_, eq_ | |
import unittest | |
from google.appengine.ext import testbed | |
from google.appengine.ext import ndb | |
from webtest import TestApp | |
from admin import app |
This file contains hidden or 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 os | |
from django.utils import simplejson as json | |
import datetime | |
from google.appengine.ext import ndb | |
from google.appengine.ext import testbed | |
from models import Subscription | |
DATE_FMT = "%Y-%m-%d %H:%M:%S" |
This file contains hidden or 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
(Pdb) pp Key | |
<class 'google.appengine.ext.ndb.key.Key'> | |
(Pdb) pp value | |
Key('Subscription', None) | |
(Pdb) type(value) | |
<class 'google.appengine.ext.ndb.key.Key'> | |
(Pdb) |