Skip to content

Instantly share code, notes, and snippets.

View jmduke's full-sized avatar
🏠

Justin Duke jmduke

🏠
View GitHub Profile
@jmduke
jmduke / test.ts
Created April 17, 2024 13:52
Basic test to check for internal links
const extractInternalLinks = (content: string): string[] => {
// Check for internal links only, in the form of [text](/path).
const internalLinks = content.match(/\[.*?\]\(\/.*?\)/g);
return (
(internalLinks
?.map((link) => {
const path = link.match(/\(\/.*?\)/)
? link.match(/\(\/.*?\)/)![0].slice(2, -1)
: null;
@jmduke
jmduke / generate_urls.py
Created October 26, 2022 15:42
Typescript-friendly replacement for `django-js-reverse`
from dataclasses import dataclass
from django.template.loader import render_to_string
from django.urls import URLResolver, get_resolver
@dataclass
class Route:
name: str
params: list[str]
<div class="newsletter-header">
<!--header-->
</div>
<div class="newsletter-body">
<!--body-->
</div>
<hr />
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Your Emburse verification code is {{Code}}.</Say>
</Response>
@jmduke
jmduke / gist:c4ad2a0d6745d23e4e9bbdc2afc9cd90
Created April 30, 2018 01:49
Commonplace Book Template
<head>
<title>Justin's Notebook</title>
<link rel="icon shortcut" href="date:image/png">
<link href="https://fonts.googleapis.com/css?family=Karla:400,400i,700,700i" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<meta charset="UTF-8">
<style>
body {
background: #fffff3;
color: #566270;
from typing import Iterable
from airtable import airtable
# Don't know what Airtable is? It's basically Excel for developers.
# It's super cool.
# Check it out: airtable.com
table = airtable.Airtable('API_KEY', 'OTHER_KEY')
# Okay, so we want to fetch all results in a table. Problem is, you know, pagination:
@jmduke
jmduke / tinyletter_archiver.py
Created January 2, 2018 19:53
Tinyletter Archiver
from datetime import datetime
import requests
from bs4 import BeautifulSoup
# FILL THIS IN!
tinyletter_username = 'your_username_here'
url = "http://tinyletter.com/{}/archive?recs=100&sort=desc&q=".format(tinyletter_username)
[{"pk":881,"name":"More Life","content_object":{"id":643,"name":"More Life","content_type_id":14,"image_url":"https://i.scdn.co/image/974010663ebd1e267ac11de88e07647eefbfa19d","musician":"Drake","spotify_url":"https://open.spotify.com/album/1lXY618HWkwYKJWBRYR4MK","pitchfork_url":"http://pitchfork.com/reviews/albums/21599-life-of-pause/","release_year":2017},"content_type":14,"is_completed":true,"creation_date":"2017-03-20T15:48:22.205504Z","rating":3,"text":"Knocks against it:\n\n1. 80 minutes is thirty minutes too long. This album (or *playlist*, or whatever) does not need 22 tracks.\n2. Drake still has nothing new or particularly interesting to say.\n3. Something vaguely icky about stealing Jamaican slang. (Then again, I defend *Graceland*.)\n\nKnocks for it:\n\n1. Some legitimately great songs (Passionfruit, 4422.)\n2. Much more pleasant than *Views*.","days_since_completion":0},{"pk":588,"name":"Big Night","content_object":{"id":170,"name":"Big Night","description":"A failing Italian restaurant run by

Jakob Egger, who created a number of great apps that I use daily (like Postgres.app and Postico) wrote a post entitled Subscription Pricing is for Stagnating Products:

The one thing I don’t understand is why smaller companies are also trying to switch to subscriptions? Are they also suffering from a stagnating user base, and hoping to increase their bottom line? If that is the case, they are doomed — subscription pricing will only diminish their user base even faster, and won’t fix the underlying problems that led to a lack of growth in the first place.

It’s easy to see where Jakob is coming from: he’s done very well with his paid up-front model for his apps.

However, Jakob’s (much deserved!) success in his pricing model does not translate to definitive proof that paid up-front apps are the way to go.

Instead, subscription models, while not necessarily *absolut

from Queue import Queue
from threading import Thread, active_count
import pytumblr
import sys
import time
import logging
client = pytumblr.TumblrRestClient(
'FILLINYOUROWNDAMNVALUES',
'FILLINYOUROWNDAMNVALUES',