Skip to content

Instantly share code, notes, and snippets.

View joshbode's full-sized avatar

Josh Bode joshbode

  • Melbourne, Victoria, Australia
View GitHub Profile
@joshbode
joshbode / README.md
Last active January 5, 2023 00:42
Split Logging Output using `splitvt`

Split logging output using splitvt

@joshbode
joshbode / README.md
Last active September 14, 2022 02:02
Picture-in-Picture (PiP) Bookmarklet

Bookmarklet to enable picture-in-picture controls for Firefox in Google Meet, and other sites that disable PiP

Create a new bookmark with the following "URL":

javascript:(function() {var i, elements = document.querySelectorAll("body video"); for (i = 0; i < elements.length; i++) {elements[i].style.pointerEvents = "all"}})()

Note: this embeds the following function:

function() {
@joshbode
joshbode / multipass.zsh
Created July 18, 2022 12:32
Fix multipass Bash completion to work with ZSH
MULTIPASS="/snap/multipass/current/etc/bash_completion.d/snap.multipass"
if [[ -e "${MULTIPASS}" ]]; then
source <(
sed \
-e '/_get_comp_words_by_ref/d' \
-e 's^\$(echo \${BASH_VERSION} | .*)^0^' \
"${MULTIPASS}"
)
fi
@joshbode
joshbode / foo.sh
Last active June 6, 2020 06:50
Mozilla Flatpak Wayland
flatpak override --user
--env=MOZ_ENABLE_WAYLAND=1 --env=MOZ_WEBRENDER=1 --env=MOZ_USE_XINPUT2=1 \
--socket=wayland \
org.mozilla.firefox
flatpak info --show-permissions org.mozilla.firefox
FROM python:3.8
# ...
ADD entrypoint.sh /usr/local/bin
ENTRYPOINT ["bash"]
CMD ["-l"]
@joshbode
joshbode / fetch.sh
Last active April 29, 2020 10:46
Fetch URL without curl/wget (good for Docker)
python -c "import shutil, sys, requests; x = requests.get(sys.argv[1], stream=True); shutil.copyfileobj(x.raw, (sys.stdout if x.ok else sys.stderr).buffer); sys.exit(not x.ok)" https://httpbin.org/get | jq .
@joshbode
joshbode / logging.py
Last active January 15, 2024 13:39
Colour Logging - Works in Jupyter Lab/Notebook
import sys
import logging
from typing import Optional, Dict
from colorama import Fore, Back, Style
class ColoredFormatter(logging.Formatter):
"""Colored log formatter."""
@joshbode
joshbode / mem.sh
Created December 15, 2017 23:18
Track Memory usage
function track_mem {
while (( 1 )); do
echo -en "$(date --iso-8601=s)\t"
ps -eo comm,pid,pmem,rss,vsz | grep "^$1"
sleep $2
done
}
@joshbode
joshbode / gzip.jl
Created May 11, 2017 15:54
TextParse Support for GZip
using GZip
MAX_WIDTH = 4
function Base.filesize(io::GZip.GZipStream)
f = open(io.name, "r")
seekend(f)
skip(f, -4)
n = Int64(first(reinterpret(Int32, read(f, 4))))
close(f)
Modules = [CallTest]