Skip to content

Instantly share code, notes, and snippets.

@therightstuff
therightstuff / README.md
Created September 29, 2022 05:46
VSCode Jest extension settings for ZSH

VSCode Jest extension settings

These are the settings to enable the VSCode Jest extension to identify, run and debug tests using nvm and Oh My Zsh.

CAUTION: nvm must be available to the root user for these settings to work, see this script.

NOTE:

  • workspace-settings.json belong in .vscode/settings.json
  • extension-settings.json must be located via the VSCode settings interface
@therightstuff
therightstuff / update-root-nvm.sh
Created September 29, 2022 05:34
Make nvm's node and npm available to the root user
#!/bin/bash
nvm_version="$1"
if [ -z "$nvm_version" ]; then
 echo "desired nvm version must be provided eg. v14.16.0, try providing the output of 'nvm version'"
 exit 1
fi
node_link="/usr/local/bin/node"
npm_link="/usr/local/bin/npm"
@therightstuff
therightstuff / atomic-counter-lambda-handler.js
Created September 15, 2022 05:52
Atomic DynamoDB increment and creation/update time with Axios/API Gateway/Lambda
const aws = require('aws-sdk');
const dynamodb = new aws.DynamoDB.DocumentClient();
let corsHeaders = {
'Access-Control-Allow-Origin': process.env.CORS_ORIGIN,
'Access-Control-Allow-Credentials': true,
};
exports.handler = async () => {
const promise = new Promise(async (resolve) => {
@therightstuff
therightstuff / .circleci-config.yml
Last active September 6, 2022 06:19
Manual trigger workflow for CircleCI
version: 2.1
parameters:
my_trigger_parameter:
type: string
default: ""
workflows:
# Workflow triggered by API call / hitting "Trigger Pipeline" in the web interface
api-triggered-workflow:
@therightstuff
therightstuff / 1.do-it-yourself.js
Last active May 12, 2022 06:17
Reading and writing regular expressions for sane people
var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})(0–9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
...
@therightstuff
therightstuff / StructuredData.cs
Created March 24, 2022 22:37
Storing and Retrieving Unstructured DynamoDB objects in C# with the AWS SDK
/// <summary>
/// The object mapping used to store structured test data
/// </summary>
private class StructuredDynamoDbTestObject
{
/// <summary>
/// The data key.
/// </summary>
[DynamoDBHashKey("structured_key")]
public string StructuredKey { get; set; }
@therightstuff
therightstuff / README.md
Created February 20, 2022 08:58
Fixing polyfill incompatibilities for webpack 5 in create-react-app

Fixing polyfill incompatibilities after upgrading to webpack 5 in create-react-app

After upgrading to the latest dependencies, I encountered the following errors:

'buffer' resolution

ERROR in ./node_modules/safe-buffer/index.js 2:13-30

Module not found: Error: Can't resolve 'buffer' in '/Users/geek.neo/propolis-portal/node_modules/safe-buffer'
@therightstuff
therightstuff / README.md
Created October 3, 2021 10:35
Bamboo YAML Specs Tips and Tricks
@therightstuff
therightstuff / README.md
Created July 10, 2021 09:05
Node.js script to convert FNB Credit Card statements from PDF to CSV

Convert PDF FNB Credit Card statements to CSV compatible with cheque account CSV format

A quick-hack node.js script that converts FNB (First Nation Bank of South Africa) PDF Credit Card statements to a CSV format that's similar enough to the format of their cheque account CSVs to enable the budgie-feeder parser to ingest it.

NOTE: results may vary, generated CSV files must be reviewed before use.

@therightstuff
therightstuff / atomic_write.py
Last active April 12, 2021 09:51
Safe atomic file writes for JSON and YAML in Python 3
import json
import os
import shutil
import stat
import tempfile
import yaml
def copy_with_metadata(source, target):
"""Copy file with all its permissions and metadata.