Skip to content

Instantly share code, notes, and snippets.

@bobbae
bobbae / ngrok_tunnel_two_commands.md
Created January 27, 2024 02:36
Two command solution to achieve ngrok like exposure of local http server to internet

If you have a web service on your laptop that you want to expose to the internet but you are located behind a firewall, you can use the following two commands to overcome the limitations.

This is not exactly equivalent but similar to ngrok.

https://ngrok.com/

You need a machine on Internet that has publicly accessible IP address. You can use a Google Cloud free tier virtual machine.

https://www.ardanlabs.com/blog/2020/11/working-with-sqlite-using-go-python.html?utm_source=pocket_reader
@bobbae
bobbae / istio-gke-tls-example.sh
Created December 9, 2021 16:16 — forked from mikesparr/istio-gke-tls-example.sh
Example GKE ingress with TLS certificate for secure traffic to backend Istio ingress gateway
#!/usr/bin/env bash
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
export PROJECT_NUMBER=$(gcloud projects describe $PROJECT_ID --format="value(projectNumber)")
export IDNS=${PROJECT_ID}.svc.id.goog # workflow identity domain
export GCP_REGION="us-west1"
export ISTIO_VERSION="1.9.1"
@bobbae
bobbae / shortwords.txt
Last active April 9, 2021 17:00
short words
cat
cats
catsdogcats
catxdogcatsrat
dog
dogcatsdog
hippopotamuses
rat
ratcatdogcat
setInterval(function() {document.elementFromPoint(500, 500).click();}, 30000);
#!/bin/sh
# Generate self signed root CA cert
openssl req -nodes -x509 -newkey rsa:2048 -keyout ca.key -out ca.crt -subj "/C=AU/ST=VIC/L=Melbourne/O=Ranch/OU=root/CN=root/emailAddress=sample@sample.com"
# Generate server cert to be signed
openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj "/C=AU/ST=VIC/L=Melbourne/O=Ranch/OU=root/CN=localhost/emailAddress=sample@sample.com"
# Sign the server cert
@bobbae
bobbae / get-iam-policy.py
Last active February 12, 2021 19:05
GCP: get a list of projects with roles/owner permission
import subprocess
import json
projects = subprocess.Popen(['gcloud', 'projects', 'list', '--format=json'], stdout=subprocess.PIPE).communicate()[0]
projects2 = json.loads(projects.decode('utf-8').replace('\n', ' '))
for proj in projects2:
projid = proj['projectId']
try:
from google.cloud import bigquery
project_id = "XXXX-XXXXX"
# Construct a BigQuery client object.
client = bigquery.Client(project=project_id)
dataset_id = project_id + ".example_dataset1"
print("dataset_id",dataset_id)
#dataset = client.get_dataset(dataset_id)
@bobbae
bobbae / unscientific-gcsfuse-vs-gsutil-benchmark.md
Last active April 17, 2024 04:01
A very crude benchmark for gcs (google cloud storage) fuse vs gsutils
  1. Create/use service account with "storage admin" role and download the key in json format.

  2. activate service account

  gcloud auth activate-service-account --key-file=/home/bob/bob-key.json /home/bob/tmpmnt/
  1. create a bucket
    gsutil mb gs://bobtest1