Skip to content

Instantly share code, notes, and snippets.

View mpurdon's full-sized avatar

Matthew Purdon mpurdon

View GitHub Profile
@mpurdon
mpurdon / $HOME:.oh-my-zsh:custom:nvm.zsh
Last active May 25, 2024 20:35
NVM oh-my-zsh script
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
export PATH=$PATH:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
export PATH=$PATH:$(npm get prefix)/bin
find-up() {
path=$(pwd)
while [[ "$path" != "" && ! -e "$path/$1" ]]; do
path=${path%/*}
@mpurdon
mpurdon / obsidian-note.md
Created December 8, 2023 15:19
ChatGPT Instructions - Output for Obsidian

What would you like ChatGPT to know about you to provide better responses?

Obsidian Note Formatting

Folders:

- Capture: Initial thoughts.
- Process: Refining info.
- Organize: Structured notes.
@mpurdon
mpurdon / user-stories.md
Created December 8, 2023 15:15
ChatGPT Instructions - User stories

What would you like ChatGPT to know about you to provide better responses?

Consider that this task is meant for an audience of software engineers so focus on technical details

How would you like ChatGPT to respond?

@mpurdon
mpurdon / general-programming.md
Created December 8, 2023 15:14
ChatGPT Instructions - General programming question

What would you like ChatGPT to know about you to provide better responses?

I would like production-ready solutions with logging and error handling.

I want to follow best practices using the latest features of languages and frameworks. Specify types for everything and do not use "any" anywhere in the solution

I want the code to be clean and functional in nature, with discreet code extracted into functions so that try/catch blocks can focus on specific error scenarios 
@mpurdon
mpurdon / aws-lambda.md
Created December 8, 2023 15:13
ChatGPT Custom Instructions - AWS Lambda Generation

What would you like ChatGPT to know about you to provide better responses?

I am a software architect that works in a serverless environment using AWS.

I want solutions to specifically focus on a lambda function for problem asked, do not try to implement infrastructure or other artifacts as part of the solution

I would like production-ready solutions with logging and error handling as well as metrics and tracing using the `@aws-lambda-powertools` library. Always use the AWS SDK version 3 library. 

I want to follow best practices using the latest features of languages and frameworks. Specify types for everything and do not use the "any" type anywhere in the solution
@mpurdon
mpurdon / index.ts
Created August 16, 2023 17:08
Convert a DynamoDB backup to Excel
import {S3Client, ListObjectsV2Command, GetObjectCommand} from '@aws-sdk/client-s3';
import {Workbook, Worksheet, Border} from 'exceljs';
import {createGunzip} from 'zlib';
import {Readable} from 'stream';
// Configuring the AWS environment
const s3Client = new S3Client({region: 'us-east-1'});
async function listJsonFiles(bucketName: string, prefix: string): Promise<string[]> {
console.log({
@mpurdon
mpurdon / 0001-use-conventional-commits.md
Last active August 10, 2023 16:16
First proposal for an evolution

Use Conventional Commits for Commit Messages

Introduction

@mpurdon
mpurdon / categories.json
Created April 4, 2023 18:08
Example expense categories for statement_parser
{
"Income": {
"display_order": 1,
"": {
"credit TT": "Employer",
"Payroll Deposit": "Employer",
"Online Banking 3rd party deposit": "Employer"
}
},
"Business Expenses": {
@mpurdon
mpurdon / client.ts
Created January 20, 2023 21:45
An example of functional command pattern in TS
/**
* Zoho API Client
*
* Uses the Functional Options pattern to allow for a cleaner constructor
*
* @see: https://medium.com/swlh/using-a-golang-pattern-to-write-better-typescript-58044b56b26c
*/
import axios from 'axios';
import {Logger} from '@aws-lambda-powertools/logger';
@mpurdon
mpurdon / storeMessage.ts
Last active January 5, 2023 21:51
Storing a message in TS with Typescript DynamoDB Document Client
/**
* Store the message in dynamo
*
* @param creationDate
* @param context
*/
const storeMessage = async (
creationDate: Date,
context,
): Promise<{ creationDateString: string; pk: string }> => {