Skip to content

Instantly share code, notes, and snippets.

View phoe's full-sized avatar
🤔
:thonk:

Michał "phoe" Herda phoe

🤔
:thonk:
View GitHub Profile
@phoe
phoe / lu-decomposition.lisp
Created November 14, 2018 23:14
LU decomposition in portable Common 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)
@phoe
phoe / kbmap-lisp
Created October 18, 2018 07:20
Polish Lisp keyboard map - parens and brackets switched
// based on a keyboard map from an 'xkb/symbols/pl' file
default partial alphanumeric_keys
xkb_symbols "basic" {
// Visualisation and description: http://podziemie.net/xkb/pl
// Contact: Michał Górny <zrchos+freedesktop@gmail.com>
include "latin"
@phoe
phoe / ssl.lisp
Created August 30, 2018 19:12
Connect to Furcadia with STARTTLS
(defun ssl-connect () ;; this is a god damn hack
(let* ((socket (usocket:socket-connect "lightbringer.furcadia.com" 80))
(stream (usocket:socket-stream socket)))
(sleep 1)
(loop while (listen stream)
for line = (read-line stream nil stream)
until (eq line stream)
do (format t "S> ~A~%" line))
(format t "C> ~A~%" "starttls")
(format stream "starttls~C~C" #\Return #\Linefeed)
@phoe
phoe / list-otwarty.md
Last active June 26, 2018 16:21
List otwarty do Dziekana WMiI UJ w sprawie artykułów 11 i 13 dyrektywy UE o prawie autorskim

List otwarty

prof. dr hab. Włodzimierz Zwonek
Dziekan Wydziału Matematyki i Informatyki
Uniwersytetu Jagiellońskiego
Łojasiewicza 6
30-348 Kraków

Szanowny Panie Dziekanie,

@phoe
phoe / qtools-ui-drag-and-drop.md
Created February 25, 2018 15:22
Qtools UI drag and drop

Qtools UI - Drag and Drop

This module contains classes implementing drag and drop functionality inside Qtools UI.

Concept

Drag and drop functionality in Qt revolves around MIME types. A single drag can contain data in multiple formats, each of them described by a single MIME type in form of a string.

For simplicity, the mechanism used in this implementation uses only a single MIME type, which, by default, is "application/qtools-mime-data-with-object", being the value of *MIME-DATA-WITH-OBJECT-TYPE*.

@phoe
phoe / thread-pid.lisp
Created February 25, 2018 10:22
Thread PIDs on SBCL on Linux
;; NOTE: absolutely non-portable
* (sb-alien:alien-funcall
(sb-alien:extern-alien "syscall" (function sb-alien:unsigned int)) 186)
3288 ;; this is the correct PID of the main SBCL thread
* (bt:make-thread (lambda ()
(sb-alien:alien-funcall
(sb-alien:extern-alien "syscall" (function sb-alien:unsigned int)) 186)))
#<SB-THREAD:THREAD "Anonymous thread" FINISHED values: 3412 {100364B363}>
@phoe
phoe / kitterspeak.md
Last active February 5, 2018 16:14 — forked from Treeki/kitterspeak.md
Kitterspeak Reference
;;; (ql:quickload :qtools)
(defmacro with-qimage-from-vector ((image-var vector width height) &body body)
"Establishes a lexical environment, in which IMAGE-VAR is bound to a QImage
created from the ARGB contents of VECTOR, with width WIDTH and height HEIGHT."
(with-gensyms (length v)
`(let* ((,length (array-dimension ,vector 0))
(,v (make-static-vector ,length :initial-contents vector)))
(unwind-protect
(with-finalizing
@phoe
phoe / fox5.lisp
Created August 9, 2017 21:10
FOX5 decoder, first sketch
;;;; CL-FOX5 2017 © Michał "phoe" Herda
;;;; MIT license
;; (ql:quickload :fast-io)
;; (ql:quickload :cl-lzma)
;; (ql:quickload :alexandria)
;;; UTILS
(defun make-byte-array (n &rest options)
@phoe
phoe / defslimefun
Last active August 9, 2017 14:49
Swank/Slime protocol - keywords
contrib/swank-arglists.lisp:1136:(defslimefun autodoc (raw-form &key print-right-margin)
contrib/swank-arglists.lisp:1185:(defslimefun complete-form (raw-form)
contrib/swank-arglists.lisp:1201:(defslimefun completions-for-keyword (keyword-string raw-form)
contrib/swank-asdf.lisp:335:(defslimefun who-depends-on (system)
contrib/swank-asdf.lisp:362:(defslimefun operate-on-system-for-emacs (system-name operation &rest keywords)
contrib/swank-asdf.lisp:385:(defslimefun list-all-systems-in-central-registry ()
contrib/swank-asdf.lisp:408:(defslimefun list-all-systems-known-to-asdf ()
contrib/swank-asdf.lisp:413:(defslimefun list-asdf-systems ()
contrib/swank-asdf.lisp:438:(defslimefun asdf-system-files (name)
contrib/swank-asdf.lisp:451:(defslimefun asdf-system-loaded-p (name)