Skip to content

Instantly share code, notes, and snippets.

View Sv443's full-sized avatar
πŸ³οΈβ€πŸŒˆ

Sven Fehler Sv443

πŸ³οΈβ€πŸŒˆ
View GitHub Profile
@Sv443
Sv443 / Arduino ESP32 C++ Cheat Sheet.md
Last active February 27, 2025 23:18
Arduino ESP32 C++ Cheat Sheet
@Sv443
Sv443 / beacon_heltec_lora_rx.ino
Last active March 2, 2025 02:43
Scripts for transmitting and receiving a string on interval via LoRa and showing the progress on the builtin oled display
// see the file beacon_heltec_lora_tx.ino below for better comments
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#define HELTEC_POWER_BUTTON
// "Heltec ESP32 LoRa v3" by "Rop Gonggrijp" - https://github.com/ropg/Heltec_ESP32_LoRa_v3
#include <heltec_unofficial.h>
#ifndef String
// include Arduino core libs if not already included
@Sv443
Sv443 / esp32_aes_iv_example.ino
Last active February 20, 2025 20:16
ESP32 Arduino - secure AES-GCM key and IV generation and storage example
#include <Preferences.h>
#include <esp_random.h>
#include <mbedtls/sha256.h>
#ifndef String
#include <Arduino.h>
#endif
// set to true to clear the NVS before generating and writing a new key and IV:
#define CLEAR_ALL false
@Sv443
Sv443 / ascii-progress-bar.ts
Last active November 20, 2024 23:13
TypeScript / JavaScript ASCII progress bar function using semi-opaque block characters for extra detail
// Example for 30.7% and length = 14: β–ˆβ–ˆβ–ˆβ–ˆβ–‘β”€β”€β”€β”€β”€β”€β”€β”€β”€
// (to use this in JS, remove the `: type` annotations on line 9)
/**
* Generates an ASCII progress bar with the given percentage and max length - uses opaque characters for extra detail
* @param percentage A number from 0 to 100
* @param barLength The length of the progress bar in characters
*/
function generateAsciiProgressBar(percentage: number, barLength: number) {
const fullBlock = "β–ˆ";
@Sv443
Sv443 / convert_mono.sh
Last active April 21, 2024 22:30
bash script for ffmpeg - convert all .ogg files in current dir to mono .ogg for use in Minecraft resource packs
# - Requires the directory "o" to be created in the same directory as this script, this is where the new files will be created.
# You can then move them to the parent directory and overwrite the old files after you verified the files are good.
# - On Windows, run this with git bash or wsl
# Converts all ogg files in the current directory to mono 64kbps ogg files:
for i in *.ogg; do ffmpeg -i "$i" -c:a libvorbis -b:a 64k -ac 1 -y "o/${i%.*}.ogg"; done
@Sv443
Sv443 / toggle-window-events.user.js
Created June 2, 2023 17:08
Simple userscript that can allow you to toggle any event on the window object on or off
// ==UserScript==
// @name window event toggler
// @namespace https://gist.github.com/Sv443/b2768fdebc8a037fbde4f4df9f7443a2
// @match https://*
// @grant none
// @version 1.0
// @author Sv443
// @license WTFPL
// @run-at document-start
// @connect self
@Sv443
Sv443 / DOMRect visualizer.md
Last active February 13, 2025 11:40
Updated version of @mlewand's DOMRect visualisation
@Sv443
Sv443 / getDiscordServerLocations.js
Last active June 15, 2021 06:51
[Node.js] Get all currently available location IDs and names of the Discord servers
// By Sv443 ( https://github.com/Sv443 ) - licensed under the WTFPL license
//
// !>> To use this, you need to install the package "xmlhttprequest" <<!
// !>> Also, set the environment variable "BOT_TOKEN" to your Discord API token <<!
//
// API reference: https://discordapp.com/developers/docs/resources/voice#list-voice-regions
const { XMLHttpRequest } = require("xmlhttprequest");
@Sv443
Sv443 / gh-actions-publish-npm-and-github.yml
Last active June 15, 2021 07:03
GitHub Actions: Publish to NPM and GitHub Package Registry on created release
# In order for this to work, since GitHub Package Registry likes to be a thorn in your ass, you'll have to follow this guide, otherwise this script will not work:
# https://pastebin.com/f24qc4Wk
#
# >>>> There are two lines that end in four exclamation marks. You will have to enter your usernames there for this script to work.
#
# Author: Sv443
# License: WTFPL (http://www.wtfpl.net/txt/copying/)
name: Publish to NPM and GPR
@Sv443
Sv443 / discord-js-get-all-guild-invites.js
Last active November 13, 2022 12:49
Discord.js - Get all invites from all your bot's guilds - only works with Discord.js v11 or lower!
// only works with Discord.js v11 or lower!
const Discord = require("discord.js");
const dev_ids = ["YOUR_ID(s)_HERE"]; // an array of IDs of the bot's developers - only these people will be able to execute this command
// Note: this snippet requires the variables "client" and "message" to work, these need to be provided by your script