Skip to content

Instantly share code, notes, and snippets.

View mike-at-redspace's full-sized avatar
🎧

Mike Vardy mike-at-redspace

🎧
View GitHub Profile
@mike-at-redspace
mike-at-redspace / serverResponseTest.js
Last active August 15, 2023 16:11
Node Server Response testing
const timestamp = getCurrentTimestamp()
const startTime = new Date()
try {
const { status, headers } = await axios.get(site)
const { date, trace_id: traceId } = headers
const responseTime = new Date() - startTime
const log = `${timestamp},${date},${status},${site},${responseTime}ms,${traceId},${headers['cache-control']}\n`
await fs.appendFile(logFilePath, log)
console.log(`${timestamp}: ${site} - ${responseTime}ms`)
} catch (error) {
@mike-at-redspace
mike-at-redspace / App.js
Created August 11, 2023 07:32
Ink/Pastel Test Runner
import { useState, useEffect } from 'react';
import { render } from 'ink';
import inquirer from 'inquirer';
import fs from 'fs';
import path from 'path';
import TestRunner from './TestRunner';
const App = () => {
const [testPackages, setTestPackages] = useState([]);
@mike-at-redspace
mike-at-redspace / useResponsiveImage.js
Created August 10, 2023 07:12
DynamicPicture - useResponsiveImage
/**
* React hook to get responsive image dimensions
*
* DynamicPicture could use the height and width from sources[0] as initial dimensions (SSR)??
*
* @param {string} imageUrl - Image src url
* @param {object} initialDimensions - Initial dimensions for SSR
* @returns {{dimensions: {width: number, height: number}, imageRef}} - Image dimensions and ref
*/
const useResponsiveImage = (imageUrl, initialDimensions) => {
@mike-at-redspace
mike-at-redspace / index.js
Last active August 5, 2023 08:48
Website Speed Test Github Action
// webpagetest-action/index.js
const core = require('@actions/core');
const webpagetest = require('webpagetest');
async function run() {
try {
const domains = core.getInput('domains');
const apiKey = core.getInput('key');
@mike-at-redspace
mike-at-redspace / collectData.js
Last active July 29, 2023 10:15
Client-side scrape Cast from IMDB
// https://www.imdb.com/title/tt1865740/fullcredits
const collectData = () => {
try {
const data = { cast: [], crew: [] };
const fullCredits = document.getElementById('fullcredits_content');
for (const child of fullCredits.children) {
if (child.classList.contains('simpleCreditsTable')) {
@mike-at-redspace
mike-at-redspace / getCriticalCSS.js
Last active July 21, 2023 12:53
Grab above the fold css
/**
* Get critical CSS and class names for elements matching a selector
*/
function getCriticalCSS(selector) {
try {
const elements = document.querySelectorAll(selector);
const classNames = new Set();
import React from 'react';
import styled from '@emotion/styled';
const Loader = styled.div`
position: relative;
`;
const Flex = styled.div`
display: flex;
flex-wrap: nowrap;

Scaled Agile Framework Cheatsheet

What is SAFe 6.0?

  • SAFe 6.0 is the latest version of the Scaled Agile Framework, a knowledge base of proven, integrated principles, practices, and competencies for achieving business agility using Lean, Agile, and DevOps .
  • SAFe 6.0 helps enterprises thrive in the digital age by delivering innovative products and services faster, more predictably, and with higher quality.
  • SAFe 6.0 provides guidance on how businesses and employees can grow and respond to change.
  • What's new in SAFe 6.0?
    • SAFe 6.0 introduces seven core competencies of Business Agility: Customer Centricity, Enterprise Solution Delivery, Agile Product Delivery, Team and Technical Agility, Organizational Agility, Continuous Learning Culture, and Lean-Agile Leadership.
  • SAFe 6.0 incorporates the Objectives and Key Results (OKR) methodology to align strategic goals with day-to-day operations and track progress towards achieving those objectives.
@mike-at-redspace
mike-at-redspace / MyComponent.js
Last active March 30, 2023 06:51
Poorman's hashrouter
import useRememberState from './useRememberState';
const MyComponent = () => {
const [value, setValue] = useRememberState('myKey', 'defaultValue');
const handleChange = event => {
setValue(event.target.value);
};
return (
const bubbleSortObjects = (arr, key) => {
let swapped
const swap = i => {
;[arr[i], arr[i + 1]] = [arr[i + 1], arr[i]]
swapped = true
}
do {
swapped = false
for (let i = 0; i < arr.length - 1; i++) {
const a = arr[i][key]