Skip to content

Instantly share code, notes, and snippets.

(use-package webpaste
:ensure t
:bind (("C-c C-p C-b" . webpaste-paste-buffer)
("C-c C-p C-r" . webpaste-paste-region)
("C-c C-p C-p" . webpaste-paste-buffer-or-region))
;; we can't use github gists, because the creation API requires a token in the header
;; see
;; and open PR:
;; - fast, with (auto?) syntax highlighting, but dark mode
cpbotha / init.el
Last active February 6, 2023 10:45
;; minimal version of my Emacs setup which approximates the effective points per inch on your screen
;; and then selects your default font pts based on that
;; Also works on wayland / WSLg because it parses out physical dims from weston.log (necessary in 2023-01)
;; LIMITATION: Will probably not work on multi-monitor setups. Exercise for the reader!
;; BSD 3-clause copyright Charl P. Botha <>
(defun get-mon-attr (which)
(cdr (assoc which (car (display-monitor-attributes-list)))))
(defun get-monitor-width-mm ()
(use-package mastodon
:ensure t
;; I am on Mastodon which translates to:
(setq mastodon-instance-url "")
(setq mastodon-active-user "cpbotha"))
cpbotha / init.el
Last active January 28, 2022 13:56
;; as of 2021-12-19 with latest master pgtk emacs on non-store WSL I can copy
;; text from other apps into Emacs, but I can't copy text from Emacs into other
;; apps, and so I use this work-around with wl-copy.
;; original value of interprogram-cut-function was gui-select-text.
;; you need to have the wl-clipboard package installed for the wl-copy tool.
;; update 2022-01-28: this work-around still required with WSL
(when (getenv "WAYLAND_DISPLAY")
(lambda (text)
# three changes by Charl Botha to get this building
# on the M1
# 1. use the iains branch of gcc (see head spec)
# 2. change build config to "--build=aarch64-apple-darwin#{osmajor}"
# 3. remove --with-bugurl
# then build with:
# brew install --verbose --build-from-source -head --formula ./libgccjit.rb
# took about 18 minutes on my M1 MBA
name = "stream-manager"
version = "0.0.147"
description = ""
authors = ["David Weber <>", "Janto Dreijer"]
license = "Proprietary"
packages = [
{ include = "server" }
cpbotha / lapingvino_zig_example.nim
Created December 9, 2020 18:35
nim implementation of toy zig example
# two nim-lang solutions based on this reddit thread:
# and this gist:
# -- Charl P. Botha <>
# on this Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz I get:
# with nim 1.4.2 and nim c --gc:orc -d:release:
# {500000002, 2}
cpbotha / guessing_game.nim
Last active November 27, 2020 11:52
cpbotha's nim n00b version of togglebit's guessing game
# guess a number inspired by togglebit!
# this nim version by nim n00b Charl P. Botha
# if I build this with nim 1.4 on ubuntu 20.04 with:
# nim c -d:release --opt:size guessing_game.nim
# the resultant binary is 62 kBytes
import random, strutils
# init random seed
cpbotha / figure.html
Last active February 9, 2024 19:22
Drop-in replacement for Hugo figure shortcode with img srcset support
figure with auto-resizing and srcset v2020-05-10
Drop-in replacement for Hugo's figure shortcode as of 2020-05-02 that uses img srcset
to enable browsers to download only the resolution that they need.
The resizing and srcset magic only works for images that are part of the page
bundle. It will fall back to stock Hugo figure behaviour otherwise.
;; original code
;; made small improvements to ergonomics
;; cpbotha changes:
;; - by default extract files WITHOUT their relative directories into DIR,
;; because that's what I expect in OFMs.
(defun archive-extract-to-file (archive-name item-name command dir keep-relpath)
"Extract ITEM-NAME from ARCHIVE-NAME using COMMAND. Save to
DIR. If KEEP-RELPATH, extract with relative path otherwise don't."