Skip to content

Instantly share code, notes, and snippets.

View wulfmann's full-sized avatar
:shipit:

Joe Snell wulfmann

:shipit:
  • Nashville, TN
View GitHub Profile
@wulfmann
wulfmann / cleanup.js
Last active November 18, 2020 22:18
Gist Web Component
cleanup(id) {
try {
delete window[id];
} catch (e) {
window[id] = undefined;
}
const script = document.getElementById(id);
if (script) {
keyResource.addMethod('GET', integration, {
methodResponses: [{ statusCode: '200' }]
});
@wulfmann
wulfmann / app.ts
Last active January 23, 2022 11:33
How to get an S3 object from an AppSync Resolver using Apache Velocity Templates
import * as cdk from '@aws-cdk/aws-cdk';
import * as appsync from '@aws-cdk/aws-appsync';
import * as s3 from '@aws-cdk/aws-s3';
// Our new S3 Data Source Construct
import { S3DataSource } from './s3-data-source.ts';
/**
* This file contains a sample CDK Stack that creates:
* - A new appsync graphql api
@wulfmann
wulfmann / update_item.py
Created October 22, 2020 17:25
Dynamically construct a boto3 dynamo update_item call
def update_item(table, item, options):
update_expression = []
expression_attribute_names = {}
expression_attribute_values = {}
for key in item:
attribute_name = f'#{key}'
attribute_value = f':{key}'
update_expression.append(f'set {attribute_name}={attribute_value}')
expression_attribute_names[attribute_name] = key
@wulfmann
wulfmann / import-all.ts
Last active July 3, 2020 19:23
Dynamically import all directory paths from a given directory
import { promises as fs } from 'fs';
import { join } from 'path';
export const importAll = async (dir='.') => {
for await (const path of await fs.opendir(dir)) {
if (path.isDirectory()) {
await import(join(dir, path.name));
}
}
};
import * as iam from ‘@aws-cdk/aws-iam’
const key = new iam.CfnAccessKey(this, ‘AccessKey’, {
serial: 1,
userName: ‘test-user’
status: ‘Active’
});
@patch("json.dump")
@patch("builtins.open", new_callable=mock_open())
def test_cache_content_items(self, m_open, m_json):
cache_file_path = "EXAMPLE_FILE_PATH"
uncached_content_items = ["content_item_1", "content_item_2"]
cached_content = cache_content_items(uncached_content_items, cache_file_path)
m_open.assert_called_with(cache_file_path, "w")
m_json.assert_called_with(
#!/bin/sh
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
# Skip on master, test, and qa
if [ -z "$BRANCHES_TO_SKIP" ]; then
BRANCHES_TO_SKIP=(master test qa)
fi
@wulfmann
wulfmann / Post.js
Last active February 19, 2019 14:32
General Prerender file that returns a promise and dumps arbitrary props to the route
import { h } from 'preact'
export default ({ id }, { whatever }) => <div>{id}: {whatever}</div>