Skip to content

Instantly share code, notes, and snippets.

View drench's full-sized avatar

Daniel Rench drench

View GitHub Profile
@drench
drench / string-succ.test.js
Created March 10, 2024 13:41
A generator that works something like Ruby's `String#succ` (for lowercase strings only)
// Run with jest
const succ = function * (string) {
const matchResult = string.match(/^([a-z]*)([a-z])$/);
if (matchResult) {
const prefix = matchResult[1];
const last_char = matchResult[2];
if (last_char == 'z') {
yield arguments.callee(prefix).next().value + 'a';
@drench
drench / blossom-cheat.rb
Created October 14, 2023 11:45
Blossom Cheat
#!/usr/bin/env ruby
# This helps suggest words for Blossom
# https://www.merriam-webster.com/games/blossom-word-game
#
# The script takes 2 arguments: a string of "petal" letters, and the center letter.
#
# For example, if the petals are N E O L A T and the the center is P, run:
#
# ./blossom-cheat.rb neolat p
@drench
drench / twitter-extras.user.js
Created September 4, 2022 16:23
twitter extras userscript
// ==UserScript==
// @name Twitter Extras
// @description Tweaks for Twitter Dot Com
// @include /^https://twitter.com/
// @run-at document-idle
// ==/UserScript==
if (document.querySelector('head meta[property="og:type"][content="profile"]')) {
let url = new URL(document.querySelector('head meta[property="og:url"]').content);
let username = url.pathname.replace(/^\//, "");
@drench
drench / woof.js
Created August 23, 2022 11:39
A *dle "helper"
#!/usr/bin/env node
"use strict";
const repl = require('node:repl');
const util = require('node:util');
const octordle_dictionary = [
"aahed",
"aalii",
Wordle 589 3/6
⬜⬜⬜⬜🟨
🟨🟨⬜⬜⬜
🟩🟩🟩🟩🟩
Wordle 588 4/6
⬜⬜⬜⬜⬜
🟨🟨⬜⬜🟨
// ==UserScript==
// @name Bandcamp Collection Extras
// @description Adds extras to Bandcamp collection pages
// @grant unsafeWindow
// @match https://bandcamp.com/*
// @run-at document-idle
// @version 1.0.0
// ==/UserScript==
class BandCampCollection {
@drench
drench / loser
Last active June 12, 2020 21:36
loser: a socat-based web server
#!/bin/sh
# loser: a socat-based web server
log() {
>&2 echo $*
}
print_http_response() {
printf "HTTP/1.0 $1\r\n"
printf "Content-type: $2; charset=utf-8\r\n\r\n"
@drench
drench / findagrave-extras.user.js
Last active February 8, 2024 14:45
FindAGrave Extras userscript
// ==UserScript==
// @name FindAGrave Extras
// @description Adds links to FindAGrave pages
// @include /^https://www.findagrave.com/memorial/[0-9]+//
// @run-at document-idle
// ==/UserScript==
class FindAGraveMemorial {
constructor(fg, doc) {
try { this.findagrave = fg() } catch(e) { }
@drench
drench / discogs-extras.user.js
Last active May 12, 2020 04:40
Discogs Search Extras userscript
// ==UserScript==
// @name Discogs Extras
// @description Adds search links to Discogs pages and more
// @include https://www.discogs.com/*
// ==/UserScript==
class SearchSite {
constructor(doc) {
this.doc = doc;
}
@drench
drench / rubydoc-version-switcher.user.js
Last active December 27, 2022 20:30
A userscript to add a version switcher to ruby-doc.org
// ==UserScript==
// @name Ruby Doc Extras
// @description Adds a version-switcher widget and other extras to ruby-doc.org
// @include https://ruby-doc.org/core-*
// @include https://ruby-doc.org/stdlib-*
// @run-at document-idle
// ==/UserScript==
class RubyDocExtras {
static setupClasses = [];