Skip to content

Instantly share code, notes, and snippets.

View stevehenderson's full-sized avatar

Steve Henderson stevehenderson

View GitHub Profile
@stevehenderson
stevehenderson / find_to_sqllite3.sh
Created April 16, 2024 04:41
Index a folder and store it in SQLite
find ~/Downloads -type f -exec stat -c "%n|%s|%y" {} \; | awk -F"|" '{printf("INSERT INTO files (file_path, file_size, file_date) VALUES ('\''%s'\'', %s, '\''%s'\'');\n", $1, $2, $3)}' | sqlite3 mydb.db
@stevehenderson
stevehenderson / remove-old-kernels.sh
Created March 25, 2024 03:03
Remove Old Kernels
#!/bin/bash
# Run this script without any param for a dry run
# Run the script with root and with exec param for removing old kernels after checking
# the list printed in the dry run
# FROM: https://askubuntu.com/questions/1253347/how-to-easily-remove-old-kernels-in-ubuntu-20-04-lts
uname -a
IN_USE=$(uname -a | awk '{ print $3 }')
echo "Your in use kernel is $IN_USE"
@stevehenderson
stevehenderson / powericeberg.yaml
Last active March 18, 2024 19:14
poweiceberg.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: spark-ui-proxy-controller
spec:
serviceName: spark-ui-proxy
replicas: 1
selector:
matchLabels:
component: spark-ui-proxy
@stevehenderson
stevehenderson / tar_encrypt_split.md
Last active November 14, 2023 15:09
Linux command to tar, pgp encrypt, and split a file

Encrypt:

tar -cJvpf - inputdirectory/ | gpg --symmetric --cipher-algo aes256 | split -d -b 100m - outputfile.tar.xz.gpg

Decrypt:

@stevehenderson
stevehenderson / postgres_show_partion_with_rows.sql
Created March 23, 2023 01:54
Query a postgres table with partitions and show the partition
SELECT tableoid::regclass AS source, *
FROM schema.partitioned_table
@stevehenderson
stevehenderson / list_all_bigquery_jobs.md
Created February 9, 2023 17:40 — forked from polleyg/list_all_bigquery_jobs.md
List BigQuery jobs from all users

Sometimes you need to troubleshoot and inspect the details of jobs (load, query etc.) in BigQuery. Inspecting the job history in the BigQuery web UI will only show the jobs that you have run. This is also true when you run run bq ls -j on the command line.

But, what if you need to get all jobs that have been run? An example would be auotmated jobs run by service accounts. A quick tip is to use the --all flag:

-a,--[no]all: Show all results. For jobs, will show jobs from all users. For datasets, will list hidden datasets. For transfer configs and runs, this flag is redundant and not necessary.

bq ls -j --all

(this tip originated from a question on Stack Overflow: https://stackoverflow.com/questions/47583485/bigquery-history-of-jobs-submitted-through-python-api)

@stevehenderson
stevehenderson / gsutil_ls_recursive.sh
Created February 3, 2023 00:54
gsutil gcs ls recursive
gsutil ls gs://some-bucket/**
@stevehenderson
stevehenderson / entropy-walker.sh
Created February 2, 2023 04:28
Entropy Walker - get entropy of all files in a directory
#!/bin/bash
#
# A simple entropy walker.
# Requirements: apt install ent
#
echo 0,File-bytes,Entropy,Chi-square,Mean,Monte-Carlo-Pi,Serial-Correlation
for i in *;
do echo $i $(ent "$i" -t | tail -n1);
done
@stevehenderson
stevehenderson / cloud_sql_csv_import.sh
Created December 7, 2022 03:58
Cloud SQL command line CSV import
gcloud sql import csv cloud-sql-instance-name gs://somebucket/folder/2/bigolecsv.gz -d somedatabase --table sometable
@stevehenderson
stevehenderson / golang_define_struct.md
Created November 30, 2022 14:29
golang unmarshall nested json from result

How do you unmarshall nested json

Given dgraph res.Json:

"q": [
      {
        "city": {
 "uid": "0x51c7ebb",