Skip to content

Instantly share code, notes, and snippets.

@joninsky
joninsky / stack.yaml
Created August 25, 2019 22:50
ENV Condition example Cloudformation
Conditions:
IsProduction: !Equals [!Ref 'ENV', 'PROD']
@joninsky
joninsky / stack.yaml
Last active August 25, 2019 22:59
ENV parameter declaration in Cloudformation
Parameters:
ENV:
Description: 'The environment that this stack represents'
Type: String
Default: 'DEV'
ConstraintDescription: "Must be either 'DEV', 'STAG', or 'PROD'"
AllowedValues:
- 'DEV'
- 'STAG'
- 'PROD'
@joninsky
joninsky / parameters.json
Created August 25, 2019 22:46
Cloudformation ENV parameter example
[
{
"ParameterKey": "ENV",
"ParameterValue": "DEV"
}
]
@joninsky
joninsky / commands.sh
Created July 19, 2019 17:39
ECR cloudformation creation
aws cloudformation create-stack --stack-name HasuraContainer --template-body file://./ECR.yaml
#Or, if you don't want the default name of `demo/hasura` for your registry. Fill in the parameters in the ecr_parameters.json file and create the stack like this.
aws cloudformation create-stack --stack-name HasuraContainer --template-body file://./ECR.yaml --parameters file://./ecr_parameters.json
@joninsky
joninsky / MutationResponseExample.json
Created May 16, 2019 21:59
MutationResponseExample
{
"data": {
"insert_user": {
"returning": [
{
"id": "05d21ca2-931c-4ed4-baf6-581769003905"
}
],
"affected_rows": 1
}
mutation NewUser($email: String!) {
insert_user(objects: [{email: $email}]) {
returning{
id
}
affected_rows
}
}
@joninsky
joninsky / MixedQueryResults.json
Created May 16, 2019 21:44
MixedQueryResults
{
"data": {
"user": [
{
"id": "b2c7a193-6500-4144-9079-cfc336995538",
"email": "[email protected]"
}
],
"user_by_pk": {
"id": "b2c7a193-6500-4144-9079-cfc336995538",
query User($byID: uuid!) {
user(where: {id: {_eq: $byID}}) {
id
email
}
user_by_pk(id: $byID) {
id
email
}
}
@joninsky
joninsky / exampleGraphQLResponse.json
Last active May 16, 2019 21:31
Basic returned example from GraphQL Request.
{
"data": {
}
}
@joninsky
joninsky / EuclideanDistance.swift
Created January 11, 2019 00:50
Euclidean Distance between two arrays of Double values in Swift
func euclideanDistance(first: [Double], second: [Double]) -> Double {
guard first.count == second.count else {
fatalError("Vector space is not the same")
}
var result: Double = 0
for i in 0..<first.count {
result += pow(first[i] - second[i], 2.0)
}
return sqrt(result)
}