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 / pzmq-router-dealer.lisp
Created May 24, 2019 10:15
ZeroMQ pzmq sample router/dealer in Common Lisp
;; modified from pzmq examples
(defun hwclient (&optional (server-address "tcp://localhost:5555"))
"Translation of http://zguide.zeromq.org/c:hwclient 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 http://api.zeromq.org/3-3:zmq-ctx-destroy
(pzmq:connect requester server-address)
@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
@phoe
phoe / swank.lfe
Last active October 17, 2017 03:05
SWANK-LFE fifth(?) draft
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; SWANK-LFE
;;;; © Michał "phoe" Herda 2017
;;;; swank.lfe
(defmodule swank
(export
;; ## Utils
(curry 2) (curry 3) (curry 4)
;; (start_server 1) (stop_server 0) (start_listener 2)
@phoe
phoe / hmmm.lisp
Last active October 6, 2017 15:01
Common Lisp that makes you go hmmm
"This one should be fairly obvious."
(defun the-answer-to-life-the-universe-and-everything ()
(+(*(+(*)(*))(+(*)(*)(*)))(*(*(+(*)(*))(+(*)(*)(*)))(*(+(*)(*))(+(*)(*)(*))))))
"The advanced version of the above."
(defun rick (
) (
+ (+
) ( *) (
*) (+) ( *)