Skip to content

Instantly share code, notes, and snippets.

View TeMPOraL's full-sized avatar

Jacek Złydach TeMPOraL

View GitHub Profile
@TeMPOraL
TeMPOraL / plump-use.lisp
Created October 3, 2017 18:46
Some examples of using Plump.
(defun parse-tree/fix-anchors (tree base-url)
"Fix anchor URLs in the `TREE' to work correctly with the <base> tag."
(plump:traverse tree
(lambda (node)
(when (starts-with-subseq "#" (plump:attribute node "href"))
(setf (plump:attribute node "href") (concatenate 'string base-url (plump:attribute node "href")))))
:test (lambda (node)
(and (plump:element-p node)
(string-equal (plump:tag-name node) "a")))))
@TeMPOraL
TeMPOraL / clx.lisp
Created September 11, 2017 18:30
Example of a X window that properly handles closing events from the WM.
(defpackage #:scratch/clx-test
(:use #:cl)
(:export #:run))
(in-package #:scratch/clx-test)
;;; A minimum test case for properly handling window close events from the window manager.
(defun delete-window-event-p (display type data)
(and (eq type :wm_protocols)
@TeMPOraL
TeMPOraL / keybase.md
Created May 11, 2017 22:49
Android created Gist

Keybase proof

I hereby claim:

  • I am temporal on github.
  • I am temporal_pl (https://keybase.io/temporal_pl) on keybase.
  • I have a public key ASCI--smw7XaN_sGcdGKg27RlH9QLy7Pv8r975Qg4P0YMAo

To claim this, I am signing this object:

@TeMPOraL
TeMPOraL / orgmode.el
Created November 3, 2016 13:58
Excerpts from the current config for org-mode I use.
(try-load-and-configure-library
'org-install
(setq org-hide-leading-stars t)
(setq org-pretty-entities t)
(setq org-pretty-entities-include-sub-superscripts nil)
(setq org-return-follows-link t)
(setq org-special-ctrl-a/e t)
(setq org-log-done t)
@TeMPOraL
TeMPOraL / bcm2835.lisp
Last active October 15, 2019 07:11 — forked from chomy/bcm2835.lisp
(defpackage :BCM2835
(:use :FFI)
(:export :init
:close
:gpio-fsel
:gpio-write
:gpio-lev
:gpio-set
:gpio-clr
:delay
(defun ⋅ (a b)
"Compute dot product of two vectors."
(assert (= (length a)
(length b))
(a b)
"Cannot compute a dot product of ~S and ~S - lengths of vectors differ." a b)
(reduce #'+ (map 'vector #'* a b)))
(defun × (a b)
"Compute cross product of two 3D vectors."
(defun m44*m44 (m1 m2)
;; Unrolled, because why the hell not?
;; TODO maybe unroll dot-product and matrix-column/matrix-row as well?
;; for now let's inline them and hope the compiler is not dumb
(make-m44 (⋅ (m44-column m1 0) (m44-row m2 0)) (⋅ (m44-column m1 1) (m44-row m2 1)) (⋅ (m44-column m1 2) (m44-row m2 2)) (⋅ (m44-column m1 3) (m44-row m2 3))
(⋅ (m44-column m1 0) (m44-row m2 0)) (⋅ (m44-column m1 1) (m44-row m2 1)) (⋅ (m44-column m1 2) (m44-row m2 2)) (⋅ (m44-column m1 3) (m44-row m2 3))
(⋅ (m44-column m1 0) (m44-row m2 0)) (⋅ (m44-column m1 1) (m44-row m2 1)) (⋅ (m44-column m1 2) (m44-row m2 2)) (⋅ (m44-column m1 3) (m44-row m2 3))
(⋅ (m44-column m1 0) (m44-row m2 0)) (⋅ (m44-column m1 1) (m44-row m2 1)) (⋅ (m44-column m1 2) (m44-row m2 2)) (⋅ (m44-column m1 3) (m44-row m2 3))))
;;; repl.sh
#!/bin/bash
if [[ "$#" -ne 1 ]]; then
echo "Usage: repl.sh 'script to be run'"
exit 1
fi
screen -AdmS 'main' "$1"
(defbehavior root-0
(if (alive)
(if (enemy-in-range)
(attack (find-weakest-enemy-in-range))
(move-to-enemy find-nearest-enemy))))
@TeMPOraL
TeMPOraL / regenerate.lisp
Created December 2, 2012 19:43
A static page generator
;;;; regenerate.lisp - script for regenerating [redacted] static HTML from template files.
(ql:quickload "cl-emb")
(ql:quickload "cl-fad")
(ql:quickload "cl-ppcre")
(defparameter *configuration* '() "plist containing config parameters passed to EMB templates.")
(defparameter *essays* '() "plist containing essay descriptors generated by `defessay'.")
(defconstant +default-properties+ '(:title nil :url nil :orig-title nil :orig-url nil :date nil :orig-date nil :alt-translations nil :translators nil :editors nil :disabled nil :additional-html nil :part-of-hnp nil :description ""))