Skip to content

Instantly share code, notes, and snippets.

View datfinesoul's full-sized avatar
😲
attempting to absorb infinite amounts of information

Phil Hadviger datfinesoul

😲
attempting to absorb infinite amounts of information
View GitHub Profile
@datfinesoul
datfinesoul / Makefile
Created June 22, 2021 03:46
Drift Makefile
SHELL=/bin/bash
scan:
@driftctl scan \
--from "tfstate+tfcloud://$(shell <".tfcloud/.wsid" cat)" \
--tfc-token "$(shell <"${HOME}/.terraform.d/credentials.tfrc.json" jq -r '.credentials."app.terraform.io".token')"
ignore:
@driftctl scan \
--from "tfstate+tfcloud://$(shell <".tfcloud/.wsid" cat)" \
@datfinesoul
datfinesoul / .editorconfig
Last active March 16, 2021 13:38
Merge a list of keys into a JSON map and clean up old entries
[*.bash]
indent_style = tab
indent_size = 2
[*.{txt,json}]
indent_style = space
indent_size = 2
@datfinesoul
datfinesoul / multiline-regex.js
Last active March 9, 2021 12:46
Ability to split regex into multiple lines and add comments in JS
const partition = "aws-cn";
const multilineRegex = (...rest) => new RegExp(rest.map(x => (x instanceof RegExp) ? x.source : x).join(''));
const re = multilineRegex(
/aws:/, // I can COMMENT!!!!
partition,
/:secretsmanager:cn-north-1:111111111111:/
);
@datfinesoul
datfinesoul / README.md
Last active November 24, 2022 07:02
Use `jq` to take a JSON object and export it as environment variables

There is extra code in here, but the key takeaway is:

  1. Use jq to convert an object with key/value pairs, into a key=value string list
  2. Feed that listinto a while loop, which then exports the environment variables

While this is done in a script, it needs to live in a function, if the environment variables are supposed to persist in the current shell.

@datfinesoul
datfinesoul / README.md
Last active February 15, 2021 13:29
Node.js Generator Async/Await Concurrency Limit

elaborate-example.js

Shows the use of generators to control concurrency. This example illustrates the following.

  • 3 workers running through the data
  • Each piece of "work" takes 200-2000 milliseconds to run
  • The 5th, 10th and 17th item will throw an exception
  • Workers will exit because the exception is unhandled
worker='1' itemnum='0' item='F'
@datfinesoul
datfinesoul / README.md
Last active February 3, 2021 04:16
JS Examples: Failing to use await with async functions

A teaching example to show what happens when you don't have an await on an async method invocation.

Without the away, the program will print:

1612325635779 slowMessage start
1612325635781 leaving program
1612325637784 slowMessage end
@datfinesoul
datfinesoul / ecr.md
Last active June 12, 2020 04:55
ECR Notes

Tag an <untagged> ECR image in China

export AWS_PROFILE="<profile>"
aws ecr get-login-password --region cn-north-1 | \
  docker login --username AWS --password-stdin <account_id>.dkr.ecr.cn-north-1.amazonaws.com.cn
MANIFEST=$( \
  aws ecr batch-get-image --repository-name <ecr_repo_name> \
  --image-ids imageDigest=sha256:<sha> \
  --query 'images[].imageManifest' --output text \
 )
@datfinesoul
datfinesoul / databases - naming_conventions.md
Last active October 23, 2015 22:40
Databases: MSSQL naming conventions for contstraints

MSSQL naming conventions

The best take on this I've seen so far.

Based on a post by Dan Guzman, SQL Server MVP, http://weblogs.sqlteam.com/dang/.

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/76db4119-d040-446e-9ea7-6ba90e017338/naming-conventions-for-constraints?forum=transactsql

Picture a database with a Schema called "In" and another schema called "Out", representing input data and output data respectively. These schema have table names that're the same - for example: each schema has it's own IncomeExpense

@datfinesoul
datfinesoul / databases - bit_vs_dates.md
Last active October 23, 2015 22:31
Databases: BITs vs DATEs

BITs vs DATETIMEs for flags

My background has been more in the MSSQL (Microsoft SQL Server) side of relational databases in the past, so I'll use DATETIME and BIT as the data types of the discussion, but it should work the same regardless of DBMS.

Take for example this table:

CREATE TABLE blog.article
(
 article_id INT NOT NULL,
@datfinesoul
datfinesoul / splunk.md
Created September 2, 2015 19:52
Splunk Notes

SPLUNK & Logging

Tips

  • SET TIMEZONE IN PROFILE

creating a basic saved search

sourcetype=syslog (host=east OR host=europe OR host=asia OR host=jobs) marklar