Skip to content

Instantly share code, notes, and snippets.

View mikesparr's full-sized avatar

Mike Sparr mikesparr

  • Montana, USA
View GitHub Profile
@mikesparr
mikesparr / nodejs-routes-standards-example.md
Created October 1, 2025 22:51
Example NodeJS Express App Routes Specification

API Route Standardization Guide

This guide outlines the standards that should be followed to ensure consistency across all route files in the API.

Route File Structure

Each route file should follow this structure:

// 1. Imports
@mikesparr
mikesparr / nodejs-controllers-standards-example.md
Created October 1, 2025 22:50
Example NodeJS Express App Controller Standards Definition

API Controller Standardization Guide

This guide outlines the standards that should be followed to ensure consistency across all controllers in the API.

Controller Structure

Each controller file should follow this structure:

// 1. Imports
@mikesparr
mikesparr / facebook-post-test.js
Created September 28, 2025 00:37
Test script publishing posts to a Facebook page
import express from "express";
import fetch from "node-fetch";
const app = express();
app.use(express.json());
// Load environment variables
const {
FB_PAGE_ID,
FB_ACCESS_TOKEN,
@mikesparr
mikesparr / example-cloud-run-tf-secret-file.tf
Last active May 18, 2025 21:47
Example Terraform syntax for Cloud Run with Secret Manager secret as mounted file
provider "google" {
project = var.project
}
data "google_project" "current" {}
# Build the service agent email using the format:
# service-PROJECT_NUMBER@serverless-robot-prod.iam.gserviceaccount.com
locals {
project_number = data.google_project.current.number
@mikesparr
mikesparr / example-google-secret-as-file.sh
Created May 18, 2025 19:41
Google Cloud Secret Manager example secret as file
# create secret as file
export SECRET_ID="example-secret"
export SECRET_FILE=".env"
# create env file
cat > $SECRET_FILE << EOF
# Node environment
NODE_ENV=production
# Logging configuration
@mikesparr
mikesparr / example-dockerfile-entrypoint.sh
Created May 18, 2025 19:24
Inline Dockerfile entrypoint.sh creation
# Create a script to load environment variables from mounted secrets
RUN echo '#!/bin/sh' > /app/entrypoint.sh && \
echo 'if [ -d "/secrets" ] && [ -f "/secrets/.env" ]; then' >> /app/entrypoint.sh && \
echo ' cp /secrets/.env /app/.env' >> /app/entrypoint.sh && \
echo ' echo "Loaded environment from mounted secret"' >> /app/entrypoint.sh && \
echo 'fi' >> /app/entrypoint.sh && \
echo 'exec node src/server.js' >> /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh && \
chown nodeapp:nodeapp /app/entrypoint.sh
@mikesparr
mikesparr / .env.example
Last active May 2, 2025 17:53
Google Cloud Organization Initial Setup
BILLING="YOUR-BILLING-ACCT"
ORGANIZATION="<ORG-ID-NUMBER>"
FOLDER="<FOLDER-ID-NUMBER>"
CUSTOMER="<CUSTOMER-ID>"
# user groups
export ORG_ADMIN_GROUP="[email protected]"
export BILLING_ADMIN_GROUP="[email protected]"
export SECURITY_ADMIN_GROUP="[email protected]"
export NETWORK_ADMIN_GROUP="[email protected]"
@mikesparr
mikesparr / docker-desktop-uninstall-colima-install.sh
Last active February 9, 2025 22:58
Helper script to replace Docker Desktop for Mac with Colima and test networking
#!/bin/env bash
#####################################################################
# REMOVE DOCKER DESKTOP FOR MAC (OPTIONAL: IF INSTALLED)
#####################################################################
echo ""
echo "Removing Docker Desktop for Mac..."
# 1. make sure docker running
sudo launchctl start com.docker.docker
@mikesparr
mikesparr / gke-clickhouse-operator-parquet.sh
Created October 21, 2024 23:59
Example deploying Clickhouse database operator on Google Kubernetes Engine (GKE) Autopilot cluster and importing parquet data from storage bucket using HMAC key
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/kubernetes-engine/docs/how-to/creating-an-autopilot-cluster
# - https://cloud.google.com/storage/docs/creating-buckets
# - https://cloud.google.com/storage/docs/access-control/using-iam-permissions
# - https://cloud.google.com/storage/docs/authentication/managing-hmackeys#command-line
# - https://github.com/Altinity/clickhouse-operator/blob/master/docs/quick_start.md
# - https://clickhouse.com/docs/en/getting-started/quick-start
@mikesparr
mikesparr / gcp-asset-inv-bq-feed.sh
Last active July 17, 2024 21:24
Experiment with GCP Asset Inventory feeds publishing to Pub/Sub and importing into BigQuery using subscriptions and Avro schema
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/asset-inventory/docs/monitoring-asset-changes#organizations
# - https://cloud.google.com/asset-inventory/docs/reference/rest/v1/TopLevel/batchGetAssetsHistory#temporalasset
# - https://cloud.google.com/iam/docs/creating-custom-roles#creating
# - https://cloud.google.com/sdk/gcloud/reference/organizations/add-iam-policy-binding
# - https://gist.github.com/mikesparr/38260f9d457fc2f9452f1910213b4a71
# - https://aravind-ramaiahk.medium.com/streamlining-cloud-asset-management-automating-the-export-of-google-cloud-organization-asset-46cc8b428038