-
-
Lambda Function To Calculate A Checksum
Here’s a Lambda function to calculate a checksum. The JSON document will be passed in the body field and the script loads the JSON document using json.loads(). The MD5 checksum of the JSON document is calculated by encoding the JSON string as bytes, hashing it using hashlib.md5(), and returning the hexadecimal representation of the hash using hexdigest(). The response returns a 200 status code when successful, with the MD5 checksum as a string in the response body. If the JSON document is invalid and cannot be loaded, a 400 status code is returned with an error message in the response body. In the event of a 400, use the https://github.com/krypted/tinyconverters/blob/main/LintJSON.py…
-
Google Cloud Function To Validate Email Addresses
The following is a simple Google Cloud Function that will validate that text entered into a field (passed to the function in the request body when called) is a valid format of an email address. The email address might not be real, but at least we aren’t accepting a string that’s incorrectly formatted: This function will validate the email address that is passed in the request body. If the email address is valid, the function will return a success response (200). If the email address is not valid, the function will return an error response (400).
-
Google Cloud Function To Add JSON To A Cloud SQL Database
Here’s a Google Cloud Function that takes some arbitrary json (in json_data) and posts it to a new record in a Cloud SQL database. No error handling or deduplication/matching, just a straight post: https://github.com/krypted/tinyconverters/blob/548892cc377e1063770ab4a8cd53dc6573bae950/json_to_cloud_SQL.py Before using, it needs information to connect to the database, so customize the INSTANCE_NAME, DATABASE_NAME, and TABLE_NAME for the INSERT. For more on Cloud SQL, see https://cloud.google.com/sql/docs.
-
Google Cloud Function To Create A Google Doc
Here’s a Google Cloud Function that creates a Google Doc based on a title and body from a json document: https://github.com/krypted/tinyconverters/blob/main/json_to_new_google_doc.py To use it, you’ll need to enable the Google Docs API from the Google Cloud Project and create a service account to get a JSON key file that’s saved in the same folder the cloud function is uploaded to. Once the Cloud Function is deployed, grab the URL and use it as follows:
-
Google Cloud Function To Add JSON To A Google Sheet
Here’s a Google Cloud Function that uses the Google Sheets API to add arbitrary json to a Google Sheet: https://github.com/krypted/tinyconverters/blob/main/json_to_GoogleSheet.py To use the function, create a Google Cloud project and enable the Google Sheets API. Then create a service account and download the JSON key file for that account and place it in the same directory as the script. Once the Cloud Function is deployed, a request similar to the following will add the nested JSON data to the spreadsheet with the ID for that sheet swapped in with spreadsheetId in the below `curl`: This allows us to pipeline information in a variety of ways, like a web hook that…
-
Pre-Processing Linter Google Cloud Functions for plist, json, && yaml
I recently posted some converters to handle different types of data transmogrification. When handling document structures, we should lint them pre- and post-processing, so here are some Google Cloud Functions to handle that (for the three more common formats that I work with):
-
Google Cloud Function To Check Status Of A Port
Sometimes you just need a little microservice to check that a port is up before you try and send some data to it. This does just that… https://github.com/krypted/NestMonitor/blob/main/socket%20check.py
-
One Simple History Of 3D Printing
-
Google Cloud Function To Convert Property Lists To JSON Documents
I’ve written a lot of little scripts to convert files or types from one format to another, over the years. It’s easier to import something that can do the work for you and just use a Lambda or a Google Cloud Function that you call from other tools. This is the microservice way. So here’s a little python Google Cloud Function that converts a property list to a JSON document: To use the function, first create a Google Cloud Function that uses the property_list_to_json() function from the Google Cloud Console or the gcloud CLI. Once you have the URL, simply call it with a POST to the function’s URL. The…