Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Tietze DivineDominion

View GitHub Profile
@DivineDominion
DivineDominion / 0001-add-mastodon-toot-scheduled-at-buffer-local-variable.patch
Last active November 26, 2022 13:08
Patch to offer post scheduling in Mastodon.el
View 0001-add-mastodon-toot-scheduled-at-buffer-local-variable.patch
From e17e2ecd417864c725fe5f182a25cf3024251263 Mon Sep 17 00:00:00 2001
From: Christian Tietze <ctietze@noreply.codeberg.org>
Date: Sat, 26 Nov 2022 11:07:24 +0000
Subject: [PATCH] add mastodon-toot--scheduled-at buffer-local variable to
optionally schedule posts
---
lisp/mastodon-toot.el | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
@DivineDominion
DivineDominion / JiggleThread.swift
Created November 4, 2022 08:11
Jiggle thread implementation in Swift
View JiggleThread.swift
// Based on an idea from page 188 in:
//
// Robert C. Martin (2009):
// "Clean Code. A Handbook of Agile Software Craftsmanship",
// Upper Saddle River: Prentice Hall.
import Foundation
@inline(__always)
func jiggleThread(minimumDelay: TimeInterval = 0.3, maximumDelay: TimeInterval = 4) {
View 202207041909 AppStorage extension for strongly typed keys.md

202207041909 AppStorage extension for strongly typed keys

#appstorage #swiftui

The @AppStorage property wrapper for observable access to UserDefaults keys is stringified.

To get a strongly typed key access, I oriented myself on the @Environment(\.keyPath) wrapper and my experience with SwiftyUserDefaults and its subscript-based access.

// Use defaultValue from the key:
@AppStorage(\.showOnboarding) var showOnboarding
@DivineDominion
DivineDominion / magit-context-menu.el
Last active March 8, 2022 07:48
Add "Discard", "Stage", and "Unstage" to right-click menu in Magit buffers
View magit-context-menu.el
(require 'magit)
(defun magit-current-section-menu-label ()
"Menu item label for section at point."
(pcase (magit-diff-scope)
('hunk "Hunk")
('hunks "Hunks")
('file "File")
('files "Files")
('module "Module")
View select-tab-macro.el
(defmacro ct/tab-bar-select-action-define (num)
`(defun ,(intern (format "ct/tab-bar-select-%i" num)) ()
,(format "Select tab %i by its absolute number." num)
(interactive)
(tab-bar-select-tab ,num)))
;; Manual calls work
(progn
(ct/tab-bar-select-action-define 1)
(ct/tab-bar-select-action-define 2)
@DivineDominion
DivineDominion / URL+resolvedAgainstBase.swift
Last active January 31, 2022 10:37
Given two file path URLs, determine the shortest relative path to get from one to the other, e.g. `../../folder/file.txt`
View URL+resolvedAgainstBase.swift
// Copyright © 2021 Christian Tietze. All rights reserved. Distributed under the MIT License.
import Foundation
extension URL {
/// Produces a relative path to get from `baseURL` to the receiver for use in e.g. labels.
///
/// When there's no common ancestor, e.g. `/tmp/` and `/var/`, then this returns an absolute path. The only exception to this rule is when `baseURL` itself is the root `/`, since tor that base _all_ paths are relative.
///
/// - Returns: Shortest relative path to get from `baseURL` to receiver, e.g. `"../../subdirectory/file.txt"`, and `"."` if both are identical. Absolute path (or absolute URL for non-`file://` URLs) if there's nothing in common.
@DivineDominion
DivineDominion / kramdown_gfm_wikilink.rb
Created April 22, 2021 10:13
Kramdown GFM Parser extension for [[wikilinks]]
View kramdown_gfm_wikilink.rb
@DivineDominion
DivineDominion / convert_dayone_to_org.rb
Last active August 16, 2022 00:22
Convert Day One (macOS) Journal.txt to Emacs org-mode diary/journal — https://christiantietze.de/posts/2020/10/export-day-one-journal-to-org-mode/
View convert_dayone_to_org.rb
#!/usr/bin/env ruby
#
# convert_dayone_to_org.rb
# Copyright © 2020 Christian Tietze. All rights reserved. Distributed under the MIT License.
#
# Converts a Day One plain text export (Journal.txt) into org-mode journal format. It does
# - Markdown image conversion from ![](thepath.jpg) to [[thepath.jpg]]
# - Extraction of images from the front of an entry; moves it right after the property drawer.
# - Creation of nested year/month/day date sections (see example below)
#
@DivineDominion
DivineDominion / html-entity-insert.el
Last active July 30, 2020 09:14
Emacs lisp function to select a HTML entity from a filterable list and insert it at point. Based on Based on code by @emacs_gifs from https://emacsgifs.github.io/html-entities-helper
View html-entity-insert.el
;; Licensed under GNU/GPL. https://emacsgifs.github.io/html-entities-helper
(defun ct/html-entity-insert ()
"Select and insert an html entity.
Uses the list from https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references."
(interactive)
(defvar _html-entity-list
'("char: \" entity: &quot; text: quotation mark (APL quote)"
"char: & entity: &amp; text: ampersand"
"char: ' entity: &apos; text: apostrophe (apostrophe-quote); see below"
"char: < entity: &lt; text: less-than sign"
View About the gradual processing of thoughts while talking.md

About the gradual processing of thoughts while talking

If you want to know something and cannot find it through meditation, I advise you, my dear, meaningful friend, to talk about it with your nearest acquaintance, who will be upsetting you. It does not have to be a sharp-thinking head, nor do I mean it as if you should ask him about it: no! Rather, you should tell him yourself first of all. I see your eyes wide open, and you answer me that in your early years you were advised to speak of nothing but things you already understand. Others, I want you to speak out of a reasonable intention to instruct you, and so, in different cases, both rules of wisdom may well coexist. The Frenchman says, l'appétit vient en mangeant, and this principle of experience remains true if you parody it, and says, l'idee vient en parlant.

I often sit at my business table above the files and, in a complicated dispute, I explore the point of view from which it would like to be judged. I usually look into the light, as the brightest