Skip to content

Instantly share code, notes, and snippets.

@gregjhogan
gregjhogan / ubuntu-back-blackground-color.sh
Created March 2, 2020 19:40
ubuntu black background color
gsettings set org.gnome.desktop.background picture-options 'none'
gsettings set org.gnome.desktop.background primary-color '#000000'
@gregjhogan
gregjhogan / raspberry-pi-ubuntu-provisioning.sh
Created December 11, 2019 22:37
change default username after installing ubuntu on raspberry pi
NEWNAME=""
FULLNAME=""
usermod -l $NEWNAME -d /home/$NEWNAME -m ubuntu
groupmod -n $NEWNAME ubuntu
chfn -f $FULLNAME $NEWNAME
@gregjhogan
gregjhogan / azure-storage-blob-git-repo.sh
Created September 25, 2019 21:43
git repo backed by azure blob storage
# create public azure storage account <account> with container 'git-test'
az storage account create -n <account> -g <resource-group> -l <region> --sku Standard_LRS
az storage container create --account-name <account> -n git-test --public-access blob
# create a
mkdir git-test && cd git-test
git init
echo "Hello World!" > test.txt
git add test.txt && git commit -m 'initial commit'
@gregjhogan
gregjhogan / redis-list-progress-bar.sh
Created August 25, 2019 05:26
redis list progress bar
# watch the progress of a redis list go down
REDIS_HOST=<redis-hostname> REDIS_LIST=<redis-listname> TOTAL=<optional> python -c $'import os; import redis; from tqdm import tqdm; from time import sleep; r = redis.Redis(host=os.getenv("REDIS_HOST")); plen = r.llen(os.getenv("REDIS_LIST")); total = int(os.getenv("TOTAL", 0)); progress = tqdm(total=(total or plen), initial=(total-plen if total else 0));\nwhile plen > 0: clen = r.llen(os.getenv("REDIS_LIST")); progress.update(plen-clen); plen = clen; sleep(1);\nprogress.close()'
@gregjhogan
gregjhogan / base64-decode-file-names.sh
Created August 15, 2019 20:17
base64 decode file names in directory that have base64 encoded names
find <dir> -type f | xargs -L 1 -I {} basename {} | xargs -L 1 -I {} printf "{}\nCg==" | base64 -d
@gregjhogan
gregjhogan / base64-decode-file-names.sh
Last active August 15, 2019 20:21
base64 decode file names in directory that have base64 encoded names
find <dir> -type f | xargs -L 1 -I {} basename {} | xargs -L 1 -I {} printf "{}\nCg==\n" | base64 -d
@gregjhogan
gregjhogan / mysql-schema-change-with-all-clients-disconnected.sh
Created July 24, 2019 07:43
MySQL schema change while all clients are disconnected
# block all connections
sudo iptables -A INPUT -p tcp --dport 3306 -j DROP
# kill all connections
docker exec -it <container-name> mysql -sN -e "select concat('kill ',id,';') from information_schema.processlist;" > kill.txt
docker exec -i <container-name> mysql < kill.txt
# make schema changes
ALTER TABLE ...
# allow connections again
sudo iptables -D INPUT -p tcp --dport 3306 -j DROP
@gregjhogan
gregjhogan / azure-storage-account-container-size.sh
Last active June 6, 2019 23:16
get size of all files in an azure storage account container
echo $(az storage blob list --account-name <account-name> --container-name <container-name> --query "[*].[properties.contentLength]" --output tsv --num-results '*' | paste --serial --delimiters=+ | bc | xargs printf "%'d") bytes
@gregjhogan
gregjhogan / read-vin.py
Last active May 25, 2025 13:02
Read VIN using read memory by address
import sys
import os
import struct
import time
from python import Panda
from enum import IntEnum
from Queue import Queue, Empty
import threading
@gregjhogan
gregjhogan / speedtest-cli.sh
Last active June 7, 2019 21:26
bash speed test
curl https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -