Skip to content

Instantly share code, notes, and snippets.

@rpav
rpav / output.lisp
Last active December 18, 2015 02:19
cl-autowrap demo
(progn
(cffi:defcstruct #1=#:anon-type-1646
(f :float))
(cffi:defcstruct x
(a :int)
(b :int)
(j :int :count 2)
(n (:struct #1#))
(m (:struct #1#))
(next (:pointer (:struct x)))))
@rpav
rpav / insert-eval-button.el
Last active December 29, 2015 11:39
Insert a "button" (hyperlink) at the point that evals the code before it in slime.
(defun insert-eval-button ()
(interactive)
(insert-string " ")
(insert-text-button
"Eval" 'action
(lambda (x)
(save-excursion
(goto-char (button-start x))
(slime-eval-last-expression)))
'follow-link t))
@rpav
rpav / gist:7832108
Last active December 30, 2015 12:49
sbcl won't finalize until the thread is done?
(defclass finalize-test () ())
(defmethod initialize-instance ((instance finalize-test) &key &allow-other-keys)
(bt:make-thread (lambda () (sleep 300)))
(tg:finalize instance
(lambda ()
(format t "I am all done.~%"))))
(make-instance 'finalize-test)
@rpav
rpav / Xmodmap
Created May 20, 2014 17:05
Xmodmap for exchanging () and [] .. easier access to () for Lisp!
keycode 34 = parenleft braceleft
keycode 35 = parenright braceright
keycode 18 = 9 bracketleft
keycode 19 = 0 bracketright
@rpav
rpav / output.js
Last active August 29, 2015 14:05
c2ffi function templates
[
{
"tag": "function",
"name": "fun",
"location": "test3.cpp:6:16",
"variadic": false,
"inline": false,
"storage_class": "none",
"template": [
{
@rpav
rpav / output.js
Created August 12, 2014 20:52
c2ffi class template
[
{
"tag": "typedef",
"name": "A_int",
"location": "test.cpp:9:19",
"type": {
"tag": ":class",
"name": "A",
"id": 1
}
@rpav
rpav / replace-word-at-point.el
Created September 3, 2014 18:04
replace-word-at-point
(defun replace-word-at-point ()
(interactive)
(save-excursion
(let ((regexp (concat "\\_<" (current-word) "\\_>"))
(replacement (read-from-minibuffer
(concat "Replace " (current-word) " with: ") "")))
(re-search-backward "\\_<")
(replace-regexp regexp replacement))))
@rpav
rpav / gist:06525c5c902938c1ddae
Created October 9, 2014 03:06
Abbreviated parsing example
(defparameter *input-string*
"(tiles 2 2
(tile 0 0 TTERMLTERM EMPTY16X2 0)
(tile 1 1 TL UL 7
(primitive_site RLL_X0Y25 RESERVED_LL internal 8)
(primitive_site DCI7 DCI internal 13)
(primitive_site DCI0 DCI internal 13)
(primitive_site PMV PMV internal 8)
(primitive_site DCIRESET7 DCIRESET internal 1)
(primitive_site DCIRESET0 DCIRESET internal 1)
@rpav
rpav / say.lisp
Last active August 29, 2015 14:16
:say macro for print debugging
;; (:say foo bar)
;; => FOO = <VALUE>, BAR = <VALUE>
;; (:say (:val foo))
;; => <VALUE>
;; (:say (:val foo) (:val bar))
;; => <VALUE><VALUE>
;; (:say (:val foo) " " (:val bar))
@rpav
rpav / tilemap-loader.lisp
Created May 2, 2016 19:34
Common Lisp loader code for Tiled map editor JSON format (tilesets and maps)
(defparameter *tileset-cache* (make-hash-table :test 'equal))
;; TILE, TILESET
(defclass tile ()
((props :initform nil :accessor props)
(image :initform nil :initarg :image :reader tile-image)))
(defclass tileset ()
((props :initform nil :accessor props)