Skip to content

Instantly share code, notes, and snippets.

@stoyan-scava
stoyan-scava / gist:cdae262ea89f6c9c07444e67e2d03f33
Created March 15, 2023 10:30
Azure Text to Speech response example
SpeechSynthesisResult {
privResultId: '2C0AD04069BF42C0BB57C946D66665BA',
privReason: 10,
privErrorDetails: undefined,
privProperties: undefined,
privAudioData: ArrayBuffer {
[Uint8Contents]: <52 49 46 46 f8 25 05 00 57 41 56 45 66 6d 74 20 10 00 00 00 01 00 01 00 44 ac 00 00 88 58 01 00 02 00 10 00 64 61 74 61 d4 25 05 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 337308 more bytes>,
byteLength: 337408
},
privAudioDuration: 38250000
@stoyan-scava
stoyan-scava / gist:d88c47fdb6ee757092f1f315df5aaa61
Last active October 5, 2022 07:37
The common tongue of cloud typescript - an opinionated style guide
Casing:
Long: easier to read throug in lists
MACRO_CASE: constants, enums
kebap-case: file names, paths
Short: less characters allow us to fit more meaning; e.g. when we extend or scope an entity (both good practices) the name tends to grow
camelCase: variables, function/method names, function/method attributes, GraphQL actions, API I/O, object properties
PascalCase for classes and interfaces, cloud infrastructure resource names
@stoyan-scava
stoyan-scava / gist:d18c6b5c827e0d43942de8ca57b37993
Created March 28, 2021 18:34
Validator for file extensions
/**
* Validator of file extensions
*/
export class ExtensionValidator {
private readonly detector = new ExtensionDetector();
constructor() {
}
/**
@stoyan-scava
stoyan-scava / ExtensionDetector,ts
Created March 28, 2021 18:29
Detector for file extensions
/**
* Detect file extension from filename
* @param filename
* @param extension including the dot
*/
export class ExtensionDetector {
constructor() {
}
/**
@stoyan-scava
stoyan-scava / StackManager.ts
Created February 16, 2021 15:56
Stack Manager - Wrapper of AWS CloudFormation calls. To be used in CI scripts for resource look-up.
import {CloudFormation} from "aws-sdk";
import {
ListStackResourcesOutput,
ListStacksOutput,
Stack,
StackResourceSummary,
StackStatus,
StackSummary
} from "aws-sdk/clients/cloudformation";
@stoyan-scava
stoyan-scava / cloudFrontTrustedKeyEncodedKeyGeneration.sh
Last active February 16, 2021 08:47
Generate RSA encoded key for AWS CloudFront trusted key
// source: https://stackoverflow.com/a/58967523/14569745
openssl genrsa -out key.pem && \
openssl rsa -pubout -in key.pem -out pubkey.pem
// Use the content of pubkey.pem as value of PublicKey.PublicKeyConfig.EncodedKey on CloudFront:CreatePublicKey