Skip to content

Instantly share code, notes, and snippets.

View dnnsmnstrr's full-sized avatar
:shipit:

Dennis Muensterer dnnsmnstrr

:shipit:
View GitHub Profile
@dnnsmnstrr
dnnsmnstrr / wiki-table-scraper.js
Last active February 6, 2024 15:19
Wiki Table Scraper
(function() {
const table = document.querySelector('.wikitable'); // Adjust the selector if needed
if (!table) {
console.log('Table not found.');
return;
}
const rows = table.querySelectorAll('tr');
const data = Array.from(rows).slice(1).map(row => {
const cells = row.querySelectorAll('td');
@dnnsmnstrr
dnnsmnstrr / replaceEmoji.js
Last active April 23, 2023 12:49
A text formatter that replaces text with matching emoji
function format(text) {
const emojimap = {
"❤️": "love",
"😂": "laughing",
"😍": "awesome",
"👍": "great",
"😭": "crying",
"😊": "smiling",
"😘": "kiss",
"🔥": "fire",
[
"Show us the weirdest thing you have in the room with you right now.",
"There is a free, round-trip shuttle to Mars. The catch: it will take one year of your life to go, visit, and come back. Are you in?",
"What is your least favorite thing about technology?",
"What superpower would you most want?",
"What food is best with cheese?",
"Would you go in the mother-ship with aliens if they landed on Earth tomorrow?",
"Would you join a community in space if it was permanent?",
"Would you rather live 100 years in the past or 100 years in the future?",
"You are the best criminal mastermind in the world. What crime would you commit if you knew you would get away with it?",
@dnnsmnstrr
dnnsmnstrr / trashplan.js
Created March 11, 2023 14:03
Helper to figure out the schedule for who was responsible to bring out the trash in which week
const parties = [
'Herr Freitag',
'Frau Samstag',
'WG'
]
console.log(parties.length)
const START_WEEK = 6
@dnnsmnstrr
dnnsmnstrr / advent.js
Created March 11, 2023 13:29
Prototype code for advent calendar
const schema = {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/advent.json",
"title": "Advent Calendar",
"description": "A calendar for the Advent season",
"type": "object",
"properties": {
"title": {
"description": "The title of the calendar",
"type": "string"
@dnnsmnstrr
dnnsmnstrr / showHUD.js
Created February 28, 2023 13:18
Helper function to show HUD in BTT with JavaScript
function showHUD(text, icon, duration = 3) {
const hudConfig = {
BTTActionHUDHideWhenOtherHUDAppears: true,
BTTActionHUDDetail: text,
BTTIconConfigSFSymbolName: icon,
BTTActionHUDDuration: duration,
BTTActionHUDSlideDirection: 0,
BTTIconConfigImageHeight: 50,
BTTActionHUDTitle: "",
BTTIconConfigIconType: 2,
@dnnsmnstrr
dnnsmnstrr / free-ram.applescript
Last active February 27, 2023 11:44
Free RAM on macOS
display dialog "Free inactive RAM?" buttons {"Cancel", "OK"} with icon 2 with title "Freeing RAM" default button 2
set buttonAnswer to the button returned of the resul
if buttonAnswer is "ОК" then
say "Freeing RAM. Wait please."
tell application "Terminal"
do shell script "purge"
quit
end tell
say "Done!"
end if
@dnnsmnstrr
dnnsmnstrr / spotifyUri.js
Last active April 23, 2023 11:54
PastePal transform Spotify URL to URI
function transform(clip) {
const pathRegex = /^[a-z]+:\/\/[^:\/]+(:[0-9]+)?\/(.*?)(\/[0-9]+)?(\?.*)?$/
const uriPath = clip.text.replace(pathRegex, '$2');
const spotifyUri = "spotify:" + uriPath.replaceAll('/', ':')
return spotifyUri;
}
@dnnsmnstrr
dnnsmnstrr / gitlabAPI.js
Created January 21, 2023 02:29
A scriptable module to interface with the gitlab api
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: magic;
/**
* Keychain key for GitLab url and personal access token.
*/
const GITLAB_ACCESS_TOKEN_KEY = "gitlab.widget.accessToken";
const GITLAB_URL_KEY = "gitlab.widget.url";
@dnnsmnstrr
dnnsmnstrr / 8ball.txt
Last active February 27, 2023 11:46
8ball responses
No chance.
Odds aren't good...
Not now.
Ask again later.
Don’t count on it
Outlook not so good
My sources say no
Very doubtful
My reply is no
Possibly maybe!