Skip to content

Instantly share code, notes, and snippets.

View chris-burkhardt's full-sized avatar
🏠
Working from home

Chris B chris-burkhardt

🏠
Working from home
View GitHub Profile
@chris-burkhardt
chris-burkhardt / sourcetree-github-tags-fix
Created July 21, 2021 07:32
sourcetree-github-tags-fix
No matter git hooks or other scripts, all of them need to run on the local machines individually.
So I will suggest to sync tags with remote before the developers create their own tags on local machines.
Actually it just need to execute once for each local machine,
so the developers just need to run below commands (delete local tags and get all tags from remote)
on their machine before working:
git tag -l | xargs git tag -d
git fetch --tags
@chris-burkhardt
chris-burkhardt / nodejs-distinct-array-items
Created July 16, 2021 02:50
Nodejs Distinct Array Items
const diff = (arr1, arr2) => [
...arr1.filter(e => !arr2.includes(e)),
...arr2.filter(e => !arr1.includes(e))
];
const sym = (...args) => [...new Set(args.reduce(diff))];
sym([1, 2, 3], [5, 2, 1, 4]);
// ===========================
@chris-burkhardt
chris-burkhardt / Nodejs-quicksort-descending
Created July 15, 2021 03:19
NodeJS QuickSort Descending
var existingOrder = [{
CreatedDate: "2021-07-12T03:49:57.000Z"
},
{
CreatedDate: "2021-07-13T09:25:23.000Z"
},
{
CreatedDate: "2021-07-18T04:52:41.000Z"
},
{
@chris-burkhardt
chris-burkhardt / nodejs12-sort.txt
Last active July 15, 2021 03:15
NodeJS 12 sort() working
var existingOrder = [{
CreatedDate: "2021-07-12T03:49:57.000Z"
},
{
CreatedDate: "2021-07-13T09:25:23.000Z"
},
{
CreatedDate: "2021-07-18T04:52:41.000Z"
},
{
@chris-burkhardt
chris-burkhardt / s3BucketCleaner.yml
Created June 28, 2021 03:01
Github Actions Teardown Serverless Stack - Empty S3 Buckets
name: TeardownBranch
'on': [delete]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
@chris-burkhardt
chris-burkhardt / NodeJS-base64encodedimage-to-S3.txt
Last active October 27, 2021 03:39
JS Upload Base64 Encoded Image to AWS S3 Bucket
'use strict'
const AWS = require("aws-sdk");
const S3 = new AWS.S3();
module.exports = async function (inputs, context) {
// example encoded images can be created here: https://www.base64-image.de/
// upload image to S3
try {
const s3BucketLocation = await uploadImageToS3(inputs.DeviceDiagnosticRequest.IMEIImage, "IMEIImage", inputs, context);
} catch (error) {
@chris-burkhardt
chris-burkhardt / nodejs-crypto-encryption-service.txt
Last active July 15, 2021 03:23
JS Crypto Encryption Service
'use strict'
// use the following online tool for encryption and decryption testing
// https://www.javainuse.com/aesgenerator
const CryptoJS = require('crypto-js');
class EncryptionService {
/**
* Encrypts a plain-text string using AES-256 cipher with the following settings
* Mode: CBC, Key Size: 256, Output Format: Base64
const missingIDs = ['111111', '2222222'];
const existingUsers = [{
"System": "Test",
"Company Name": "Test Company",
"UU_UserName": "testuser",
"Active": 0,
"Ceased": 0,
"Unused": 4,
"UBO Surname1": "Test",
"UBO Firstname1": "Test",
@chris-burkhardt
chris-burkhardt / nodejs-remove-array-duplicates-using-set().txt
Last active July 15, 2021 03:22
Remove Array Duplicates with new Set() in JS
const testArr1 = ['pig', 'fox', 'zebra']
const testArr2 = ['ferrari', 'fox', 'pig', 'maserati']
// each value of a Set needs to be unique, so combining arrays that have
// duplicate entries into a Set will auto-remove exact matches
const removeArrayDuplicates = (first, second) => {
const combinedArrays = [...first, ...second];
const arraySet = [...new Set(combinedArrays)]
return arraySet
}
@chris-burkhardt
chris-burkhardt / DockerCommandCheatSheet.txt
Last active May 3, 2020 23:25
Docker Command Cheat Sheet
Most frequently used Docker commands:
-----------------------------------------------------------------
ALL CONTAINERS - delete
-----------------------------------------------------------------
## Main ways to remove all images/containers
docker rm $(docker ps -a -q)
docker rmi -f $(docker images -q)
## Delete all running and stopped containers
docker container rm -f $(docker ps -aq)