Skip to content

Instantly share code, notes, and snippets.

@snmsts
snmsts / iolib.err.sh
Created July 29, 2013 07:41
couldn't load fasl.
#!/bin/sh
rm -rf /tmp/iolib-fasl/
sbcl --no-userinit --script <<EOT
(in-package :common-lisp-user)
(load #P"~/quicklisp/setup.lisp")
(asdf:enable-asdf-binary-locations-compatibility
:centralize-lisp-binaries t
(cl:defun :toggle (symbol)
(cl:if (cl:find symbol cl:*features*)
(cl:progn
(cl:setf cl:*features* (cl:remove symbol cl:*features*))
cl:nil)
(cl:progn
(cl:push symbol cl:*features*)
symbol)))
@snmsts
snmsts / hello world
Created September 4, 2013 04:17
generate "Hello World" without including any literal.
(defmacro def-print-string (name string)
`(defun ,name ()
(let ((one (count t'(t))))
(print
(coerce
(mapcar #'code-char
(list
,@(loop :for i :across string
:collect
`(+ ,@(loop :for j := (char-code i) :then (floor j #.(count t'(t t)))
@snmsts
snmsts / shlyfile
Created September 27, 2013 10:49
test with shlyfile
(defun which (bin &key a)
(let* ((paths (mapcar #'(lambda (x) (make-pathname :defaults (format nil "~A/" x)))
(asdf::split-string (asdf::getenv "PATH") :separator '(#\:))))
found)
(setq found (flet ((test (x y)
(cl-fad:file-exists-p (merge-pathnames x y))))
(if a
(remove bin paths :test (complement #'test))
(find bin paths :test #'test))))
@snmsts
snmsts / gist:6761725
Created September 30, 2013 10:00
print runtime environment
(format t "~&~@{~{~A~^ ~}~^~%~}"
`("Lisp:" ,(lisp-implementation-type) ,(lisp-implementation-version))
#+quicklisp `("Quicklisp:" "Version",(quicklisp-client::local-version) ,(ql-dist:all-dists))
#-quicklisp `("Quicklisp:" "Not installed"))
@snmsts
snmsts / shlyfile
Created January 17, 2014 17:15
test
;; -*- lisp -*-
(defvar *current-dir* (make-pathname :type nil :name nil :defaults *load-pathname*))
(push (merge-pathnames "quickdocs/" *current-dir*)
asdf:*central-registry*)
(defvar *output-dir* (merge-pathnames "out/1st/" *current-dir*))
(ql:quickload '(:quickdocs :iolib.syscalls))
(defun doc (a)
(ql:quickload '(:cffi :cl-ppcre))
(with-output-to-string (*standard-output*)
(handler-bind
((cffi:load-foreign-library-error
#'(lambda (c)
(declare (ignore c))
(invoke-restart 'cffi::use-value "libncursesw.so.5"))))
(ql:quickload :cl-charms)))
(defun eltstr->sexp (eltstr base-expr)
(loop :with x := base-expr
:with gensym := (gensym)
:for i :in (mapcar #'(lambda (x) (mapcar (lambda (x) (or (= (length x) 0)
(parse-integer x))) (split-sequence:split-sequence #\_ x)))
(split-sequence:split-sequence #\/ eltstr))
:do (setq x (cond ((eql (length i) 1)
(if (minusp (first i))
`(let ((,gensym ,x))
(nth (+ (length ,gensym) ,(first i)) ,gensym))
(defun ymdhms (&optional (universal-time (get-universal-time)))
(or (ignore-errors (format nil "~{~2,'0d~#[~;:~;:~;_~:;/~]~}"
(cdddr (nreverse (multiple-value-list (decode-universal-time universal-time))))))
"not-universaltime"))
@snmsts
snmsts / clack.websocket.lisp
Created August 23, 2014 18:04
websocket test implementation
(ql:quickload '(:clack :cl-async))
(defpackage websocket.test
(:use :cl
:clack))
(in-package :websocket.test)
(defvar *handler*
(clackup