Skip to content

Instantly share code, notes, and snippets.

@solace
solace / auth.setup.ts
Last active December 13, 2025 14:52
Generate test Supabase tokens and cookies
import {test as setup} from 'next/experimental/testmode/playwright/msw';
import {uuid} from '@supabase/supabase-js/dist/main/lib/helpers';
import path from 'path';
import {createSupabaseCookie} from 'testing-supabase';
const authFile = path.join(__dirname, '.auth/user.json');
setup('authenticate', async ({page}) => {
await page.context().addCookies([
@solace
solace / lucky.md
Last active February 26, 2025 05:35
Create an "I'm feeling lucky" command to surface old notes in Obsidian

%% NOTE: Remove code fences. They were added for gist rendering purposes. %%

<%*
dv = app.plugins.plugins.dataview.api;
function lucky() {
        const threshold = dv.date('now') - dv.duration('14 days');
        const list = dv.pages().where(p => {
                if (p["se-last-reviewed"]) {
                        const lastReviewed = p["se-last-reviewed"].toString().slice(0, 10);
 return dv.date(lastReviewed) &lt; threshold;
@solace
solace / handlers.ts
Last active February 19, 2025 12:11
next.js 15 playwright testmode onFetch wrapper
const AUTH_USER_ENDPOINT = /\/auth\/v1\/user/;
export const userRemote = (email: string) => ({
method: 'GET',
route: AUTH_USER_ENDPOINT,
response: {
data: {
id: 'uuid',
email,
role: 'authenticated',
@solace
solace / migration.py
Created November 6, 2020 14:00
Django: Add Permissions to Groups during Migration
# YMMV
from django.conf import settings
from django.contrib.auth.models import Group, Permission
from django.core.management.sql import emit_post_migrate_signal
from django.db import migrations, models
import django.db.models.deletion
import logging
@solace
solace / tumblr-webclipper.js
Last active July 8, 2024 04:13
A bookmarklet to clip Tumblr posts
javascript:navigator.clipboard.write([new ClipboardItem({ ["text/html"]: new Blob([`---<br />created: "${new Date().toISOString()}"<br />published: "${document.querySelector('time').dateTime}"<br />authors: ${document.querySelector('a[rel="author"]').text}<br />url: ${window.location}<br /><br />---<br /><br /># ${document.querySelector('link[type="application/json+oembed"]').title} <br /><br />` + document.querySelectorAll(`[data-id="${window.location.pathname.match(/(\d+)/)[1]}"] article > div`)[0].outerHTML.replace(/srcset="(.*?)"/g, (matcher,p1) => { const last = p1.split(/\s*,\s*/).pop(); return `src="${last.split(/\s+/)[0]}"`})], {type: 'text/html'})})]).then(() => console.log('Copied to clipboard'));
@solace
solace / batch_yarle.sh
Created June 27, 2024 14:56
Run yarle on nested stacks of Evernote enex notebooks
#!/bin/bash
# Source: https://www.baeldung.com/linux/bash-expand-relative-path
resolve_relative_path() (
# If the path is a directory, we just need to 'cd' into it and print the new path.
if [ -d "$1" ]; then
cd "$1" || return 1
pwd
# If the path points to anything else, like a file or FIFO
elif [ -e "$1" ]; then
@solace
solace / GistTransformer.ts
Last active May 16, 2024 03:49
Replace gist links in markdown with an embed using remark in Next.js
const GistTransformer = {
name: 'Gist',
shouldTransform(url) {
const {host} = new URL(url);
return ['gist.github.com'].includes(host);
},
getHTML(link) {
const url = new URL(link);
const id = url.pathname.split('/').pop();
@solace
solace / gist:0ea7c761ff448a0f3aa5c7a35a7de278
Created April 6, 2020 05:04
Import FileZilla Bookmarks to Cyberduck
# From https://trac.cyberduck.io/ticket/7317
#
# Should do it automatically, if it doesn't, check if ~/.config/filezilla/sitemanager.xml exists.
# If it doesn't, create the directory, and
cp ~/.filezilla/sitemanager.xml ~/.config/filezilla/sitemanager.xml
defaults delete ch.sudo.cyberduck bookmark.import.de.filezilla
# Relaunch Cyberduck
@solace
solace / deepgram2autoedit.sh
Created November 3, 2022 15:32
Convert deepgram JSON to autoEdit transcript JSON
# WARNING: This is not a complete script.
# You could update the hardcoded values, but practically, it will need to
# be modified to programmatically process your source files and append the
# result to the autoEdit transcripts.json array.
# This is the internal autoEdit project ID.
# Once you've created the project in autoEdit you can get the ID from
# /path/to/digital-paper-edit-electron/db/projects.json
# on macOS this is /Users/username/Library/Application Support/digital-paper-edit-electron
project_id="1234567890"
@solace
solace / ShowNotes.tsx
Last active December 27, 2023 17:05
Interactive transcripts with YouTube and Descript. See https://askmeaboutmypodcast.substack.com/p/interactive-transcripts-with-youtube
export default function ShowNotes({ transcript, seekTo }) {
const headings = transcript.filter((entry) => 'heading' in entry && entry.heading);
return (
<ul>
{headings.map((heading, ix) =>
<li
key={`timeline-${ix}`}
role="button"
data-start={heading.start}