Performs the application of given key/value pairs to a source template, with generated results written to an output file.
Functions applyTemplate
accepts three arguments:
- Source template file.
- Target output file generated.
- List of key/value pairs as an array.
With the given source template:
The byte order mark (BOM) is a Unicode character(U+FEFF
) at the start of a text stream/file to signify the endianness and encoding used to a high level of confidence.
# utf-8
$ hexdump -C utf-8-bom.txt
00000000 ef bb bf 54 65 73 74 20 73 74 72 69 6e 67 20 e2 |...Test string .|
00000010 98 ba 0a |...|
Function which determines if a given file is binary.
Test is based on the following algorithm (similar to that implemented within Perl):
- Empty files are considered text.
- If not empty, read up to 512 bytes as a buffer. File will be binary if:
- Null byte is encountered.
- More than 30% of the buffer consists of "non text" characters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version Latest | |
$HOSTED_ZONE_ID = "ABCDEFGHIJKLM" | |
$changeRequest01 = New-Object -TypeName Amazon.Route53.Model.Change | |
$changeRequest01.Action = "UPSERT" | |
$changeRequest01.ResourceRecordSet = New-Object -TypeName Amazon.Route53.Model.ResourceRecordSet | |
$changeRequest01.ResourceRecordSet.Name = "record01.domain.com" |
Random query recipes of JMESPath for the AWS CLI tools that I might have written or stumbled upon.
- Random list of ascending numbers generated in
resultIndexList
as seed list. - Set of random numbers generated, insert position determined by
insertAt()
function. - Each value inserted using
resultIndexList.splice()
to maintain sort order as progressing.
A pattern for recursion with Promises - in this example, walking a directory structure.
readDirRecursive()
is called with a starting directory and will itself return aPromise
.- Internally
readDir()
is called and passed starting directory to read from. - A list of directory items is returned by
getItemList()
as aPromise
, which in turn is chained togetItemListStat()
to stat each item to determine if file or directory. - Finalised list then passed to
processItemList()
: