Skip to content

Instantly share code, notes, and snippets.

View brlodi's full-sized avatar

Benjamin Lodi brlodi

View GitHub Profile
@brlodi
brlodi / !README.md
Last active August 22, 2023 20:13
Rich git diffs for images on the command line

If you use a terminal emulator that supports imgcat (most commonly and famously iTerm 2 implements it), drop this script into your path and add the attached snippet to your .gitignore to generate visual diffs in your Git commandline.

Derived from https://til.hashrocket.com/posts/n44hnf0z99-show-better-image-diff-on-git

Prerequisites

  • Image-capable terminal emulator
  • imgcat implementation for your emulator in your path
  • GraphicksMagick available in your path (an ImageMagick clone, minus the security flaws)
@brlodi
brlodi / autoclose-zoom-launch-meeting-tabs.js
Created February 24, 2023 18:52
A userscript to clean up those annoying "Launch Meeting" tabs Zoom likes to open. I'm not positive I've captured every path variation Zoom uses so let me know if you find one that doesn't work.
// ==UserScript==
// @name Autoclose Zoom Launch Meeting windows
// @namespace Violentmonkey Scripts
// @match https://*.zoom.us/j/*
// @match https://*.zoom.us/s/*
// @grant window.close
// @version 1.0
// @author Benjamin Lodi <brlodi@gmail.com>
// @description 2/24/2023, 12:47:07 PM
// ==/UserScript==
@brlodi
brlodi / bi_fix_multires.fish
Created October 13, 2021 02:16
When Blue Iris writes exported clips that switch between the substream and main stream, they're just streams of frames with varying resolutions. Most video players don't like that, because they expect all frames of a video to be the same size. This intelligently reencodes such videos *only if needed* so they can be consumed by other software.
function bi_fix_multires
function _get_frames_info -a f field_name
ffprobe -hide_banner -skip_frame nokey -show_frames -show_entries frame=$field_name $f 2>/dev/null | awk -F'=' "/$field_name/{print \$2}"
end
function _get_stream_info -a f field_name
ffprobe -hide_banner -show_entries stream=$field_name $f 2>/dev/null | awk -F'=' "/$field_name/{print \$2}"
end
set --local files (du $argv | sort -n | awk '{print $2}')
@brlodi
brlodi / fix_hevc_tags.sh
Last active February 2, 2021 19:25
macOS and iOS have native support for HEVC video, but only with hvc1 tagging instead of hev1 tagging. This snippet "fixes" it "in place" without reencoding anything, so it's almost instant. I use it to make direct-to-disk recordings from my CCTV cameras playable in browser/QuickTime/QuickLook without needing VLC.
#!/bin/sh
ffmpeg -i "$1" -codec copy -tag:v hvc1 -f mp4 "$1.tmp" && mv -f "$1.tmp" "$1"
@brlodi
brlodi / base16_ansi.vim
Created March 12, 2020 21:39
A pure-ANSI colorscheme for VIM, designed to leverage the excellent Base16 colors you've already defined for your terminal. No more mismatched Vim and terminal colors!
" A pure-ANSI colorscheme for VIM, designed to leverage the excellent Base16
" colors you've already defined for your terminal emulator or via base16-shell.
" No more mismatched Vim and terminal colors!
"
" Author: Benjamin Lodi <brlodi@gmail.com>
"
" WARNING: This *will* look terrible without Base16 terminal colors, which map
" various shades of grey to many of the bright color points.
" WARNING: iTerm 2 users, make sure you're using a base16-*.dark.itermcolors
" file, even if you have a light theme.
@brlodi
brlodi / fish_prompt.fish
Created October 8, 2019 20:15
A WIP snapshot of a native-fish Powerline style prompt I was toying with. Not done by any means, but saving for posterity while I explore alternatives
# Color reference
# fish_color_normal, the default color
# fish_color_command, the color for commands
# fish_color_quote, the color for quoted blocks of text
# fish_color_redirection, the color for IO redirections
# fish_color_end, the color for process separators like ';' and '&'
# fish_color_error, the color used to highlight potential errors
# fish_color_param, the color for regular command parameters
# fish_color_comment, the color used for code comments
# fish_color_match, the color used to highlight matching parenthesis
@brlodi
brlodi / _scss-color-range-generator.md
Last active February 14, 2024 14:30
A set of Sass functions to automatically create Material Design-style color ranges, for when you don't want to have to manually spec out a full set of shades and tints for every color in your design.

About

These functions use one or two 'base' colors to automatically generate a color range similar to Material Design's color ranges. Useful to quickly get different shades of your primary brand color or accent color, or to generate a set of neutrals between hand-selected light and dark colors.

Usage

$greens: make-shades(#cc99cc);
// (
//   100: #eeddee,
// 200: #ddbbdd,