Skip to content

Instantly share code, notes, and snippets.


Michał "phoe" Herda phoe

View GitHub Profile
phoe / sbcl-private-package.lisp
Created Jan 26, 2022
List all SBCL packages, private, and public ones
View sbcl-private-package.lisp
(defun starts-with (string substring)
(let ((length (length substring)))
(and (<= length (length string))
(string= (subseq string 0 length) substring))))
(defun list-all-sbcl-packages ()
(flet ((sbcl-package-p (package)
(starts-with (package-name package) "SB-")))
(remove-if-not #'sbcl-package-p (list-all-packages))))
phoe /
Last active Apr 18, 2022
Forever Stable Branch

Forever Stable Branch

Stable branch, I can see you in the stable branch
See you again, I see you again
In my dreams, in my dreams, in my dreams, in my dreams

Morning light, I remember the morning li-i-i-i-ight
Outside my door (outside my door), I'll see you no more (see you no more)
In my dreams, in my dreams, in my dreams, in my dreams

phoe /
Last active May 5, 2021
Dear GitHub Trust and Safety Team
phoe /
Last active May 5, 2021
Dear GitHub Trust and Safety Team
phoe /
Last active Apr 11, 2022
Package-local nicknames in Common Lisp - a semishitpost about PLNs

Package-local nicknames in Common Lisp

Warning: this is a rant.

Warning: you have been warned.

Note: actually worthwhile content starts in the second subsection. You are free to skip the first one.

Story time

phoe / arcturus-glossary.json
Last active May 14, 2020
Arcturus riichi mahjong glossary in JSON format - plus tiles, plus standard and nonstandard yaku and yakumans
View arcturus-glossary.json
"romaji": "Agari",
"kanji": "和がり",
"english": "Win",
"explanation": "Generic call for winning a hand."
"romaji": "Agaripai",
"kanji": "和がり牌",
"english": "Winning tile",
phoe / format-float-junk.lisp
Last active Nov 21, 2019
fix for CCL's floating point fuckery - code adapted from SBCL
View format-float-junk.lisp
;; Do not use - a proper fix was committed into my fork at phoe-trash/ccl.
(defconstant single-float-min-e
(- 2 ccl::ieee-single-float-bias ccl::ieee-single-float-digits))
(defconstant double-float-min-e
(- 2 ccl::ieee-double-float-bias ccl::ieee-double-float-digits))
;; TODO: maybe-inline %flonum-to-digits, we don't need the indirection
(declaim (inline %flonum-to-digits))
(defun %flonum-to-digits (char-fun
phoe /
Last active Feb 7, 2020
loop return value

So recently a religious debate intense discussion happened on #lisp about whether the following form:

;; Form 1
(loop for i from 1 to 5 finally (return i))

should return 5 or 6 (or, in other words, (1+ 5) - this notation is important as it will be used later).

I argue that it is invalid for it to return 6 and 5 must be returned instead.

phoe / pzmq-router-dealer.lisp
Created May 24, 2019
ZeroMQ pzmq sample router/dealer in Common Lisp
View pzmq-router-dealer.lisp
;; modified from pzmq examples
(defun hwclient (&optional (server-address "tcp://localhost:5555"))
"Translation of updated for ZMQ 3.
Includes some parameters in with-* macros to demonstrate syntax."
(pzmq:with-context (ctx :max-sockets 10)
(pzmq:with-socket (requester ctx) (:dealer :affinity 3 :linger 100)
;; linger is important in case of (keyboard) interrupt;
;; see
(pzmq:connect requester server-address)
phoe / lu-decomposition.lisp
Created Nov 14, 2018
LU decomposition in portable Common Lisp
View lu-decomposition.lisp
;;; Matrix utilities.
(defun matrix= (matrix-1 matrix-2)
(destructuring-bind (m1y m1x) (array-dimensions matrix-1)
(destructuring-bind (m2y m2x) (array-dimensions matrix-2)
(and (= m1y m2y)
(= m1x m2x)
(loop for y below m1y
always (loop for x below m1x
always (= (aref matrix-1 y x)