Skip to content

Instantly share code, notes, and snippets.

View erichiggins's full-sized avatar

Eric Higgins erichiggins

View GitHub Profile
@erichiggins
erichiggins / bootstrap.py
Last active January 2, 2017 00:36
Adding Google App Engine SDK to Python virtualenv
#!/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
@erichiggins
erichiggins / search_models.py
Created April 29, 2014 19:26
GAE Search-augmented NDB Models: Keep a searchable index up-to-date with the latest information in your datastore Models.
#!/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.
@erichiggins
erichiggins / gae_ndb_revisions
Last active August 29, 2015 14:00
GAE NDB Revisions: Create automatic versions of your datastore models, allowing you to undo changes!
#!/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).
@erichiggins
erichiggins / ndb_json.py
Last active May 23, 2021 00:27
JSON serializer/deserializer adapted for use with Google App Engine's NDB Datastore API. This script can handle Model, Expando, PolyModel, Query, QueryIterator, Key, datetime, struct_time, and complex types.
#!/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()
@erichiggins
erichiggins / appstats_serializer.py
Last active December 25, 2015 10:18
Protobuf to Python dictionary serializer for Google App Engine AppStats module.I wanted to be able to send my AppStats profile data off to a logging service (like Loggly) so that I could monitor it over time. This module serializes the data so that it can be converted to JSON and sent off to a log service by a cron job.
#!/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)
@plentz
plentz / nginx.conf
Last active July 17, 2024 09:16
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active July 10, 2024 14:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

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

@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!