Skip to content

Instantly share code, notes, and snippets.

View Whitecx's full-sized avatar

Christian Bates-White Whitecx

View GitHub Profile
@Whitecx
Whitecx / dualStartScript.json
Last active October 29, 2021 18:56
An NPM script for starting both the main server with npm start, and a react local server with npm start in separate windows. (Assumes folder structure: root->client, server
"scripts":{
"predualStart": "echo \"DIR=\"$0\"; cd \"$DIR\"; echo \"Launching React Client in New Window\"; echo \"Current directory: \"$PWD\"\"; npm --prefix \"$PWD\"/../client start;\" > clientStarter.sh && chmod +x clientStarter.sh && open -a Terminal clientStarter.sh",
"dualStart": "trap 'rm clientStarter.sh' SIGINT && nodemon --inspect -r dotenv/config -i index.js",
}
@Whitecx
Whitecx / renderHTML.js
Created April 18, 2023 19:08
Render ChatGPT HTML
// Select all code elements containing HTML code snippets
const codeElements = document.querySelectorAll('code');
// Loop through each code element
codeElements.forEach(codeElement => {
// Get the inner HTML of the code element and replace entities
let codeHTML = codeElement.innerHTML
// Remove the syntax highlighting tags and surrounding quotes using a regular expression
codeHTML = codeHTML.replace(/^['"]?<code>|<\/code>['"]?$/g, '').replace(/<[^>]+>/g, '');
@Whitecx
Whitecx / refreshStack.js
Last active May 18, 2023 17:22
A chrome snippet for auto-refreshing cloudformation stacks (only for a specific stack, not the list of stacks)
//Returns a promise that resolves after a setTimeout wait period of "seconds"
const wait = async (seconds = 1)=> {
seconds *= 1000;
return new Promise((resolve, reject) => { setTimeout(resolve, seconds)});
}
//Targets the second stacks refresh button (the one when a stack is being viewed) and clicks it on a loop
const runStackRefresh = async () =>{
const stackRefreshBtn = document.getElementsByClassName("stacks-refresh-button")[1];
while(true){