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…
-
Simple Swift Fuzzer
Sometimes we want to test a function to see how… robust it is. This is a small example fuzzing function to input randomly generated characters that get passed to another function. It just uses randomBytes so much more logic could easily be added to constrain what’s being passed to whatever type it’s being passed to… but this satisfies my need. import Foundation func fuzz(function: () -> Void) { // Generate a random input to pass to the function we are fuzzing let input = Data(randomBytes: 1024) // Call the fuzzed function with the random input do { try function() } catch { print(error) } // Check the fuzzed function to…
-
File Lists And Version History With The Dropbox API
TLDR: See https://github.com/krypted/DropboxScripts for some python scripts for the Dropbox API I recently needed to get a list of changes to all files on Dropbox. To get there, I first found the list_folder endpoint, so here’s a script to dump a list of files https://github.com/krypted/DropboxScripts/blob/main/ListDropboxFiles.py However, then I realized I needed to look up the version history for files, so here’s a script to dump version history: https://github.com/krypted/DropboxScripts/blob/main/ListHistory.py Then to tie the two together, this script lists version changes for each dumped file recursively: https://github.com/krypted/DropboxScripts/blob/main/ListChangesPerFile.py Then I realized that the user was listed with a GUID rather than the actual user. I just need a paper trail and have few…
-
Google Cloud Function To Encrypt A JSON Document With An ECC Key
To use this function, create a Google Cloud Function that uses the encrypt_json() function in Google Cloud Console or the gcloud command-line tool. Once created the function, invoke it by sending a POST request to the function’s URL. The request body should contain the JSON document to encrypt. The response body will contain the encrypted JSON document. For example, to encrypt the JSON document my_data.json, you would use the following command: The response body will contain the encrypted JSON document. This function uses the Google Cloud KMS service to encrypt the JSON document. So make sure there’s a KMS key enabled in a project before using the function.
-
Small Go Script To Send Some JSON To An Endpoint
The following was written to act as a Google Cloud Function or Lambda, and sends a simple POST to a standard rest endpoint at https://krypted.com/api/v1/sites with the json defined in jsonObject. The endpoint can easily be changed in http.NewRequest or converted to a variable. The response to the POST is then returned as stdout. package main import ( "fmt" "net/http" "encoding/json" ) func main() { // Create a new HTTP client. client := &http.Client{} // Create a new JSON object. jsonObject := map[string]string{ "name": "Krypted", "site": "www.krypted.com", } // Marshal the JSON object to a string. jsonString, err := json.Marshal(jsonObject) if err != nil { fmt.Println(err) return } // Create…
-
Tiny hex and binary converters in swift, go, python, && javascript
Have a few scripts that I’ve been bringing into projects for awhile (and altering for each so ymmv on the state, but you’ll get the general idea). https://github.com/krypted/tinyconverters As the names and file extensions imply, these simply take ascii as an input and output as binary or hex, or take the binary or hex and output as ascii.
-
Creating Unit Tests With Google Bard
Unit tests are one of those things that evolve over time. When we talk about test coverage, anyone that thinks they have full coverage is kidding themselves, but it’s not uncommon for my workflows to just build some stuff and go back and fill in the unit tests before I bring in a second person. And yet… we know we need to do them. Sometimes I’ve gotten help with this specific part of projects from sites like Upwork. There’s been a lot of talk about AI eating the world, so I thought I’d see how much of this kind of thing AI could get us for free. Let’s start with…