Skip to content

Instantly share code, notes, and snippets.

@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}
@solace
solace / GistTransformer.ts
Last active December 24, 2023 05:06
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();
// Import this
const modifyToken = require('markdown-it-modify-token');
module.exports = function (config) {
...
// Pass a custom instance of markdownIt into eleventy.
config.setLibrary("md", markdownIt({
// html, breaks, and linkify are default options from eleventy.
html: true,
breaks: true,
@solace
solace / daily_stoic.js
Created December 18, 2023 16:38
Obsidian templater user scripts for QOTD
// https://github.com/benhoneywill/stoic-quotes
async function daily_stoic() {
const res = await fetch(`https://stoic-quotes.com/api/quote`);
const body = await res.json();
return `> [!quote] Daily Stoic\n> ${body.text}\n> — ${body.author}`;
}
module.exports = daily_stoic;
@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 / middleware.ts
Created November 12, 2023 08:58
NextJS middleware to fix "Invalid Refresh Token: Already Used" from supabase
// Requested fix for https://github.com/supabase/gotrue/issues/1290
export async function middleware(req: NextRequest) {
const res = NextResponse.next();
const supabase = createMiddlewareClient({req, res});
const {error} = await supabase.auth.getSession();
// Trying to fix "Invalid Refresh Token: Already Used"
@solace
solace / categories.js
Last active September 23, 2023 08:23
Support categories and tags migrated from WordPress in Eleventy. See https://micheleong.com/2023/09/23/migrate-wordpress-eleventy-colocated-images
// File: lib/collections/categories.js
const slugify = require("slugify");
const getAllKeyValues = require("../utils/getAllKeyValues");
module.exports = (collection) => {
let allCategories = getAllKeyValues(
collection.getFilteredByGlob("src/posts/**/*.md"),
"categories"
@solace
solace / middleware.ts
Created September 10, 2023 13:08
Access pathname in NextJS generateMetadata
import type {NextRequest, NextResponse} from 'next/server'
export async function middleware(req: NextRequest) {
const requestHeaders = new Headers(req.headers)
requestHeaders.set('x-request-url', req.url);
const res = NextResponse.next({
request: {
headers: requestHeaders
}