Skip to content

Instantly share code, notes, and snippets.

@phmarek
phmarek / vlime-test-keys.vim
Created March 18, 2021 13:02
F2, F3 key bindings for Vlime
nnoremap <F2> :<C-U>let g:my_slimv_eval_form=vlime#ui#CurTopExpr() \| call vlime#plugin#SendToREPL(g:my_slimv_eval_form)<CR>
nnoremap <F3> :<C-U>call vlime#plugin#SendToREPL(vlime#ui#CurTopExpr()) \| call vlime#plugin#SendToREPL(g:my_slimv_eval_form)<CR>
@phmarek
phmarek / ht:s-h__vs__flex:w-o-t-s.md
Created February 11, 2021 12:45
HUNCHENTOOT:SEND-HEADERS and streaming output vs. FLEX:WITH-OUTPUT-TO-SEQUENCE
-             (let ((stream (hunchentoot:send-headers)))
+             (flex:with-output-to-sequence (stream)

and a short benchmark (wrk --latency -c2 -t2 -d 5)

gives these results. First HT:S-H:

...
@phmarek
phmarek / btrfs-clean-progress.sh
Last active March 15, 2021 10:09
Show progress of BTRFS snapshot removal
#!/bin/bash
P="${1:-.}"
prev=0
while sleep 30 ; do
C=$(btrfs sub list -d "$P" | wc -l)
if [[ "$C" != "$prev" ]]
then
prev="$C"
@phmarek
phmarek / ls-sorting.txt
Created August 12, 2020 07:16
"ls" sorting directories/files differently if the start with "d" or "p"?
$ mkdir config config-example
$ touch config/d config-example/d
$ touch config/p config-example/p
$ ls config*/d
config/d config-example/d
$ ls config*/p
config-example/p config/p
$ # Why is the sort order different??
$ locale
LANG=de_AT.UTF-8
@phmarek
phmarek / script.lisp
Created July 16, 2020 16:39
SBCL --script with arbitrary options
#!/bin/bash
#|
exec /usr/bin/sbcl --dynamic-space-size 2000 --script "$0"
|#
(print "hello world")
@phmarek
phmarek / perl_qw-reader.lisp
Created July 6, 2020 11:31
A reader macro like qw() in Perl
(defpackage :perl-symbols)
(defun my-qw-reader (stream char)
(declare (ignore char))
(let ((*readtable* (copy-readtable nil))
(*package* (find-package :perl-symbols)))
(setf (readtable-case *readtable*)
:preserve)
(set-macro-character #\: nil nil *readtable*)
@phmarek
phmarek / form-count-via-asdf.lisp
Last active July 16, 2020 09:05
Replacement for "sloccount", to count forms in a(n ASDF) system
#+cl-ppcre
(defun :form-count-for-asdf (system &key file-regex per-file)
(let ((files 0)
(per-file-alist ())
(top-forms 0)
(forms 0)
;(more-data nil)
(system (or (asdf:find-system system)
(error "~s not found" system))))
(labels ((rec (f)
@phmarek
phmarek / ssl-server+client.lisp
Created July 31, 2019 18:38
Example for an SSL server plus a client, including client certificate. Needs the certs from my CL+SSL branch.
(in-package :cl-user)
(ql:quickload '(:hunchentoot :drakma))
(hunchentoot:define-easy-handler (root :uri "/")
()
(let ((cert (hunchentoot:get-peer-ssl-certificate)))
(format nil "It works: ~a"
(unless (cffi:null-pointer-p cert)
@phmarek
phmarek / r0.res
Created April 18, 2016 07:57
DRBD configuration used for the RDMA performance Tech Guide
#
# DRBD configuration used for the RDMA performance Tech Guide
# See http://blogs.linbit.com/p/1013/rdma-performance/
#
resource r0 {
disk /dev/mapper/zero-block-1;
meta-disk internal;
device minor 0;
disk {