Below is a Lambda function to return the number of fields in a JSON document. This Lambda function expects the JSON document in a body field of the event. It loads the JSON document using the standard json.loads() and counts the number of fields by retrieving the keys of the loaded JSON object and calculating the length. The expected response would be a 200 status code if successful, with the number of fields as a string in the response body (which can easily be changed to an int, but made sense to leave as str so if it got some wacky data I’d see that). If the JSON document is…
-
-
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):
-
Simple XPath options with Jamf Pro
Given the increased reliance on XML in scripts and exchanging data, a number of different solutions leverage XML traversal options to get all the things done. We frequently use path to bring a file into a script or program, or accept input from STDIN. The most basic task that we then perform is simply selecting an item from that file or STDIN and then variabalizing it. One common tool that we use here is Path. XPath calls these objects nodes, and uses path expressions to select these nodes. A path expression is the path along the xml input that is followed to find a piece of data. There are some…
-
Configuring Spam Assassin In Mac OS X Lion Server
The built-in message hygiene in Lion Server is provided by Spam Assassin and clamav (amavis). Lion Server’s Server Admin application has an easy-to-use way of configuring some of the more basic settings for Spam Assassin. Spam Assassin’s rules are configured in /etc/mail/spamassassin/local.cf. If you open this into a standard text editor then you can insert blocks that are rules. Each rule has the ability to either locate text within a header (such as an email address), a subject or in the text of an email. To use Spam Assassin to block messages that have the word viagra in them, for example, you would insert the following block: body NO_MORE_VIAGRA /viagra/i…