Skip to content

Instantly share code, notes, and snippets.

View emrysr's full-sized avatar

Emrys Roberts emrysr

View GitHub Profile
@emrysr
emrysr / cache-sizes.sh
Last active March 12, 2025 12:59
bash script to read cache sizes on my macbook
#!/bin/bash
# Description:
# Use this script to compair cache sizes before you manually reboot or clear the caches.
# This script displays cache sizes for various directories, including VS Code and user/system caches.
# It helps identify large cache directories, particularly in the user's Library/Caches folder.
#
# Usage:
# ./cache-sizes.sh - Shows VS Code and system cache sizes, skips detailed user cache scan.
# ./cache-sizes.sh --all - Shows VS Code, system, and detailed user cache sizes, including top large directories.
# ./cache-sizes.sh -a - Same as --all (shorthand).
@emrysr
emrysr / get_db.sh
Last active February 26, 2025 07:49
utility to backup database locally. ssh into test server, run pg_dump and save locally
#!/usr/bin/env bash
# Get the pg_dump file for a given project database and streams it back locally.
# Saves locally to: $OUTDIR/$filename
#
# Description: This script performs a backup of the specified project's database
# using PostgreSQL's pg_dump utility. It can operate in two modes:
# 1. With a specified project name as an argument (Optional)
# 2. Default: Using the PROJECT environment variable
#
# Options:
@emrysr
emrysr / rainbow-bg-stripes
Created February 16, 2023 16:48
sweeeet rainbow stripes background
/* SWEEEET RAINBOW STRIPES BACKGROUND */
background: repeating-linear-gradient(
135deg,
#d50000,
#d50000 20px,
#c51162 20px,
#c51162 40px,
#aa00ff 40px,
#aa00ff 60px,
#6200ea 60px,
@emrysr
emrysr / supported_timezones.py
Last active May 23, 2022 11:52
get list of daylight saving specific timezones from pytz
import pytz
'''
timezones not in AREA/CITY format dont take into concideration the local daylight savings
so if a user specifies GMT as timezone then it is fixed thoughout the year!
get a reduced list timezone names from pytz.all_timezones that have a AREA/CITY format
'''
def area_timezones():
timezones = set()
for zone in pytz.all_timezones_set:
parts = zone.split('/')
@emrysr
emrysr / ping.py
Last active April 17, 2022 14:48
pings all addresses on local network (255.255.255.0 subnet)
#!/usr/bin/env python3
import socket
import subprocess
import ipaddress
alive = []
def get_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0)
@emrysr
emrysr / xrandr.reset
Created October 24, 2020 12:49
create fixed xrandr output mode
/***
* after sleep, ubuntu 20.04 drops down to 1280:1024 ? unable to choose higher resolution from settings.
* create and set new resolution with script
* @see: https://unix.stackexchange.com/questions/227876/how-to-set-custom-resolution-using-xrandr-when-the-resolution-is-not-available-i
**/
# see current list of output options:
$ xrandr
# read settings for given resolution
# speed app debug on actual device
install `scrcpy` to use your mouse and keyboard on your android device (developer mode)
https://github.com/Genymobile/scrcpy
Creates a window on your linux desktop that show what your phone screen "sees".
Host keyboard, mouse and clipboard availble on device.
Can be linked by usb or ethernet (in docs)
# install
sudo apt install scrcpy
@emrysr
emrysr / mot
Created March 31, 2020 12:51
ascii art your usename on login (~/.profile or motd?)
#!/bin/bash
toilet -f roman -F crop:border $USER | lolcat
@emrysr
emrysr / cleanup-compose
Created March 19, 2020 23:47
clean out docker-compose files before rebuilding and running
$ docker-compose rm -vf && \
docker-compose pull && \
docker-compose build --no-cache && \
docker-compose up --force-recreate --always-recreate-dep
```bash
docker-compose rm -vf && docker-compose pull && docker-compose build --no-cache && docker-compose up --force-recreate --always-recreate-dep
```
@emrysr
emrysr / device mac addresses
Created March 17, 2020 13:21
bash command to list the mac addresses of a device (ignores loopback devce)
```bash
ip address | egrep "^\s+link" | awk '{$1=$1};1' | cut -d' ' -f2 | tail -n+2
```