Skip to content

Instantly share code, notes, and snippets.

@mdlavin
mdlavin / secure-data-create-patient.ts
Last active August 1, 2022 12:31
Secure Health Data Storage Article - Create Patient Snippet
const createPatient = async (accountId: string, projectId: string) => {
const patient = await fetch(`https://fhir.us.lifeomic.com/${accountId}/dstu3/Patient`, {
method: 'POST',
headers: {
authorization: `Bearer ${process.env.PHC_API_KEY}`,
'content-type': 'application/json'
},
body: JSON.stringify({
resourceType: "Patient",
@mdlavin
mdlavin / secure-data-create-observation.ts
Last active August 1, 2022 12:34
Secure Health Data Storage Article - Create Observation Snippet
const createObservation = async (accountId: string, projectId: string, patientId: string) => {
const observation = await fetch(`https://fhir.us.lifeomic.com/${accountId}/dstu3/Observation`, {
method: 'POST',
headers: {
authorization: `Bearer ${process.env.PHC_API_KEY}`,
'content-type': 'application/json'
},
body: JSON.stringify({
resourceType: "Observation",
@mdlavin
mdlavin / Machine Setup.md
Last active July 7, 2022 11:45
Machine setup

Enable FileVault disk encryption

Enable Firewall

sudo defaults write /Library/Preferences/com.apple.alf globalstate -int 1

Disable guest account

@mdlavin
mdlavin / template.yml
Created January 23, 2021 20:37
Amplify custom auth domain template.yml
AWSTemplateFormatVersion: 2010-09-09
Parameters:
env:
Type: String
authCognitoResourceUserPoolId:
Type: String
Mappings:
CustomAuthDomains:
@mdlavin
mdlavin / backend-config.json
Last active January 23, 2021 20:38
Amplify custom auth domain backend-config.json
{
"auth": {
"domain": {
"providerPlugin": "awscloudformation",
"dependsOn": [
{
"category": "auth",
"resourceName": "CognitoResource",
"attributes": [
"UserPoolId"
@mdlavin
mdlavin / amplify-custom-auth-domain-app.js
Created January 23, 2021 19:45
Amplify Custom Auth Domain Config Update
import awsconfig from "./aws-exports";
import Amplify from "@aws-amplify/core";
// Find the User Pool ID for your production deployment in
// the AWS Console
if (awsconfig.aws_user_pools_id === "us-east-1_M7n6RNrq9") {
awsconfig.oauth.domain = "auth.yourdomain.com;
}
Amplify.configure(awsconfig);
@mdlavin
mdlavin / amplifyPush.sh
Last active July 6, 2022 08:33 — forked from swaminator/amplifyPush.sh
The amplifyPush script (Pulled on 12/27/2019)
#!/usr/bin/env bash
set -e
IFS='|'
help_output () {
echo "usage: amplify-push <--environment|-e <name>> <--simple|-s>"
echo " --environment The name of the Amplify environment to use"
echo " --simple Optional simple flag auto-includes stack info from env cache"
exit 1
}
@mdlavin
mdlavin / graphql-apollo-xray-error-formatter.js
Last active January 19, 2022 18:50
An Apollo Server formatError function that avoids "Converting circular structure to JSON" errors
// This is the attribute that continuation local storage uses to hold onto
// the current context. The value comes from https://github.com/othiym23/node-continuation-local-storage/blob/fc770288979f6050e4371c1e1b44d2b76b233664/context.js#L11
const CLS_CONTEXT_ATTRIBUTE = 'error@context';
// A formatError function that can be used with
// https://www.apollographql.com/docs/apollo-server/features/errors#for-the-client-response
function formatError (err) {
// The continuation-local-storage module attaches a context attribute to
// errors so that the context can be resolved from errors. The attribute
// is enumerable by default and so it gets included in GraphQL error
@mdlavin
mdlavin / null-payload-article-promise-wrapper.js
Created July 5, 2018 19:10
A helper to make sure that a Promise will always resolve
function safePromise (promise, timeout) {
let slowOpId;
const slowLoggingPromise = pFinally(promise, function () {
if (slowOpId) {
log.warn({slowOpId, itemKey}, 'The Promise eventually resolved');
}
});
// Don't wait on longer than `timeout` ms for the Promise
@mdlavin
mdlavin / null-payload-article-promise-that-does-not-resolve.js
Created July 5, 2018 18:41
An example application that terminates without error earlier than expected
function someAsyncFunction () {
return new Promise(function () {
// This is a bad promise that never resolves
});
}
someAsyncFunction()
.then(function () {
console.log('Done');
})