Skip to content

Instantly share code, notes, and snippets.

View cptSwing's full-sized avatar

Jens cptSwing

View GitHub Profile
@cptSwing
cptSwing / settings.json
Created August 8, 2025 11:27
configure tailwindCSS extension in VSCode to correctly show Intellisense info in strings prefaced with /* 'tw */, among others
"tailwindCSS.experimental.classRegex": [
"\\/\\*\\s*tw\\s*\\*\\/\\s*[`'\"](.*)[`'\"];?", // parse strings following a /* tw */ comment
["(?:\\b(?:const|let)\\s+)?[\\w$_]*(?:[Cc]lass[Nn]ame)[\\w\\d]*\\s*(?:=|\\+=)\\s*['\"]([^'\"]*)['\"]"], // parse strings such as 'testClassName', etc
["classList.(?:add|remove|toggle)\\(([^)]*)\\)", "(?:'|\"|`)([^\"'`]*)(?:'|\"|`)"] // parses DOM manip's, such as classList.add('') etc
],
@cptSwing
cptSwing / MapGoogleDriveToG.bat
Created August 8, 2025 10:48
How I map GoogleDrive to an identical virtual drive on all devices in need, in order to keep filenames/directory paths consistent (3DS Max savefiles, Substance Designer materials, etc etc)
@REM Map Google Drive to G:
@subst G: "C:\Users\<< USER >>\Google Drive Streaming\My Drive"
@REM Show mapped drives
@subst
@REM Show for 10 seconds
@timeout /t 10
@cptSwing
cptSwing / SetDpiValues.bat
Created August 8, 2025 10:46
Set different DPI scaling values for extra monitors attached to a laptop, while keeping the laptop's. Requires "SetDPI" (see link below)
@echo off
@REM path to SetDPI.exe (get from https://github.com/imniko/SetDPI)
set SETDPI_PATH="C:\ProgramData\SetDpi"
@REM How many screens connected?
for /f "delims=" %%a in ('powershell -Command "$m = Get-PnpDevice -Class Monitor -Status OK | measure; $m.Count"') do set "MONITOR_COUNT=%%a"
echo Monitor count : %MONITOR_COUNT%
@cptSwing
cptSwing / Nuke WSL
Created August 8, 2025 10:43
WSL has a tendency to not recover well when booting up a PC from hibernation. Here's how to kill all related processes via CMD.
taskkill /F /FI "IMAGENAME eq wsl.exe"
taskkill /F /FI "IMAGENAME eq wslhost.exe"
taskkill /F /FI "IMAGENAME eq wslservice.exe"
/* eslint-disable no-console */
import { cloneDeep } from 'lodash';
type DevConsoleOptions = {
errorHandlerName?: string;
printStack?: boolean;
clone?: boolean; // clone the argument (to create a snapshot at time of execution) ?
devMode?: boolean; // boolean value to use instead of NODE_ENV
};
@cptSwing
cptSwing / 3dCarousel.tsx
Created August 1, 2022 13:27
3D Carousel using Typescript-React; and mostly Tailwind
/**
* From: https://github.com/suhailsulu/react-carousel-3d ; edited for TS & TW
*/
import { useState, useEffect, useRef } from 'react';
import { useSwipeable } from 'react-swipeable';
import './3dCarouselStyles.css';
interface CarouselProps {
slides:
@cptSwing
cptSwing / powershell_compact_wsl_vhds.ps1
Last active August 8, 2025 10:38
Windows PowerShell script to compact WSL's virtual hd - run PowerShell as admin
# before running, execute Set-ExecutionPolicy RemoteSigned so that your PowerShell will allow it to run
$ErrorActionPreference="Stop"
Write-Host "Cleaning up packages and fstrim - " -NoNewLine
$SUDOSECUREPASSWORD = Read-Host "please enter your sudo password" -AsSecureString
Write-Host ""
# convert to usable String
$SUDOPASSWORD = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SUDOSECUREPASSWORD))
@cptSwing
cptSwing / StrokesPlus Horizontal Scroll
Last active August 8, 2025 10:39
I added this in StrokesPlus as an application only script, and set the gestures to react to middle mouse button, left and right 'swipe'
// last element in array
var lastGesturePointInArray = action.GesturePoints.Length - 1;
// pixels travelled
var distanceTravelled = action.GesturePoints[lastGesturePointInArray].X - action.GesturePoints[0].X;
// Edit if need be:
var horizScrollDist = 1.5;
// turn to absolute num