Skip to content

Instantly share code, notes, and snippets.

View eggbean's full-sized avatar

Jason Gomez eggbean

  • London, United Kingdom
View GitHub Profile
@eggbean
eggbean / eza-wrapper.sh
Last active February 23, 2025 23:08
Now moving from exa to eza fork. Wrapper script to give it nearly identical switches and appearance to ls. Also automatically adds --git switch when in a git repository.
#!/bin/bash
## Change following to '0' for output to be like ls and '1' for eza features
# Don't list implied . and .. by default with -a
dot=0
# Show human readable file sizes by default
hru=1
# Show file sizes in decimal (1KB=1000 bytes) as opposed to binary units (1KiB=1024 bytes)
meb=0
# Don't show group column
@eggbean
eggbean / dynu.sh
Last active December 19, 2024 11:16
Secure dynu.com dynamic IP update script using OAuth2 authentication
#!/bin/bash
# dynu.com dynamic IP update script
# variables can be added in file, in sourced file or as command line arguments
set -e
# https://www.dynu.com/en-US/ControlPanel/APICredentials
# oauth2='{Client-Id}:{Secret}'
oauth2='EOJ2S-Z6OoN_le_KS1d75wsZ6y0SFdVsY9183IvxFyZp:EClusMEUk8e9ihI7ZdVLF5cZ6y0SFdVsY9183IvxFyZp'
// ==UserScript==
// @name Twitter Go Back with H key
// @namespace https://gist.github.com/eggbean/ba4daf82f132421c69dbd2c2e0b3e061/raw/twitter_go_back.user.js
// @version 1.1
// @description Makes the unused H key a browser back button for better H,J,K,L keyboard navigation
// @author https://github.com/eggbean
// @match https://x.com/*
// @icon https://x.com/favicon.ico
// @grant none
// ==/UserScript==
@eggbean
eggbean / install_awscliv2.sh
Last active October 26, 2024 09:46
Script to install or update AWS CLI v2 on Linux/WSL (x86_64 and aarch64 supported). Can be used in ansible or bootstrap script.
#!/bin/bash
# AWS CLI v2 install/update script
# For v2 you either need to install manually
# or use a script like this
#
# For bash v5 >
#
# For auto-completion add `cli_auto_prompt = on` to config
# ..or add AWS_CLI_AUTO_PROMPT=on environment variable
@eggbean
eggbean / kernel_update_check.sh
Last active June 6, 2023 05:13
Bash snippet to determine if the kernel has been updated, requiring a reboot. Tested on Debian and RHEL-based systems. If you put it in your .bashrc, surround it with (parentheses) so that it runs in a subshell, or execute it as a separate script, as otherwise it would change your nullglob shell option and current directory if sourced.
#!/bin/bash
cd /boot || exit 1
shopt -s nullglob ; for file in config-* ; do kernels+=( "${file#config-}" ) ; done
newest="$(printf '%s\n' "${kernels[@]}" | sort -V -t - -k 1,2 | tail -n1)"
current="$(uname -r)"
[[ $current != $newest ]] && echo "Reboot needed for new kernel"
@eggbean
eggbean / vimium-options.json
Last active August 15, 2023 04:47
Vimium partial site exclusions so that the native keybindings can be used. Granular exclusions for GitHub which still allow vimium keys on pages which benefit from them. `:%s/eggbean/YOURUSERNAME/'`. Use with the essential 'web search navigator' Firefox/Chrome extension.
{
"settingsVersion": "1.67.4",
"exclusionRules": [
{
"pattern": "^https?://www.google.com/(?!maps)*",
"passKeys": "/abcdefhijklmnopqrsuvwyz"
},
{
"pattern": "^https?://mail.google.com/*",
"passKeys": "#/?cdegijklprsux"
@eggbean
eggbean / AltGr-to-Alt-and-PrtSc-to-Context-Menu.reg
Created July 3, 2023 12:10
Windows registry key to change PrtSc key to Context Menu key and AltGr to Alt (you can still Ctrl+Alt to get the same function as AltGr. This is useful for ThinkPad users in the UK in particular.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,5d,e0,37,e0,38,00,38,e0,\
00,00,00,00
@eggbean
eggbean / oci-fupdate
Last active November 3, 2023 00:01
Firewall Network Security Group update script for Oracle Cloud. Good for remote working or for use as cron job for people with dynamic IP addresses at home.
#!/bin/bash
# Oracle firewall update script
# Usage: oci-fupdate [ <source-CIDR> ] [ --query ]
#
# Updates an existing Network Security Group to allow SSH access through the OCI
# firewall to reach instances in a public subnet, like bastion hosts. With no
# argument your current public IP address is used, or you can add a source address
# block in CIDR format. The --query option returns the current source address.
#
@eggbean
eggbean / install_nginx.sh
Last active April 25, 2024 09:56
Script to install nginx from nginx repository. I use it to make images for auto-scaling instances.
#!/bin/bash
# Installs nginx from nginx repository (not distro repo)
#
# Usage: sudo ./install_nginx.sh [ --stable ]
# --stable option: Use stable channel instead of mainline
#
# Currently supported:
# RHEL
# CentOS
@eggbean
eggbean / windirstat-add-context-menu.ps1
Last active December 9, 2024 17:17
WinDirStat PowerShell script or registry file to add context menu entries to open on drives or folder, with a little icon. No longer needed with WinDirStat v2.
# Adds shell integration for WinDirStat. The program should be installed in
# Program Files (x86) but it will check if that directory is not on C:
#
# Alternatively, if installed on C: you can use the reg file below instead.
if (-not ([security.principal.windowsprincipal][security.principal.windowsidentity]::getcurrent()).isinrole([security.principal.windowsbuiltinrole]::administrator)) {
write-error "this script needs to be run as an administrator. please restart powershell as an administrator and try again."
exit
}