Skip to content

Instantly share code, notes, and snippets.

View mh0w's full-sized avatar
💭
🦆

Matthew Hawkes_ONS mh0w

💭
🦆
View GitHub Profile
@mh0w
mh0w / bash.sh
Last active August 22, 2025 15:55
GCP Cloud Shell Editor (ephemeral) - creating a venv with a specific python version
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.10
sudo apt install python3.10-venv
# You can then use Python interpreter /bin/python3.10
@mh0w
mh0w / settings.json.md
Last active September 19, 2025 18:14
VSCode settings.json

Problem: cannot use GitHub CoPilot in ssh remote sessions.

Solution: add this to .vscode/settings.json (e.g. on the remote server)

"remote.extensionKind": {
        "GitHub.copilot": [
            "ui"
        ],
        "GitHub.copilot-chat": [
            "ui"
@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 matching history navigation in bash terminal (type one or more characters and then hit up or down).sh
Last active November 1, 2025 14:55
Enable matching history navigation in bash terminal (type one or more characters and then hit 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 August 19, 2025 10:58
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
# Optional: use -k to disable ssl certificate check requirement
curl -sSL "https://update.code.visualstudio.com/commit:${commit_id}/server-linux-x64/stable" -o vscode-server-linux-x64.tar.gz
@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,