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 / 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 = ""
@marcus-crane
marcus-crane / routes.go
Created June 16, 2021 01:49
Fiber golang example of showing child routes a la Django Rest Framework (could be improved)
package routes
import (
"sort"
"strings"
"github.com/gofiber/fiber/v2"
)
func Register(app *fiber.App) *fiber.App {
@marcus-crane
marcus-crane / radarr_tag_netflix.py
Created May 27, 2021 09:59
A hacky script for tagging films in Radarr that can be streamed on Netflix
from justwatch import JustWatch
from pyarr import RadarrAPIv3
client = JustWatch(country='NZ') # change to your country code
BASE_URL = 'http://192.168.1.100:7878'
API_KEY = '<api_key_here>'
FILMS_ON_NETFLIX = {}
radarr = RadarrAPIv3(BASE_URL, API_KEY)
@marcus-crane
marcus-crane / delete-firefox-devices.py
Created April 27, 2021 06:16
A python script for bulk deleting old devices
"""
Roughly based off https://gist.github.com/gbaman/b3137e18c739e0cf98539bf4ec4366ad
To grab your access token, log into https://accounts.firefox.com/settings
Open your browser dev tools (Right click -> Inspect Element), go to the Network tab
and refresh the page to populate the network stream.
Click on any one of the POST requests to https://graphql.accounts.firefox.com/graphql
and then under the Request Headers portion (at the bottom of the Headers tab),
copy the value for the Authorization Header. Just the token, not the Bearer text itself.
@marcus-crane
marcus-crane / convert.py
Created March 31, 2021 06:26
A small script used for changing Maildir message creation date to match date within the email itself
from mailbox import MaildirMessage
import time
from datetime import datetime
import os
from glob import glob
files = glob("*")
def update_mod_date(directory):
with open(directory, 'r') as f: