Skip to content

Instantly share code, notes, and snippets.

View mh0w's full-sized avatar
💭
🦆

Matthew Hawkes_ONS mh0w

💭
🦆
View GitHub Profile
@mh0w
mh0w / examples.sh
Last active May 23, 2025 10:29
jfrog jf.exe CLI for artifactory
# Make sure set environment variables [example values in brackets]:
# JF_URL [https://internalurl or https://external-art-url.example.com]
# AND EITHER
# (a) user and password
# JF_USER [my-user-name]
# JF_PASSWORD [MySuperSecretPassword]
# (b)
# JF_ACCESS_TOKEN [my.access-t0ken]
# May also need to download the artifactory certificate to $home/.jfrog/security/certs
@mh0w
mh0w / Enable history navigation in bash terminal (up, down).sh
Created May 2, 2025 08:00
Enable history navigation in bash terminal (up, down)
# Enable matching history navigation in bash terminals
# May need to pip install gnureadline first
# Press up-arrow for previous matching command
# Two bindings as different terminals use different escape chars
bind '"\e[A": history-search-backward'
bind '"\eOA": history-search-backward'
# Press down-arrow for next matching command
# Two bindings as different terminals use different escape chars
@mh0w
mh0w / .bashrc
Created January 28, 2025 16:38
.bashrc
function hello() {
echo "Hello, $1!"
}
function checktimes {
echo "Checking recent start and end times, please wait..."
powershell -Command "& { Invoke-Expression (Get-Content -Raw '//NDATA12/hawkem$/My Documents/WindowsPowerShell/checktimes.txt') }"
}
alias gitt='git -c "http.https://github.com/.extraheader=$GH_AUTH"'
@mh0w
mh0w / Base64 encode powershell command.sh
Last active January 15, 2025 11:25
Base64 encode powershell command
# Examples
powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"Your text goes here - keep the backslashes\"))"
powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"password123\"))"
powershell "[convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes(\"_secret!key?here@\"))"
@mh0w
mh0w / download vs code server files.sh
Last active February 14, 2025 10:27
Download vs code server files
# Taken from https://stackoverflow.com/a/57601121/19532697
# Get your commit id from VS Code's Help tab
commit_id=f06011ac164ae4dc8e753a3fe7f9549844d15e35
# Download url is: https://update.code.visualstudio.com/commit:${commit_id}/server-linux-x64/stable
# The file might be up to about 100MB and thus might take a while to download if speeds are low
curl -sSL "https://update.code.visualstudio.com/commit:${commit_id}/server-linux-x64/stable" -o vscode-server-linux-x64.tar.gz
mkdir -p ~/.vscode-server/bin/${commit_id}
@mh0w
mh0w / .pre-commit-config.yaml
Created December 4, 2024 13:24
Python pre-commit hooks
# Example pre commit hooks
repos:
- repo: local
hooks:
- id: flake8
name: flake8
entry: flake8
stages: [commit]
language: system
types: [python]
@mh0w
mh0w / Note on Dawarich.rb
Created November 25, 2024 19:06
Note on Dawarich
# The Ruby development.rb is located within the Docker container at
# /var/app/config/environments/development.rb
# It's here that the user can configure e.g.
Rails.application.configure do
config.hosts << "my-site-here.app"
end
@mh0w
mh0w / Add git bash to Windows 11 terminal.md
Created October 30, 2024 14:32
Add git bash to Windows 11 terminal

Make sure the git command runs successfully in Command Prompt. It needs to be in the PATH env var.

Update the file profile.json: open Settings by pressing Ctrl+, in Windows Terminal, click on Open JSON file in the sidebar, and add following snippet inside the word profiles:

        { 
            "tabTitle": "Git Bash",
            "acrylicOpacity" : 0.75, 
            "closeOnExit" : true, 
@mh0w
mh0w / Identifying large files in a git repo.sh
Created July 8, 2024 10:30
Identifying large files in a git repo
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
sed -n 's/^blob //p' |
awk '$2 >= 2^20' |
sort --numeric-sort --key=2 |
cut -c 1-12,41- |
$(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
git rev-list HEAD | nl | xargs -n 2 -P 8 sh -c 'git ls-tree -rl "$1" | perl -p -e "\$_ =~ s/[^ ]*+ [^ ]*+ ([^ ]*+) ++([^\t]*+)\t.*+/\1 \2/" | sort > logfile-$0' ; sort -m -u logfile-* | awk '{ sum += $2 } END { print sum }'
@mh0w
mh0w / Add directory to PATH.py
Last active July 8, 2024 15:57
Add directory to PATH
import sys
import os
# Define the path to add to sys.path, such as the current working directory
print(os.getcwd())
path_to_add = os.getcwd()
# Add the path_to_add to the system path
if path_to_add not in sys.path:
sys.path.append(path_to_add)