Skip to content

Instantly share code, notes, and snippets.

@onebytegone
onebytegone / image-compare.sh
Created November 2, 2023 12:11
Imagemagick Image Compare Script
#!/usr/bin/env bash
# Usage: ./image-compare.sh "${URL_A}" "${URL_B}"
# Example: ./image-compare.sh https://placekitten.com/g/200/300 https://placekitten.com/200/300
TMP_DIR=$(mktemp -d)
IMG_A_URL="$1"
IMG_A_FILENAME=$(echo "${IMG_A_URL}" | sed -E 's|^.*/([^/]+)(\?.*)?$|\1|')
IMG_A_EXT=$(echo "${IMG_A_FILENAME}" | sed -E 's|^.*\.(.+)|\1|')
IMG_B_URL="$2"
@onebytegone
onebytegone / disk-speed-test.md
Created December 18, 2021 15:30
Testing Disk Drive Speed Via CLI
cd /tmp
time dd if=/dev/zero bs=2048k of=tstfile count=8192 2>&1 | awk '/sec/ {print $1 / $5 / 1048576, "MB/sec" }'
ls -al tstfile
time dd if=tstfile bs=2048k of=/dev/null count=8192 2>&1 | awk '/sec/ {print $1 / $5 / 1048576, "MB/sec" }'

Note: If the machine has more than 16GB of free RAM, the read speed may be incorrect due to RAM caching.

@onebytegone
onebytegone / manually-level-printrbot.gcode
Created January 26, 2020 19:48
GCode for manually leveling Printrbot Metal Simple
; Set bed and extruder temps
M190 S70
M109 S180
; Home X/Y
G28 X0.00 Y0.00
G1 Y150 X0 Z10 F3000
G30 S-1
G1 Y150 X0 Z10 F3000
@onebytegone
onebytegone / trim-utf8-string-to-bytes.js
Last active September 27, 2019 01:42
Function to trim UTF-8 string to a given number of bytes
const { StringDecoder } = require('string_decoder'),
input = 'abc😧🤕',
length = Buffer.byteLength(input);
function trimToSize(str, byteLength) {
const decoder = new StringDecoder('utf8'),
buffer = new Buffer(str);
return decoder.write(buffer.slice(0, byteLength));
}
@onebytegone
onebytegone / teensy-nkro.md
Created September 19, 2019 21:22
Patch teensyduino for NKRO on Teensy 3.2

Patching teensyduino to support NKRO for Teensy 3.2

  1. Install Arduino IDE

  2. Install teensyduino using its installer

  3. Run the following:

    cd /Applications/Arduino.app/Contents/Java/hardware/teensy
    git init
    git add -A
    
@onebytegone
onebytegone / sync-photo-frame-images.sh
Created September 14, 2019 21:28
Script to pre-process images for a digital photo frame
#!/usr/bin/env bash
set -e
SRC_DIR=$1
DEST_DIR=$2
TMP_DIR=/tmp/photo-frame
if [ -z "${SRC_DIR}" ] || [ -z "${DEST_DIR}" ]; then
echo "Usage: $(basename $0) ./src-dir ./dest-dir"

Keybase proof

I hereby claim:

  • I am onebytegone on github.
  • I am onebytegone (https://keybase.io/onebytegone) on keybase.
  • I have a public key whose fingerprint is 4071 BFAF 2C34 4904 10B1 9C00 3025 37F3 89FE E7DB

To claim this, I am signing this object:

@onebytegone
onebytegone / backup-restore-docker-volume.md
Created November 14, 2018 00:59
Backup and restore a Docker volume on Mac OS X

Backup and restore a Docker volume on Mac OS X

This is a rough draft for backing up and restoring data contained in a Docker volume. I can't say that this is a "best practice". For my limited testing at the moment, it seems sufficient.

Example docker-compose.yml

version: '3'
@onebytegone
onebytegone / datadog-screenboard-aligner.js
Last active June 19, 2018 13:35
Datadog ScreenBoard Grid Aligner
$('.widget').each(function() {
var GRID_SIZE = 12,
el = $(this),
title = el.find('.title_text').text(),
roundToGrid;
roundToGrid = function(value) {
return Math.ceil(value / GRID_SIZE) * GRID_SIZE;
};
@onebytegone
onebytegone / gifize.sh
Created June 8, 2018 15:01
Screen capture video to GIF converter
#!/bin/bash
# usage: ./gifize.sh -x left -y top image.gif
X_POS_LEFT='10'
X_POS_RIGHT='(w-text_w-10)'
Y_POS_TOP='10'
Y_POS_BOTTOM='(h-text_h-10)'
X_POS=$X_POS_LEFT