Skip to content

Instantly share code, notes, and snippets.

View erichiggins's full-sized avatar

Eric Higgins erichiggins

View GitHub Profile
@erichiggins
erichiggins / datastore_fetch_all.py
Last active November 25, 2020 17:31
Efficiently page over a Query to fetch all entities from the Google App Engine Datastore.
#!/usr/bin/python
"""
Functions are provided for both the DB and NDB Datastore APIs.
References:
* https://cloud.google.com/appengine/docs/python/datastore/queries
* https://cloud.google.com/appengine/docs/python/ndb/queries
"""
def db_fetch_all(query, limit=100, cursor=None):
@erichiggins
erichiggins / zipimportify.py
Last active December 10, 2016 10:02
Converts a directory of Python packages installed by pip into importable zip files for use on Google App Engine.
#!/usr/bin/env python
"""
Convert a directory of pip-installed libraries into zip-imports for use on GAE.
Usage:
pip install -U <library_name>
pip freeze > requirements_dev.txt
pip install -U --egg --target <path_to_zips> -r requirements_dev.txt
python zipimportify.py <path_to_zips>

Keybase proof

I hereby claim:

  • I am erichiggins on github.
  • I am erichiggins (https://keybase.io/erichiggins) on keybase.
  • I have a public key ASDQ1plERE4G6ef8c_KV640t0DUHHeD6FJFO1DbYX9X8xwo

To claim this, I am signing this object:

@erichiggins
erichiggins / basic_scale_class.py
Created June 28, 2022 07:49
Boilerplate scale class for the Open Trickler. Fill out the sections labeled with TODOs.
class BasicScale:
"""Class for controlling a basic scale scale."""
# TODO(you): Update the default values, such as baudrate, to match your scale.
def __init__(self, memcache, port='/dev/ttyUSB0', baudrate=19200, timeout=0.1, _version=1, **kwargs):
"""Controller."""
self._memcache = memcache
self._serial = serial.Serial(port=port, baudrate=baudrate, timeout=timeout, **kwargs)
# Set default values, which should be overwritten quickly.
self.raw = b''