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 / cloud-next-24-demo.sh
Last active April 8, 2024 03:57
Snippets from my Cloud Next '24 demo talk "Hello Gateway, Goodbye Ingress" in Las Vegas April 9, 2024
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/kubernetes-engine/docs/concepts/gateway-api
# - https://cloud.google.com/kubernetes-engine/docs/how-to/container-native-load-balancing
# - https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
# - https://cloud.google.com/gemini/docs/quickstart
# - https://cloud.google.com/kubernetes-engine/docs/best-practices/rbac
# - https://cloud.google.com/kubernetes-engine/docs/how-to/hardening-your-cluster#group_authentication
@mikesparr
mikesparr / gcp-secure-web-proxy-1.sh
Created March 29, 2024 18:35
Experiment using Google Cloud Secure Web Proxy and Cloud NAT
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/secure-web-proxy/docs/initial-setup-steps
# - https://cloud.google.com/certificate-manager/docs/deploy-google-managed-regional
# - https://cloud.google.com/secure-web-proxy/docs/quickstart
# - https://cloud.google.com/secure-web-proxy/docs/enable-tls-inspection (OPTIONAL)
#####################################################################
@mikesparr
mikesparr / gcp-gae-cr-private.sh
Created March 26, 2024 03:17
Example Google Cloud Platform (GCP) serverless apps communicating via private network
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/run/docs/securing/private-networking#from-other-services
# - https://cloud.google.com/run/docs/securing/private-networking#from-vpc
# - https://cloud.google.com/appengine/docs/flexible/disable-external-ip
# - https://cloud.google.com/dns/docs/records#adding_or_removing_a_record
# - https://cloud.google.com/vpc/docs/configure-private-google-access
# - https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-go-service
@mikesparr
mikesparr / advanced-ddos-gcp.sh
Last active March 6, 2024 22:24
Cheat sheet for enabling advanced DDoS protection on Google Cloud
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/armor/docs/managed-protection-using#gcloud
# - https://cloud.google.com/armor/docs/advanced-network-ddos
# - https://cloud.google.com/armor/docs/configure-adaptive-protection
# - https://cloud.google.com/armor/docs/adaptive-protection-auto-deploy
#####################################################################
@mikesparr
mikesparr / 01_setup.sh
Created March 6, 2024 20:25
Experiment using Langchain, OpenAI and Streamlit, along with FAISS for CPU vector store, that analyzes YouTube transcripts and answers questions
#!/usr/bin/env bash
# reference: https://www.youtube.com/watch?v=lG7Uxts9SXs (some code was deprecated so fix along way)
# create folder
mkdir youtube-assistant
cd youtube-assistant
# set up virtual env
python3 -m venv .venv
@mikesparr
mikesparr / word2vec_import.py
Created March 5, 2024 00:40
Experiment with Word2Vec embedding of words in Python for study of GenAI and NLP solutions
import pandas as pd
import nltk
import string
import matplotlib.pyplot as plt
from nltk.corpus import stopwords
from nltk import word_tokenize
from gensim.models import Word2Vec as w2v
from sklearn.decomposition import PCA
@mikesparr
mikesparr / mini-qa.py
Last active February 27, 2024 16:26
Experiment with Langchain, OpenAI, and Datastax AstraDB (vector database) for custom LLM Q&A bot in Python
#!/usr/bin/env python3
# Reference: https://www.youtube.com/watch?v=yfHHvmaMkcA (Tutorial - some dated libs fixed in here)
# set constants
ASTRA_DB_APPLICATION_TOKEN="<< YOUR APP TOKEN (starts with AstraCS:) >>"
ASTRA_DB_SECURE_BUNDLE_PATH="<< FULL PATH TO YOUR ASTRA DB BUNDLE >>"
ASTRA_DB_CLIENT_ID="<< YOUR ASTRA DB CLIENT ID >>"
ASTRA_DB_CLIENT_SECRET="<< YOUR ASTRA DB CLIENT SECRET >>"
ASTRA_DB_KEYSPACE="search"
@mikesparr
mikesparr / gke-gateway-iap-demo.sh
Created February 24, 2024 17:56
Demo securing a Google Kubernetes Engine (GKE) hosted app using Gateway API, HTTPRoute, and Identity Aware Proxy (IAP)
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/iap/docs/concepts-overview
# - https://cloud.google.com/iap/docs/enabling-kubernetes-howto
# - https://cloud.google.com/kubernetes-engine/docs/how-to/configure-gateway-resources#configure_iap
# - https://cloud.google.com/sdk/gcloud/reference/container/clusters/create
# - https://github.com/digitalocean/kubernetes-sample-apps/tree/master/podinfo-example
# - https://cloud.google.com/kubernetes-engine/docs/how-to/container-native-load-balancing
@mikesparr
mikesparr / gcp-nextjs-vercel-gcp-migrate.sh
Last active November 23, 2023 21:40
Experiment migrating Vercel hosted NextJS app to Google Cloud Platform atop Cloud Run
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://nextjs.org/learn/dashboard-app/getting-started
# - https://github.com/vercel/next.js/tree/canary/examples/with-docker
# - https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-nodejs-service
# - https://cloud.google.com/run/docs/configuring/services/environment-variables
# - https://cloud.google.com/run/docs/securing/service-identity
# - https://cloud.google.com/sdk/gcloud/reference/run/deploy
@mikesparr
mikesparr / 01-firebase-auth-test.md
Last active October 31, 2023 21:12
Firebase Auth Phone Provider Test

Firebase Setup

  • created Firebase project
  • created Firebase app
  • copied example code
  • setup node enviroment
# install node
brew install node

# setup firebase