Skip to content

Instantly share code, notes, and snippets.

View qgreg's full-sized avatar
🚀
Deploying continuously

Gregory L. Quinlan qgreg

🚀
Deploying continuously
View GitHub Profile
@qgreg
qgreg / sendgrid_python_dynamic_template_data.py
Created August 1, 2018 00:39
Sendgrid introduced dynamic templates, but hasn't released the feature in the Python SDK. Here's a bit of a path in the meantime.
""" Until Sendgrid updates the Python SDK to handle the new dynamic template data, you can use this Gist to
manage dynmaic template data in your python application.
The DynamicTemplateData is used to assign the key and value of the data, then NewPersonalizations is a subclass
of the existing Personalizations to which the DynamicTemplateData can be added.
This Gist takes inspiration from Sendgrid's Python SDK custom_args and CustomArgs.
Hopefully, other finds this useful and Sendgrid updates their Python SDK soon
"""
// This script assumes that there will be several groups of data in each row and create a distinct collection of JSON for
// each group. The group data is contained in the frozen headers, with all but the bottom header cell being the same for
// a given group. The labels for the group header data will be in the first column. The row id data, common to all data
// groups in the row, is found in first several columns, and ends with a blank column. A data group ends with a change in
// the group header data or a blank column.
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
@qgreg
qgreg / gist:1ec6fb9dee3bf9013eabcf9e74f260b6
Last active June 29, 2016 13:26
Using In Operator to Test for a Named Attribute for a List Data Type
def provideRatings(teams=None):
""" Provides ratings object for generating ratings table in a template. If no teams
are provided, provide all teams for now result.
Arg: A teams object.
Returns: ratings object
"""
# Store player
player_id = login_session['player_id']
# If not teams are provided, provide active teams
if not teams: