Skip to content

Instantly share code, notes, and snippets.

View BenMcLean's full-sized avatar

Benjamin McLean BenMcLean

View GitHub Profile
@BenMcLean
BenMcLean / compress-scans.bat
Created August 15, 2021 23:42
Compress Scans
@echo off
cd %~dp0
setlocal
setlocal enabledelayedexpansion
@echo off
for /d /r %%i in (Scans.) do (
@if exist "%%i" (
@set _scans=%%i
@echo !_scans!
cd %%i\..
@BenMcLean
BenMcLean / email.ps1
Created June 9, 2021 22:40
Extract email addresses from text with PowerShell
Set-Clipboard -Value ((Get-Clipboard) | Select-String "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|""(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*"")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])" -AllMatches).Matches.Value
$set(_year,$left($if2(%originaldate%,%date%),4))
$replace(
$replace(
$if(_year,%_year% )
%album%
$if($and(%releasetype%,$not($find(%releasetype%,album))), \(%releasetype%\))
\($if2(%albumartist%,%artist%)\)
$if($eq($upper(%_extension%),MP3),, $upper(%_extension%))
/
$if($gt(%totaldiscs%,1),$if(%discsubtitle%,CD$num(%discnumber%,$len(%totaldiscs%)) %discsubtitle%/)$num(%discnumber%,$len(%totaldiscs%))-,)
@BenMcLean
BenMcLean / KnockOutKitMaker.bat
Last active June 22, 2023 07:33
Teenage Engineering PO-33 Pocket Operator KO Sampler/Sequencer Kit Maker
@ECHO ON
cd %~dp0
set /a missing=F
if "%~2" == "" (
set missing=T
) else (
if "%~1" == "" ( set missing=T )
)
if "%missing%" == "T" (
echo At least two input files must be specified.
@BenMcLean
BenMcLean / audible.bat
Last active July 13, 2022 15:03
Strip DRM from Audible purchases using https://github.com/inAudible-NG/tables
@ECHO OFF
cd %~dp0
ffmpeg -activation_bytes BYTES_GO_HERE -i %1 -vn -c:a copy "%~n1.mp4"
ren "%~n1.mp4" "%~n1.m4b"
@PAUSE
// Pixelated font shader by lox9973
// It is a cutout shader, using alpha blending for 1 pixel antialiasing on the edges.
// Intended use is "3D Text" on an opaque object like a sign.
Shader "UI/PixelFont" {
Properties {
_MainTex ("Font Texture", 2D) = "white" {}
_Color ("Text Color", Color) = (1,1,1,1)
}
SubShader {
// Below Transparent queue. Renders after the skybox, but writes to depth.
@BenMcLean
BenMcLean / compress-3ds.bat
Last active March 15, 2024 13:34
7-zip batch
@ECHO OFF
cd %~dp0
for /R %%F in (*.3ds) do ( "c:\Program Files\7-Zip\7z.exe" a "%%F.7z" "%%F" & if not errorlevel 1 del "%%F" )
@PAUSE
@BenMcLean
BenMcLean / unskraper.bat
Last active May 27, 2022 15:17
RetroPie EmulationStation Menu Item Names Un-Skraper a.k.a. the Anti-Scraper
@ECHO OFF
cd %~dp0
python.exe %~dpn0.py %1 %2 %3 %4 %5 %6 %7 %8
@BenMcLean
BenMcLean / lolwut.cpp
Last active September 28, 2020 21:19
Simple data structure that encapsulates an array in C++
#include <iostream>
using namespace std;
template <class T>
class lolwut // a lolwut is a simple encapsulated array
{
public:
lolwut() : data(NULL), size(0)
{
@BenMcLean
BenMcLean / get-state.bat
Last active July 27, 2019 18:17
Oculus Quest ADB stuff
@ECHO OFF
c:
cd %APPDATA%
cd ..\Local\Android\Sdk\platform-tools
adb get-state