Skip to content

Instantly share code, notes, and snippets.

View krabs-github's full-sized avatar

Krabs krabs-github

View GitHub Profile
@krabs-github
krabs-github / Batch Convert to MP3 with ffmpeg.txt
Created March 10, 2022 13:47
Batch Convert to MP3 with ffmpeg #Linux
for i in *.wav; do ffmpeg -i "$i" -f mp3 "${i%}.mp3"; done
@krabs-github
krabs-github / Batch - Get Windows Recycle Bin Size.bat
Created December 20, 2021 11:44
[Batch - Get Windows Recycle Bin Size] Batch - Get Windows Recycle Bin Size #Batch
DIR /S %SYSTEMDRIVE%\$RECYCLE.BIN | FINDSTR /C:File(s)
@krabs-github
krabs-github / JavaScript - Open, Close, and Move Windows.js
Last active December 20, 2021 11:45
[JavaScript - Open, Close, and Move Windows] JavaScript - Open, Close, and Move Windows #JavaScript
var myWindow = window.open("http://google.com","myWindow");
// opens SO in the same window
window.open("http://stackoverflow.com","myWindow");
// the following will only work if it's the same domain, else subject to SOP -
// so in the case of initially opening it with google, this won't work!
myWindow.document.location.href = "/example/test.html";
// closes your window
myWindow.close();
@krabs-github
krabs-github / VBS - Set VBScript to Run at Startup.vbs
Last active December 20, 2021 11:45
[VBS - Set VBScript to Run at Startup] VBS - Set VBScript to Run at Startup #VBScript
schtasks /create /sc ONLOGON /tn "name" /tr "cscript.exe C:\path\to\your.vbs"
schtasks /create /sc onstart /tn "name" /tr "cscript.exe C:\path\to\your.vbs" /ru SYSTEM
https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/schtasks-create
@krabs-github
krabs-github / JavaScript - Set Interval and Clear Interval for Stream Deck Template.js
Last active December 20, 2021 11:45
[JavaScript - Set Interval and Clear Interval for Stream Deck Template] JavaScript - Set Interval and Clear Intervals for Stream Deck Template #JavaScript
// Declare globally
var vKrabs_Intervals = {};
// Functions
let vKrabs_IntervalID = JSON.stringify(jsn.context);
function startInterval(func, time) {
vKrabs_Intervals[vKrabs_IntervalID] = setInterval(func, time);
}
function stopInterval() {
@krabs-github
krabs-github / JavaScript Clear All Intervals.js
Last active May 18, 2024 13:01
[JavaScript - Clear All Intervals] JavaScript Clear All Intervals #JavaScript
// Get a reference to the last interval + 1
const interval_id = window.setInterval(function(){}, Number.MAX_SAFE_INTEGER);
// Clear any timeout/interval up to that id
for (let i = 1; i < interval_id; i++) {
window.clearInterval(i);
}
@krabs-github
krabs-github / JavaScript - Crop an Image With Canvas.js
Last active December 20, 2021 12:30
[JavaScript - Crop an Image With Canvas] JavaScript - Crop an Image With Canvas #JavaScript
const image = new Image(),
canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d');
image.src = 'https://i.stack.imgur.com/I4jXc.png';
image.addEventListener('load', () => {
ctx.drawImage(image,
70, 20, // Start at 70/20 pixels from the left and the top of the image (crop),
50, 50, // "Get" a `50 * 50` (w * h) area from the source image (crop),
@krabs-github
krabs-github / MacOS bring window to front.md
Last active December 20, 2021 12:39
[MacOS bring window to front] MacOS bring window to front #Discord
  • Create an AppleScript as follows (e.g., in /Users/[username]/activate_chrome.scpt:
tell application "Google Chrome"
    reopen
    activate
end tell

Use the Stream Deck "System" > "Open" action with the following in the "App/File" Field:

osascript /Users//activate_chrome.scpt
@krabs-github
krabs-github / JavaScript - Determine if Hex Color is Light or Dark.js
Last active October 8, 2024 10:31
[JavaScript - Determine if Hex Color is Light or Dark] JavaScript - Determine if Hex Color is Light or Dark #JavaScript
function lightOrDark(color) {
// Check the format of the color, HEX or RGB?
if (color.match(/^rgb/)) {
// If HEX --> store the red, green, blue values in separate variables
color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
r = color[1];
g = color[2];
@krabs-github
krabs-github / Windows Variables.md
Last active February 9, 2024 19:04
[Windows Variables] Windows Variables #Windows

Windows 10+ default environment variables

VARIABLE WINDOWS 10
%ALLUSERSPROFILE% C:\ProgramData
%APPDATA% C:\Users{username}\AppData\Roaming
%COMMONPROGRAMFILES% C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files
%CommonProgramW6432% C:\Program Files\Common Files
%COMSPEC% C:\Windows\System32\cmd.exe