Skip to content

Instantly share code, notes, and snippets.

View stevehenderson's full-sized avatar

Steve Henderson stevehenderson

View GitHub Profile
@stevehenderson
stevehenderson / k8s_nodes_pods.sh
Created November 10, 2022 17:30
Kubernetes pods and their node (for namespace x)
kubectl get pods --namespace somens -o wide | awk '{print $7," ", $1}' | sort
@stevehenderson
stevehenderson / harmony_install.md
Last active September 11, 2022 20:25
Installing Harmony

So I'm playing around with Harmony @ cs.cornell.edu.

Install steps (Ubuntu 20) [Should work on WSL]

Install Prequisites

You need to have build-essential, clang, python3 + dev headers, and graphviz

I also always install anything python related in its own virtual environments, so I added the python3-venv package

@stevehenderson
stevehenderson / force_delete_k8s_pv.md
Last active August 27, 2022 13:58
Delete Kubernetes Persistent Volume

Sometimes you delete stuff on GKE Autopilot and it doesn't take:

kubectl delete pv troubledvolume --grace-period=0 --force
kubectl patch pv troubledvolume -p '{"metadata": {"finalizers": null}}'
@stevehenderson
stevehenderson / cloud_build_large_file_copy_gcs.yaml
Last active August 13, 2022 19:32
Large File Timeout for Cloud Build gsutil
# The following sets the over all timeout
timeout: 7200s
- name: 'gcr.io/cloud-builders/gsutil'
args: ['cp', 'gs://project-volumes/big-project/big-file.tar', '.']
waitFor: ['-'] # The '-' indicates that this step begins immediately.
timeout: 4600s # Per step timeout
- id: "Read Values"
name: ubuntu
entrypoint: bash
args:
- -c
- |
# Read from "/workspace"
echo "Where am I " $(pwd)
echo "Contents " $(ls)
@stevehenderson
stevehenderson / ip_curl.sh
Created August 13, 2022 01:48
Find IP with curl
curl ipinfo.io/ip
curl api.ipify.org
curl checkip.dyndns.org
dig +short myip.opendns.com @resolver1.opendns.com
host myip.opendns.com resolver1.opendns.com
curl ident.me
curl bot.whatismyipaddress.com
curl ipecho.net/plain
curl ifconfig.me
curl -4/-6 icanhazip.com
@stevehenderson
stevehenderson / collab_presto.py
Created July 29, 2022 12:14
Collab and Presto
# First run this in top cell: pip install pyhive
from pandas import read_sql
from pyhive import presto
presto_conn = presto.Connection(host="collab-cluster-hostname-m", schema="your_presto_schema", catalog="presto_catalog", port=8060, username ="presto")
presto_cursor = presto_conn.cursor()
# Query presto node
query = "select * FROM system.runtime.nodes"
query_result = read_sql(query, presto_conn)
@stevehenderson
stevehenderson / pg_graphql_150.patch
Created July 29, 2022 00:45
Patch pg-graphql 30 row limit (pg_graphql--0.3.3.sql)
diff --git a/pg_graphql--0.3.3.sql b/pg_graphql--0.3.3.sql
index 1c7e735..c35ca13 100644
--- a/pg_graphql--0.3.3.sql
+++ b/pg_graphql--0.3.3.sql
@@ -3226,19 +3226,19 @@ begin
order by
%s
limit
- least(%s, 30) + 1
+ least(%s, 150) + 1
@stevehenderson
stevehenderson / gist:35372794c838572e634a71790f05d515
Last active August 21, 2022 03:55
Cascade drop all tables in a SQL/PostgreSQL schema
-- You will need to remove some quotation marks
select 'drop table if exists "schema_name"."' || tablename || '" cascade;'
from pg_tables
where schemaname = 'schema_name';
@stevehenderson
stevehenderson / get_usage.sql
Created June 8, 2022 21:17
PostgreSQL get usage
WITH RECURSIVE pg_inherit(inhrelid, inhparent) AS
(select inhrelid, inhparent
FROM pg_inherits
UNION
SELECT child.inhrelid, parent.inhparent
FROM pg_inherit child, pg_inherits parent
WHERE child.inhparent = parent.inhrelid),
pg_inherit_short AS (SELECT * FROM pg_inherit WHERE inhparent NOT IN (SELECT inhrelid FROM pg_inherit))
SELECT table_schema
, TABLE_NAME