Skip to content

Instantly share code, notes, and snippets.

View mattolenik's full-sized avatar

Matthew Olenik mattolenik

View GitHub Profile
@mattolenik
mattolenik / retraction.gcode
Created March 16, 2024 18:13
Prusa MK3S+ end gcode for filament retraction
M83 ; set to relative
G1 E-6 F900 ; retract 6mm at 15mm/sec
@mattolenik
mattolenik / _boot_camera-streamer_libcamera.conf
Created March 5, 2024 20:57
Pi Cam v2 config for libcamera for octoprint
### Options for libcamera based cameras (PiCam, Arducam, ...)
# The port on which the webcam server for the camera should listen on. If you have only
# one camera, leave at 8080. If you have more, change to 8081, 8082, etc. The primary
# camera will be considered the one with 8080.
PORT=8080
WIDTH=1640
HEIGHT=1232
@mattolenik
mattolenik / fbisadumpsterfire.js
Created February 14, 2023 20:25
Greasemonkey script to hide Facebook ads and BS, tested Feb 2023
// ==UserScript==
// @name Hide "Suggested post" on Facebook
// @include https://www.facebook.com/*
// @grant none
// ==/UserScript==
(function(){
var watcher = function(){
var bs=[...document.querySelectorAll('div[role="main"] div[data-pagelet="FeedUnit_{n}"]')].filter(div => div.innerHTML.includes('Suggested for you')).forEach(el => el.remove())
setTimeout(watcher, 200);
};
@mattolenik
mattolenik / garplythud.txt
Last active July 27, 2022 17:58
Alternatives to fake words like foo and bar
foo
bar
baz
qux
quux
corge
grault
garply
waldo
fred
@mattolenik
mattolenik / Get path of makefile itself
Created June 23, 2021 17:37
Get path of makefile within make, path of file itself, not working dir
MAKEFILE_PATH := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) # Keep at top of file
@mattolenik
mattolenik / git-get-tag-version.sh
Created September 20, 2019 21:39
Retrieve tag/branch/commit
git describe --tags --exact-match 2> /dev/null \
|| git symbolic-ref -q --short HEAD \
|| git rev-parse --short HEAD
@mattolenik
mattolenik / bash_check_version.sh
Created August 29, 2019 19:29
bash function for ensuring bash version meets a certain minimum
# Ensures the shell meets some minimum version, useful when using bash features introduced after a certain release
check_version() {
local reqMajor="$1"
local reqMinor="$2"
local major minor
IFS=. read -r major minor _ <<< "$BASH_VERSION"
if (( major < reqMajor )) || (( major == reqMajor && minor < reqMinor)); then
echo "Bash version $reqMajor.$reqMinor or greater required, found $major.$minor" >&2
return 1
fi
@mattolenik
mattolenik / tmuxx.sh
Created December 18, 2018 22:02
Single command to create/join a tmux session
# Creates/joins a shared session using session groups (-t option).
# This simplifies making a shared group. Just invoke tmuxx from anywhere
# and it'll always join to the same, shared session.
#
# Parameters:
# $1 the name of the session group, defaults to 'main'
tmuxx () {
local session="${1:-main}"
tmux new-session -t "$session"
}
@mattolenik
mattolenik / get_named_arg.sh
Last active September 16, 2018 01:04
Looks for "named arguments" in an array, which take the form key=value
# Searches for a named argument in the form of "key=value".
# Returns the value associated with the key.
#
get_named_arg() {
local key="$1"
local default="${2:-}"
shift 2
for pair in "$@"; do
if [[ $pair =~ ^([^=]+)=([^=]*)$ ]] && [[ ${BASH_REMATCH[1]} == "$key" ]]; then
printf %s "${BASH_REMATCH[2]}"
@mattolenik
mattolenik / trapadd.sh
Created September 12, 2018 16:03
bash trap add
# From https://stackoverflow.com/questions/3338030/multiple-bash-traps-for-the-same-signal
# note: printf is used instead of echo to avoid backslash
# processing and to properly handle values that begin with a '-'.
log() { printf '%s\n' "$*"; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$@"; exit 1; }
# appends a command to a trap
#