Skip to content

Instantly share code, notes, and snippets.

View marcus-crane's full-sized avatar
💭
Online and logged on

Marcus Crane marcus-crane

💭
Online and logged on
View GitHub Profile
@marcus-crane
marcus-crane / popclipmemos.py
Created April 30, 2025 23:40
A Popclip script for sending selected text to a Memos (https://github.com/usememos/memos) server
# #popclip
# { name: Memos, icon: iconify:si:memory-fill, after: show-result, interpreter: python3 }
import json
import os
import urllib.request
print(os.environ)
payload = {
"state": "NORMAL",
@marcus-crane
marcus-crane / ddprom.py
Created April 30, 2025 23:38
A small Prometheus Exporter that exposes DownDetector statuses
import time
from bs4 import BeautifulSoup
from prometheus_client import start_http_server, Gauge
import requests
ga = Gauge('anomalies', 'A description', ['category', 'site'])
ga_categories = ['telecom', 'finance', 'online-services', 'social-media', 'gaming']
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'}
@marcus-crane
marcus-crane / skip_ia.js
Created April 1, 2025 04:59
A small JS one-liner used to unmark Internet Archive MP4s in Transmission. Some archives will have original files and then secondary, generated files that include `.ia` in the name.
Array.from(document.querySelectorAll('.inspector-torrent-file-list-entry')).filter(e => e.children[1].textContent.includes('ia')).forEach(e => e.checkbox.click())
@marcus-crane
marcus-crane / diarium.py
Last active April 30, 2025 23:41
A small Python script to convert Diarium JSON export to the format I use in Obsidian
# Prereqs: pip install pendulum markdownify
import json
from string import Template
from markdownify import markdownify as md
import pendulum
with open("diary.json", "r") as file:
data = json.loads(file.read())
@marcus-crane
marcus-crane / nginx.conf
Created July 18, 2023 23:42
Basic nginx file that contains all possible log parameters in JSON format
worker_processes 2;
user www-data;
events {
use epoll;
worker_connections 128;
}
error_log /dev/stdout info;
@marcus-crane
marcus-crane / flatten.py
Created May 22, 2023 23:13
A handy script used to convert Logstash testcases from a nested object to flat keys
import glob
import json
import flatdict
tests = glob.glob('logstash/testcases/*.json')
for test in tests:
print(test)
with open(test, 'r') as file:
@marcus-crane
marcus-crane / youtube.js
Created May 8, 2022 11:57
Obsidian script for creating a note with a YouTube video embed in it
async function youtube (tp) {
const url = await tp.system.clipboard()
const response = await fetch(`https://youtube.com/oembed?url=${url}&format=json`)
const data = await response.json()
const title = data.title.replaceAll("", "").replaceAll('"', '').replaceAll("\\", "").replaceAll("/", "").replaceAll("<", "").replaceAll(">", "").replaceAll(":", "").replaceAll("|", "").replaceAll("?", "")
tp.file.rename(title)
const regex = /v=(.*)/gm;
const m = regex.exec(url)
return m[1]
}
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
name: artist-web
description: The place to be, for great artists
labels:
example.com/custom: custom_label_value
annotations:
example.com/service-discovery: artistweb
circleci.com/project-slug: github/example-org/artist-website
This file has been truncated, but you can view the full file.
{
" Vigilante 8 (PSX) (gamerip) ": "/game-soundtracks/album/vigilante-8-original-game-rip",
"#killallzombies (2016) (PC)": "/game-soundtracks/album/killallzombies-2016-pc",
"'96 Zenkoku Koukou Soccer Senshuken (1996) (SNES)": "/game-soundtracks/album/96-zenkoku-koukou-soccer-senshuken-1996-snes",
"007 - NightFire (2002) (PS2) (gamerip)": "/game-soundtracks/album/007-nightfire-2002-ps2",
"007 - NightFire (2002) (Xbox) (gamerip)": "/game-soundtracks/album/007-nightfire-2002-xbox",
"007 - Nightfire (2002) (GC) (gamerip)": "/game-soundtracks/album/007-nightfire-2002-gc",
"007 - Quantum of Solace (2008) (NDS) (gamerip)": "/game-soundtracks/album/007-quantum-of-solace-2008-nds-gamerip",
"1-2 Switch (2017) (Switch)": "/game-soundtracks/album/1-2-switch-2017-switch",
"10 Second Run RETURNS (Switch)": "/game-soundtracks/album/10-second-run-returns-switch",
@marcus-crane
marcus-crane / wordle.js
Last active December 26, 2021 03:14
A small devtools sketch for reflecting the Daily Wordle grid as a group of emojis
let tiles = []
document.querySelector("game-app").$board.querySelectorAll("game-row").forEach(row => {
let rowTiles = []
row.$tiles.forEach(tile => rowTiles.push(tile._state))
tiles.push(rowTiles)
})
for (let row of tiles) {
let rowString = ""