Skip to content

Instantly share code, notes, and snippets.

(defpackage :hunchentoot-demo
(:use :cl :alexandria))
(in-package :hunchentoot-demo)
(defclass acceptor (hunchentoot:acceptor) ())
(defvar *acceptor* (make-instance 'acceptor))
(defvar *routes* nil)
@joekarma
joekarma / gist:3965651
Created October 27, 2012 18:47
Hello World in RESTAS
(restas:define-module :hello-world-app
(:use :cl :cl-who))
(in-package :hello-world-app)
(restas:define-route index ("/")
(with-html-output-to-string (s)
(:html
(:head
(:title "Hello World!"))
@joekarma
joekarma / gist:3956492
Created October 26, 2012 01:44
Get symbol values for packages that might not exist. Use SYMLOOK to find variables in potentially nonexistent packages, and use SYMCALL to call functions in packages that may not exist. Tossed SYMBOUNDP into the mix as well; this function tests to see whe
(defun symbol-lookup (package-designator symbol &key (symbol-lookup-function #'symbol-value))
(let ((return-value (list nil nil))
value-of-symbol)
(alexandria:when-let* ((package (find-package package-designator))
(found-symbol (find-symbol (symbol-name symbol)
package)))
(setf value-of-symbol (ignore-errors (funcall symbol-lookup-function found-symbol)))
(setf return-value
(list value-of-symbol t)))
(values-list return-value)))
(eval-when (:compile-toplevel)
(ql:quickload :split-sequence))
(("stassats" . 40572) ("Xach" . 38278) ("nyef" . 37542) ("pjb" . 36812)
("sykopomp" . 27405) ("p_l" . 27385) ("beach" . 25487) ("pkhuong" . 24938)
("tcr" . 22036) ("drewc" . 19171) ("stassats`" . 17795) ("Zhivago" . 17075)
("_3b" . 16209) ("fusss" . 15704) ("Fare" . 15631) ("madnificent" . 15121)
("H4ns" . 14446) ("antifuchs" . 14346) ("gigamonkey" . 13040)
("Ralith" . 12161) ("fe[nl]ix" . 11921) ("Guthur" . 11524) ("Fade" . 11351)
("Adlai" . 11318) ("nikodemus" . 10038) ("rsynnott" . 10017) ("rahul" . 9910)
("schme" . 8600) ("mathrick" . 8582) ("Krystof" . 8452) ("hefner" . 8430)
("tic" . 8072) ("weirdo" . 7948) ("Phoodus" . 7711) ("jdz" . 7256)
("dlowe" . 7219) ("francogrex" . 7132) ("drdo" . 6495) ("adeht" . 6304)
@joekarma
joekarma / gist:3925120
Created October 20, 2012 22:54
Get a list of packages that are created as a side effect of evaluating a given bunch of forms (such as quickloading a system)
(defmacro packages-created-by (&rest forms)
(with-gensyms (packages-before)
`(let ((,packages-before (list-all-packages)))
,@forms
(set-difference (list-all-packages) ,packages-before))))
@joekarma
joekarma / gist:3916212
Created October 19, 2012 04:22
Simple example of cl-sendmail being used to send an HTML based email. Use cl-smtp instead.
(cl-sendmail:with-email (html "[email protected]" :from "[email protected]" :subtype "html")
(setf (cl-sendmail::content html)
(xmls:parse "<body><h1>Testing</h1><p>This is a test!</p></body>")))
(some-function (:foo)
:bar)
(some-function :foo
:bar)
@joekarma
joekarma / gist:3883827
Created October 13, 2012 08:32 — forked from meadhikari/gist:3873415
First common lisp function
(loop :for n :from 1 :below 1000
:when (or (zerop (mod n 3))
(zerop (mod n 5)))
:sum n)