Skip to content

Instantly share code, notes, and snippets.

@studds
studds / aws-step-function.json
Last active December 20, 2022 09:05
JSON Schema for AWS Step Functions (derived from https://github.com/airware/asl-validator)
{
"$schema": "http://json-schema.org/draft-07/schema",
"definitions": {
"state-machine": {
"type": "object",
"properties": {
"Comment": {
"type": "string"
},
"StartAt": {
// NB: I'd normally deploy this using CloudFormation
/*
The lambda needs the following configuration:
- A bunch of memory probably 2GB
- Better to have a long timeout just in case
- Must include the following later:
- nodejs10.x (or a newer layer - but haven't tested)
- BUCKET_NAME environment variable
- Permissions to access BUCKET_NAME
@studds
studds / screenshot.js
Created February 1, 2020 06:21
A sketch of a lambda to take a screenshot and save it to S3
// NB: I'd normally deploy this using CloudFormation
/*
The lambda needs the following configuration:
- A bunch of memory probably 2GB
- Better to have a long timeout just in case
- Must include the following later:
- nodejs10.x (or a newer layer - but haven't tested)
- BUCKET_NAME environment variable
@studds
studds / subscribe-to.decorator.ts
Created December 15, 2016 06:46
SubscribeTo decorator: a async resolution for angular 2 components
/**
* Created by daniel on 12/12/16.
*/
import { OnDestroy, OnInit } from '@angular/core';
import { Subscription } from 'rxjs';
export interface ISubscribeTo {
// array of functions which create the subscriptions
subscribers: Function[];
@studds
studds / fix-query-command-value-ms-edge.shim.ts
Created December 15, 2016 00:49
Fixes / standardises behaviour for execCommand & queryCommandValue for msedge
/**
* Created by daniel on 22/11/16.
*/
import bowser = require('bowser');
export function fixQueryCommandValueForMSEdge(): void {
if (!bowser.msedge && !bowser.msie) {
return;
@studds
studds / content-editable-value-accessor.ts
Created December 1, 2016 03:08
An angular 2 value accessor for content editable fields (for use with ngModel)
import { forwardRef, Directive, ElementRef, HostListener, Renderer, SecurityContext } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { DomSanitizer } from '@angular/platform-browser';
type OnChangeFn = (innerHTML: string) => void;
type OnTouchFn = () => void;
const ENTER_KEY_CODE = 13;
@Directive({