Skip to content

Instantly share code, notes, and snippets.

View BenMcLean's full-sized avatar

Benjamin McLean BenMcLean

View GitHub Profile
@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))
$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%))-,)
$num(%tracknumber%,$if($gt($len(%totaltracks%),2),$len(%totaltracks%),2)) %title%
$if($find(%albumartist%,Various), \(%artist%\))
@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
@BenMcLean
BenMcLean / 3dify-REDHydrogenOneDownmix.bat
Last active May 27, 2022 15:18
Uses https://ffmpeg.org/ to tag a video file as being SBS 3D. Just drag+drop the video file onto this batch file in same folder with ffmpeg.exe
@ECHO OFF
cd %~dp0
ffmpeg.exe -i "%~1" -c:v copy -c:a aac -af "pan=stereo|FL=0.5*FC+0.707*FL+0.707*BL+0.5*LFE|FR=0.5*FC+0.707*FR+0.707*BR+0.5*LFE,volume=1.660156" -metadata:s:v:0 stereo_mode=1 "%~n1_half_2x1.mp4"
echo Output file is: "%~n1_half_2x1.mp4"
@PAUSE