Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.
Most workflows make the following compromises:
Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure
flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.
Use production SSL certificates locally. This is annoying
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
#!/usr/bin/env python | |
""" | |
AppStats serializer module which converts App Engine profile data from Protocol Buffers into JSON. | |
Usage: | |
import appstats_serializer | |
# List all AppStats summaries: | |
appstats_dicts = appstats_serializer.appstats_to_dict(summaries_only=True) |
#!/usr/bin/env python | |
""" | |
JSON encoder/decoder adapted for use with Google App Engine NDB. | |
Usage: | |
import ndb_json | |
# Serialize an ndb.Query into an array of JSON objects. | |
query = models.MyModel.query() |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Create automatic versions of your App Engine Datastore Models, allowing you to undo changes! | |
Usage: | |
import gae_ndb_revisions | |
# Add two properties to your Model(s). |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Search-augmented NDB Models for Google App Engine. | |
Usage: | |
import search_models | |
# Define an index for the document type. |
#!/usr/bin/env python | |
""" | |
Setup a virtualenv with the Google App Engine SDK. | |
References: | |
http://virtualenv.readthedocs.org/en/latest/virtualenv.html#creating-your-own-bootstrap-scripts | |
http://mindtrove.info/virtualenv-bootstrapping/ | |
""" | |
import hashlib | |
import os |