Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Fisher therightstuff

View GitHub Profile
@therightstuff
therightstuff / 1.do-it-yourself.js
Last active May 12, 2022
Reading and writing regular expressions for sane people
View 1.do-it-yourself.js
var parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})(0–9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/;
...
@therightstuff
therightstuff / StructuredData.cs
Created Mar 24, 2022
Storing and Retrieving Unstructured DynamoDB objects in C# with the AWS SDK
View StructuredData.cs
/// <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 Feb 20, 2022
Fixing polyfill incompatibilities for webpack 5 in create-react-app
View README.md

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 Oct 3, 2021
Bamboo YAML Specs Tips and Tricks
View README.md
@therightstuff
therightstuff / README.md
Created Jul 10, 2021
Node.js script to convert FNB Credit Card statements from PDF to CSV
View README.md

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 Apr 12, 2021
Safe atomic file writes for JSON and YAML in Python 3
View atomic_write.py
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.
@therightstuff
therightstuff / simple_password_generator.py
Last active Feb 19, 2021
Generate a secure python password with no dependencies
View simple_password_generator.py
"""
A simple password generator that produces secure passwords of a given length
without requiring the installation of additional modules.
The four valid password characters classes - lowercase, uppercase, digits and
punctuation - are inserted randomly into the password using cryptographically
strong random numbers from the secrets module until the password length
requirement is met, ensuring that each of the classes is included in the password.
Password strength verified with https://www.security.org/how-secure-is-my-password/
@therightstuff
therightstuff / nugetimport.sh
Last active Dec 10, 2020
Batch / bulk upload script for NuGet private repo hosted on Nexus
View nugetimport.sh
#!/bin/bash
# to be run with git-bash on a Windows machine
# based on https://github.com/sonatype-nexus-community/nexus-repository-import-scripts/blob/master/nugetimport.sh
# download latest version of nuget.exe for Windows x86 Commandline
# from https://www.nuget.org/downloads into the current directory
# retrieve NuGet API Key from Nexus by clicking on your profile,
# the side bar menu should show "NuGet API Key"
show_usage() {
@therightstuff
therightstuff / sample.js
Last active Nov 28, 2020
Convert GUID (UUID) to integer number in Javascript
View sample.js
// see https://github.com/uuidjs/uuid#uuidparsestr
const uuidParse = require('uuid').parse;
let convertGuidToInt = (uuid) => {
// parse accountId into Uint8Array[16] variable
let parsedUuid = uuidParse(uuid);
console.log(`uuid ${uuid} parsed successfully`);
// convert to integer - see answers to https://stackoverflow.com/q/39346517/2860309
let buffer = Buffer.from(parsedUuid);
@therightstuff
therightstuff / .netrc
Created Jul 28, 2020
Private PyPI repository access configurations
View .netrc
machine hostname.com
login USERNAME
password UNENCODED_PASSWORD