Skip to content

Instantly share code, notes, and snippets.

View mherod's full-sized avatar
🏳️‍🌈

Matthew Herod mherod

🏳️‍🌈
View GitHub Profile
/* eslint-disable max-lines-per-function */
// noinspection CssInvalidPropertyValue,JSSuspiciousNameCombination
"use client";
import React, { type ReactElement, useEffect, useState } from "react";
import { renderToStaticMarkup } from "react-dom/server";
// Configuration constants
const MAGNIFIER_SIZE = 250;
/**
* Confluence Documentation Sync Script
*
* This script automatically syncs a repository's README.md to a Confluence page.
* To use this script in another repository:
*
* 1. Copy this file to your repository's scripts directory
* 2. Add the following to your package.json:
* ```
* {
#!/bin/bash
# Trap and exit on termination
trap 'echo "Script terminated. Exiting..."; exit 1' SIGINT SIGTERM
# Function to kill ffmpeg and ffprobe processes
kill_ff_processes() {
pkill -f ffmpeg
pkill -f ffprobe
}
import { test, expect } from "@playwright/test";
const { getCookie } = require("@mherod/get-cookie");
test.beforeAll(async ({ browser }) => {
const browserContexts = browser.contexts();
const domain = "myunidays.com";
const cookie = await getCookie({
name: "auth",
domain: domain
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KMutableProperty0
import kotlin.reflect.KProperty
inline class PropertyAlias<T>(val delegate: KMutableProperty0<T>) : ReadWriteProperty<Any?, T> {
override operator fun getValue(thisRef: Any?, property: KProperty<*>): T = delegate.get()
override operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) = delegate.set(value)
}
@mherod
mherod / twennyminutewifi.sh
Last active May 3, 2022 05:12
stopping at a hotel which only gives you 20 minutes of free wifi. run this for unlimited wifi
#!/bin/bash
# link airport into path if not found
which airport || sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
while true ; do
CURRENT_SSID=`airport -I | grep "\\s\\+SSID:\\s" | awk '{print $2}'`
echo "Currently connected to $CURRENT_SSID"
# set wifi interface mac address, computed random blob using openssl and then sed formats into shape, add colon per 2 char, trim trailing colon
import java.lang.reflect.InvocationHandler
import java.lang.reflect.Method
import java.lang.reflect.Proxy
import kotlin.properties.Delegates
inline fun <reified T : Any> lazyProxyLazy(noinline delegate: () -> T): Lazy<T> {
return lazy { proxyLazy(delegate) }
}
inline fun <reified T : Any> proxyLazy(noinline delegate: () -> T): T {
const { exec } = require("child_process");
async function command(command) {
const promise = new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => {
if (error) reject(error)
if (stderr) reject(stderr)
if (stdout) resolve(stdout)
});
});
@mherod
mherod / coroutineSample.kt
Created October 1, 2021 00:42 — forked from nosix/coroutineSample.kt
Promise and async/await sample in Kotlin/JS
fun main(args: Array<String>) {
launch {
loadAllFiles()
}
}
fun launch(block: suspend () -> Unit) {
block.startCoroutine(object : Continuation<Unit> {
override val context: CoroutineContext get() = EmptyCoroutineContext
override fun resume(value: Unit) {}
val cookieManager = CookieManager.getInstance()
cookieManager.removeAllCookies {
// undesired async completion handler
}
suspend fun CookieManager.clearCookies(): Boolean = suspendCoroutine {
removeAllCookies(it::resume)
}