Skip to content

Instantly share code, notes, and snippets.

View ArnoldsK's full-sized avatar
✌️

Arnolds Kļavenieks ArnoldsK

✌️
  • Ubiquiti
  • Latvia
View GitHub Profile
@ArnoldsK
ArnoldsK / crop-to-content.ts
Last active September 16, 2024 10:21
Use Node canvas to crop to image non-transparent content, or return the content rect
import { createCanvas, loadImage } from "@napi-rs/canvas"
import fs from "fs"
const ALPHA_THRESHOLD = 255 * 0.1 // 1%
const cropImageToContent = async (src: string, newSrc: string) => {
const canvas = createCanvas(256, 256)
const ctx = canvas.getContext("2d")
const img = await loadImage(src)
@ArnoldsK
ArnoldsK / PoETotalMTXPointsCost.user.js
Last active September 13, 2024 22:48
Counts total MTX points spent in Path of Exile (https://www.pathofexile.com/my-account/microtransactions)
// ==UserScript==
// @name PoE total MTX points cost
// @namespace https://arnoldsk.lv/
// @version 2024-08-09
// @description Counts total MTX points spent in Path of Exile
// @author ArnoldsK
// @match https://*.pathofexile.com/my-account/microtransactions*
// @icon https://www.google.com/s2/favicons?sz=64&domain=pathofexile.com
// @grant none
// ==/UserScript==
@ArnoldsK
ArnoldsK / fix-70mai-videos-audio.sh
Last active March 24, 2022 16:20
70mai lite format fix
#!/bin/bash
# Fix the audio
for FILE in *; do
if [[ $FILE == *.MP4 ]]; then
NEWFILE=$(shuf -zer -n10 {A..Z} {a..z} {0..9})
echo "Working on ${FILE}..."
ffmpeg -v error -i $FILE -c:v libx264 -crf 22 "${NEWFILE}-audio-fix.mp4"
@ArnoldsK
ArnoldsK / instagram-media.user.js
Last active December 20, 2020 00:09
Display all Instagram image sizes
// ==UserScript==
// @name Instagram media
// @namespace https://arnoldsk.lv/
// @version 0.1
// @description small images? cringe
// @author ArnoldsK
// @match https://www.instagram.com/*
// @grant none
// ==/UserScript==
@ArnoldsK
ArnoldsK / reduce_video_file_size.sh
Last active January 21, 2024 10:42
Bash script for reducing a file size of a video using ffmpeg to reduce bitrate
#!/bin/bash
# Usage:
# ~$ sh reduce_video_file_size.sh [./input.mp4] [size mb] [./output.mp4]
# Parameters can be preset or set by providing none
# Input and output names must end with ".mp4"
# Can use Git Bash to run the script on Windows
display_help() {
local FILE=`basename "$0"`