Skip to content

Instantly share code, notes, and snippets.

View bruceharrison1984's full-sized avatar
🔥

Bruce Harrison bruceharrison1984

🔥
View GitHub Profile
@bruceharrison1984
bruceharrison1984 / make-mtls-certs.sh
Created April 26, 2024 18:36
LDAP MTLS Certificate Generation
#!/bin/sh
mkdir -p ./certs/{ca,client,server}
cd ./certs/ca
echo "Generate CA certificates"
openssl req -new -x509 -nodes -days 365 -subj '/CN=example.com' -keyout ca.key -out ca.crt
cd ../server
@bruceharrison1984
bruceharrison1984 / inject-importing-islands.ts
Last active February 28, 2024 15:59
HonoX Islands Detection
import { existsSync } from 'fs'
import { lstat, readFile } from 'fs/promises'
import path from 'path'
import MagicString from 'magic-string'
import precinct from 'precinct'
import { normalizePath, type Plugin } from 'vite'
import { IMPORTING_ISLANDS_ID } from '../constants'
export function injectImportingIslands(): Plugin {
const isIslandRegex = new RegExp(/\/islands\//)
@bruceharrison1984
bruceharrison1984 / jwtVerification.ts
Last active December 29, 2022 21:38
NextJS Cookie Auth sample
import * as jose from 'jose';
const FIREBASE_PUBLIC_KEY_URL =
'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com';
const isDev = process.env.NODE_ENV === 'development';
const firestoreBaseUrl = isDev
? 'http://localhost:8080'
: 'https://firestore.googleapis.com';
@bruceharrison1984
bruceharrison1984 / getCalendarView.js
Last active July 6, 2023 21:13
Javascript - Get calendar view of month as an array of arrays representing a month, split into weeks 7 dates long.
/**
* This function will return an array of arrays representing a month as a 6*7 data table. This includes leading/trailing days.
*
* This only uses native JS objects, so no external libs are needed
*
* It only iterates a single time, so it is highly performant
* @param date The month/year of this Date object determines the calendar that will be generated.
* @returns Date[][]
*/
const getCalendarView = (date: Date) => {
@bruceharrison1984
bruceharrison1984 / launch.json
Created January 26, 2022 22:59
storybook-vscode-debug.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Storybook Debug",
"type": "node-terminal",
"request": "launch",
"command": "npm run storybook",
"internalConsoleOptions": "openOnFirstSessionStart",
"serverReadyAction": {
@bruceharrison1984
bruceharrison1984 / ecs-prometheus.yaml
Created August 19, 2021 16:18
Prometheus Configuration
global:
evaluation_interval: 1m
scrape_interval: 30s
scrape_timeout: 10s
remote_write:
- url: <amp-endpoint>api/v1/remote_write
sigv4:
region: <aws-region>
scrape_configs:
- job_name: ecs
@bruceharrison1984
bruceharrison1984 / ecs-prometheus-task-role.json
Created August 19, 2021 16:17
IAM Role Permissions for ECS Prometheus
{
"Statement": [
{
"Action": [
"ecs:List*",
"ecs:Describe*"
],
"Effect": "Allow",
"Resource": [
"arn:aws:ecs:<region>:<account-id>:cluster/<ecs-cluster-name>",
@bruceharrison1984
bruceharrison1984 / ecs-prometheus-tasks.json
Last active August 19, 2021 16:57
Export ECS metrics to AMP
{
"executionRoleArn": "<execution-role-arn>",
"containerDefinitions": [
{
"image": "tkgregory/prometheus-ecs-discovery:latest",
"name": "prometheus-ecs-discovery-alpha",
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/alpha/ecs-prometheus",
@bruceharrison1984
bruceharrison1984 / delete-workflow-runs.sh
Created July 13, 2021 16:25
Delete Github Action Workflow Runs
### Stolen from https://stackoverflow.com/a/67000032
### Run multiple times, or use in a loop
org=<ORG>
repo=<REPO>
# Get workflow IDs with status "disabled_manually"
workflow_ids=($(gh api repos/$org/$repo/actions/workflows | jq '.workflows[] | select(.["state"] | contains("disabled_manually")) | .id'))
for workflow_id in "${workflow_ids[@]}"
@bruceharrison1984
bruceharrison1984 / tinyhealthcheck-complex.cs
Last active July 6, 2021 03:24
Monitor another process with TinyHealthCheck
public static IHostBuilder CreateHostBuilder(string[] args)
{
var processStartTime = DateTimeOffset.Now;
return Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddSingleton<WorkerStateService>();
services.AddHostedService<Worker>();
services.AddCustomTinyHealthCheck<CustomHealthCheck>(config =>
{