Skip to content

Instantly share code, notes, and snippets.

View bradyclifford's full-sized avatar

Brady Clifford bradyclifford

View GitHub Profile
@bradyclifford
bradyclifford / generate-import-from-tf-show.js
Last active March 2, 2022 19:27
Terraform Show to Terraform Import
// Run using node
// Output first before running this command terraform show -json > file.json
const tfShowOutput = require(process.argv.slice(2)[0]);
function parseChildModules(modules) {
for (const {address: parentAddress, child_modules : childModules, resources} of modules) {
if (childModules) parseChildModules(childModules);
@bradyclifford
bradyclifford / session-refresh.js
Last active March 9, 2022 23:09
Session Keep alive on 3rd Party
// Function runs on an interval as the user is using the 3rd party site
function() {
return function() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
console.debug('Refresh token response', xhr);
if (xhr.status >= 200 && xhr.status < 300) return;
#!/bin/sh
JSON=$(<test.json)
for encodedPair in $(echo "${JSON}" | jq -r 'to_entries[] | @base64'); do
__jq() {
echo "${encodedPair}" | base64 --decode | jq -r ${1}
}
key=$(__jq '.key')
value=$(__jq '.value')
echo "::set-output name=${key}::${value}"
@bradyclifford
bradyclifford / AppInsightsExclude.js
Last active September 2, 2022 19:04
AppInsights: Exclude URL by path base route
// Only capture requests for a specific path based-route
excludeRequestFromAutoTrackingPatterns: [
new RegExp(
`^https?:\\/\\/([^\\/\\s]+\\/)(?!${escapeRegExp(removeSlashes(pathBase))}).+$`,
'i'
)
]
@bradyclifford
bradyclifford / Simple Wrap Layout.jsx
Last active October 7, 2022 02:33
Layout Examples
// https://css-tricks.com/quick-whats-the-difference-between-flexbox-and-grid/
const Tile = styled.aside`
padding: 25px;
border: 2px solid #e4e4e4;
border-radius: 5px;
`;
// Flex
// https://css-tricks.com/snippets/css/a-guide-to-flexbox/#aa-background
const TileContainer = styled.section`
@bradyclifford
bradyclifford / gist:d1d5bcd49287f5a795e150798f8b5fcf
Created February 24, 2023 15:27
Lookup Typescript String Enum by key
export function getEnumValueLookup<T extends Record<keyof T, string>>(object: T) {
return Object.fromEntries(
Object.entries(object).map(([key, value]) => [value as string, key as keyof T])
);
}
@bradyclifford
bradyclifford / Event Naming.js
Created July 14, 2023 14:34
FullStory Examples
// Title case the bounded context and event name
FS?.event('Bounded Context/Event Name', { data... })
// 👎 Wrong way to name an event
FS?.event('Click page button to add household member', { data... })
// 👍 Right way to name an event
FS?.event('Shopping/Cart/Button/Add Household Member', { data... })
FS?.event('IFP/Assessment/Selected Silver Plan', { data... })
@bradyclifford
bradyclifford / dependabot.yml
Created April 26, 2024 15:27
Dependabot with Private Repos
version: 2
registries:
git-all-orgs:
type: git
url: https://github.com
username: im-pipeline-bot
password: ${{secrets.READ_PKG_TOKEN}}
npm-github-packages-all-orgs:
type: npm-registry
url: https://npm.pkg.github.com