Skip to content

Instantly share code, notes, and snippets.

@tkurtbond
tkurtbond / sllist.adb
Created April 16, 2024 20:31
Singly linked list implementation
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
procedure SLList is
function "+" (Source : in String)
return Unbounded_String renames To_Unbounded_String;
type Node;
type Node_Ref is access Node;
type Node is record
@tkurtbond
tkurtbond / sllist.fs
Last active April 16, 2024 21:44
Singly Linked List implementation in forth using gforth's structs.
\ sllist.fs - Singly Linked List implementation in forth using gforth's structs.
\G A node contains the address of the next node and the address of a
\G counted string.
struct
cell% field node-text \ address of counted string
cell% field node-next \ address of next node
end-struct node%
\G Initialize a node given the address of a counted string and the
@tkurtbond
tkurtbond / sllist-less-comments.fs
Last active April 16, 2024 21:50
Singly Linked List implementation using gforth's structs, less commented
\ sllist-less-comments.fs - Singly Linked List implementation in forth using gforth's structs, less comments.
struct
cell% field node-text \ address of counted string
cell% field node-next \ address of next node
end-struct node%
: node-init ( text-addr next-addr node-addr -- ) tuck node-next ! node-text ! ;
: node-type ( node-addr -- ) node-text @ count type ;
@tkurtbond
tkurtbond / git-commit-fill-nobreak-predicate.el
Last active February 14, 2024 18:30
Don't want the first line of a git commit COMMIT_EDITMSG buffer in Emacs to wrap?
(defun tkb-magit-commit-fill-nobreak-p ()
"Don't fill on the first line of a magit commit message."
(= 1 (line-number-at-pos)))
(defun tkb-magit-commit-find-file-hook ()
(interactive)
(when (string-match "COMMIT_EDITMSG\\'" (buffer-file-name))
(make-local-variable 'fill-nobreak-predicate)
(add-to-list 'fill-nobreak-predicate #'tkb-magit-commit-fill-nobreak-p)))
;; Using add-to-list without specifying APPEND didn't work because
@tkurtbond
tkurtbond / tkb-wayland-bell.el
Created January 21, 2024 20:20
Set emacs up to ring the bell using an external program under Wayland, since the Wayland devs have something against the traditional bell supplied by Xbell.
(when (getenv "WAYLAND_DISPLAY")
(message "Running under Wayland")
(defvar tkb-beep-sound "/usr/share/sounds/freedesktop/stereo/bell.oga")
(defvar tkb-beep-program "ogg123")
(defun tkb-bell ()
"Ring the bell."
(interactive)
(start-process "Beep" nil tkb-beep-program
tkb-beep-sound))
@tkurtbond
tkurtbond / nikola-metadata-nobreak.el
Last active January 21, 2024 20:05
Don't auto fill metadata lines in Nikola reST files.
;; Nikola metadata lines start like this:
;; .. keyword:
;; They shouldn't be wrapped.
(defvar tkb-nikola-metadata-regexp "\\.\\. [a-z]+:")
(defun tkb-nikola-rest-fill-nobreak-p ()
"Don't fill on metadata lines in nikola reST posts."
(save-excursion
(beginning-of-line)
(looking-at tkb-nikola-metadata-regexp)))
@tkurtbond
tkurtbond / tkb-bell.el
Created December 9, 2023 23:39
Set emacs up to ring the bell using an external program, since the normal beep/bell/ding doesn't seem to work any more.
(defvar tkb-beep-sound "/usr/share/sounds/freedesktop/stereo/bell.oga")
(defvar tkb-beep-program "ogg123")
(defun tkb-bell ()
(interactive)
(start-process "Beep" nil tkb-beep-program
tkb-beep-sound))
(setq ring-bell-function #'tkb-bell)
@tkurtbond
tkurtbond / get-gemini-atom.scm
Last active March 5, 2023 17:04
Download the list of gemini atom feeds from gemini://gemini.circumlunar.space/capcom/submitted-feeds.txt and then download all the feeds.
(module get-gemini-atom ()
(import (scheme))
(import (chicken base))
(import (chicken file))
(import (chicken process-context))
(import (chicken condition))
(import (utf8))
(import args)
@tkurtbond
tkurtbond / indent-cl-symbols.el
Created February 6, 2023 23:27
Make all the cl-* symbols indent properly in emacs lisp
(load-library "cl-indent") ; defines the common-lisp-indent-function properties
(setq lisp-indent-function 'common-lisp-indent-function)
(cl-loop for symbol being the symbols
for cl-indent-rule = (get symbol 'common-lisp-indent-function)
for elisp-equivalent = (intern-soft (concat "cl-" (symbol-name symbol)))
when (and cl-indent-rule elisp-equivalent (fboundp elisp-equivalent))
do (put elisp-equivalent 'common-lisp-indent-function cl-indent-rule))
@tkurtbond
tkurtbond / tkb-select-frame-popup.el
Created February 1, 2023 18:19
Emacs function to popup a menu to select a frame to bring the front.
(defun tkb-select-frame-popup ()
(interactive)
(let* ((frames (cl-loop for frame in (frame-list)
collect (cons (frame-parameter frame 'name)
frame)
into frames finally return frames))
(frame (x-popup-menu t `("Pick a frame" ("frames" ,@frames)))))
(when frame
(raise-frame frame)
(select-frame frame))))