Skip to content

Instantly share code, notes, and snippets.

Avatar

nmccready nmccready

View GitHub Profile
View gitCheckoutSingleFile.sh
# https://stackoverflow.com/questions/1125476/retrieve-a-single-file-from-a-repository
git clone --no-checkout --depth=1 --no-tags $1
git restore --staged $2
git checkout $2
View classes.dart
void main() {
final p = new Employee("Nick", height: 5.8, weight: 210, age: 41, taxCode: "123", salary: 2000000);
print(p.toString());
}
mixin Health {
String getLifePercentage(int age) => (100 * (age / 101.00)).toStringAsFixed(3);
double getBMI(double height, double weight) => weight / (height * height);
}
View promiseMapAnything.js
const PromiseMapAnything = (promises, cb) =>
Promise.try(() =>
Promise.resolve(promises).then((arrayOrObject) => {
if (_.isArray(arrayOrObject)) {
return Promise.map(arrayOrObject, cb);
}
const size = Object.values(arrayOrObject).length;
return Promise.all(_.map(arrayOrObject, (value, key) => cb(value, key, size)));
})
);
@nmccready
nmccready / Simple-S3Bucket-SNS
Created Jul 8, 2021 — forked from austoonz/Simple-S3Bucket-SNS
A CloudFormation template sample for creating an S3 Bucket with an SNS Trigger.
View Simple-S3Bucket-SNS
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Simple S3 Bucket with SNS Trigger
Parameters:
BucketName:
Type: String
Description: The name of the S3 Bucket to create
View Terraform-State-Ideas.md

Issues with Terraform State Management

The idea of "state" is the lynchpin of Terraform, and yet Terraform's workflow is fraught with gotchas that can lead to the loss or destruction of state. This doc is a set of notes about issues I've encountered, what caused them, and in many cases ideas about how to improve Terraform to avoid or reduce the chances of them.

Each of these scenarios has occured at least within my team. Each time one of these occurs it erodes people's confidence in Terraform, giving it a reputation for being fragile and unforgiving of errors. This this document is not written just to criticize but rather to identify ways in which the situation could be improved.

View golang links
@nmccready
nmccready / Makefile
Created Oct 29, 2020 — forked from ryu1kn/Makefile
Encrypt/decrypt with AWS KMS using AWS cli
View Makefile
# How to encrypt/decrypt your text/blob secret with AWS KMS with AWS cli
KEY_ID=alias/my-key
SECRET_BLOB_PATH=fileb://my-secret-blob
SECRET_TEXT="my secret text"
ENCRYPTED_SECRET_AS_BLOB=encrypted_secret_blob
DECRYPTED_SECRET_AS_BLOB=decrypted_secret_blob # Result of decrypt-blob target
encrypt-text:
@nmccready
nmccready / parseArgsForward.sh
Last active Oct 23, 2020
parse args and forward
View parseArgsForward.sh
while [[ "$#" > 0 ]]; do case $1 in
-j|--package-json) shift; PACKAGE_JSON_LOC=$1;;
-r|--repository-name) shift; DOCKER_REPO=$1;;
*) args[${#args[@]}]=$1;;
esac; shift; done
someFunction ${args[@]}
@nmccready
nmccready / recurseRename.sh
Created Aug 7, 2020
recusive rename mult files
View recurseRename.sh
$ find . -name 'index.go' -type f -exec rename 's/index\.go/main\.go/' '{}' \;
@nmccready
nmccready / npmVersion.md
Created Jun 26, 2020
npm version described
View npmVersion.md

npm version

read https://docs.npmjs.com/cli/version it's very straight forward.

Everything in npm config cli is available to be set in .npmrc like preid.

IE this allows your to define your prerelease identifier. By default npm follows this format.

MAJOR.MINOR.PATCH-PRE