Skip to content

Instantly share code, notes, and snippets.

@cpbotha
cpbotha / nginx.conf
Created November 28, 2024 12:11
forward yourdomain/bsky including optional post URL part to bluesky
location ~ ^/bsky(/.*)?$ {
return 302 https://bsky.app/profile/charlbotha.com$1;
}
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 2
---
title: "{{title}}"
{% if date %}year: {{date | format("YYYY")}}{% endif %}
authors: {{authors}}{{directors}}
tags: 
  - zotero 
---

{{ bibliography }}

(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))
:config
;; we can't use github gists, because the creation API requires a token in the header
;; see https://docs.github.com/en/rest/gists/gists?apiVersion=2022-11-28#create-a-gist
;; and open PR: https://github.com/etu/webpaste.el/pull/57
;; - dpaste.org fast, with (auto?) syntax highlighting, but dark mode
@cpbotha
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 <[email protected]>
(defun get-mon-attr (which)
(cdr (assoc which (car (display-monitor-attributes-list)))))
(defun get-monitor-width-mm ()
(use-package mastodon
:ensure t
:config
;; I am @[email protected] on Mastodon which translates to:
(setq mastodon-instance-url "https://emacs.ch")
(setq mastodon-active-user "cpbotha"))
@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 0.51.2.0
(when (getenv "WAYLAND_DISPLAY")
(setq
interprogram-cut-function
(lambda (text)
# three changes by Charl Botha https://github.com/cpbotha 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
[tool.poetry]
name = "stream-manager"
version = "0.0.147"
description = ""
authors = ["David Weber <[email protected]>", "Janto Dreijer [email protected]"]
license = "Proprietary"
packages = [
{ include = "server" }
]
@cpbotha
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:
# https://old.reddit.com/r/Zig/comments/k9q0vi/append_to_slice_in_zig/
# and this gist:
# https://gist.github.com/LaPingvino/57fb1c0afaacdb1185f247db2b365102
# -- Charl P. Botha <https://charlbotha.com/>
# 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
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! https://www.twitch.tv/togglebit
# this nim version by nim n00b Charl P. Botha https://charlbotha.com/
# 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
randomize()