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 / $profile
Last active February 22, 2025 17:56
PowerShell $profile which automatically updates in the background when a new version number appears in this gist.
# Version 1.7.0
$gistUrl = "https://api.github.com/gists/81e7d1be5e7302c281ccc9b04134949e"
$gistFileName = '$profile' # Change this to match the filename in your Gist
$checkInterval = 4 # Check for updates every 4 hours
$updateCheckFile = [System.IO.Path]::Combine($HOME, ".profile_update_check")
$versionRegEx = "# Version (?<version>\d+\.\d+\.\d+)"
$localProfilePath = $Profile.CurrentUserCurrentHost
# Last update check timestamp
@eggbean
eggbean / add_vim_to_path.ps1
Last active September 24, 2024 01:42
PowerShell script to make a persistent symlink to Vim for Windows and add it to $PATH
# Jason Gomez - June 2024
# Problem 1: When installing Vim for Windows using winget it's not added
# to $PATH so it cannot easily be used from the command line.
# Problem 2: The path to the Vim executables keeps changing as the
# version number is part of the path.
# Solution: This script makes a persistent symlink to the latest installed
# version of Vim for Windows and adds it to $PATH. Re-run the
# script when a new version of Vim is installed.
# Get all Vim directories and sort them by version number
@eggbean
eggbean / install_scoop.ps1
Last active February 19, 2025 16:13
PowerShell script to install scoop for multi-users and install packages that I use.
# PowerShell script to install scoop for multi-user and packages.
# If re-run when scoop is already installed, any additional packages
# are installed and shims are reset in order of the package list.
# I prefer to keep user and global packages as the same, so there's
# a minor inconvenience in some situations where packages will
# be listed twice with global commands.
#
# To avoid git ownership warnings, read this:
# https://stackoverflow.com/a/71904131/140872
# git config --global --add safe.directory "*" (double quotes on Windows)
@eggbean
eggbean / install_golang.sh
Last active October 1, 2024 09:36
Script for automated installation or updating Go. For Linux and macOS, x86_64, arm64 and arm.
#!/bin/bash -e
# This script installs or updates to the latest version of Go.
# Multi-platform (Linux and macOS)
# Multi-architecture (amd64, arm64, arm) support
#
# Add to your .profile, .bash_profile or .zshenv:
# export PATH=$PATH:/usr/local/go/bin
error_string=("Error: This command has to be run with superuser"
@eggbean
eggbean / install_getssl.sh
Last active April 25, 2024 09:56
Script for automated installation or updating the latest version of getssl (https://github.com/srvrco/getssl) using the binary packages. For Debian and RHEL-based systems.
#!/bin/bash
error_string=("Error: This command has to be run with superuser"
"privileges (under the root user on most systems).")
if [[ $(id -u) -ne 0 ]]; then echo "${error_string[@]}" >&2; exit 1; fi
eval "$(. /etc/os-release && typeset -p ID)"
if [[ $ID =~ ^(debian|ubuntu)$ ]]; then
pkg=deb
apt-get update
@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
}
@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 / 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 / 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 / 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"