Octopodial Chrome

Stuff that Made Sense at the Time

The Personal Weblog of Bob Uhl


Sunday, 13 August 2006

The Geek Code

Many years ago, when I was still a young man, the Geek Code was created as a simple way for one to list one’s geekiness in a concise format (even the desire to do so is geeky…); my own geek code is:

GCS d+(++) s:+ a- C++++$ ULSA++++ P— L+++$ E+++ W+++$ N+++ o+ K w— O- M– V- PS+++(–) PE++ Y+ PGP t– 5++ X– R>+ !tv b++ DI++ D+(++) G+

Ah, the days of my youth!

Webactions

I’ve recently been playing at home & at work with AllegroServe & Webactions, a web development framework from Franz Inc., one of the leading Common Lisp vendors. Once you’ve worked your head around it, it’s quite powerful. I’ve also been learning how to use Lisp macros to reduce my coding burden. For example, take a look at the following lines:

(def-db-object brewer (thing)
  ((rating
   :type float
   :reader rating
   :html (html (:princ (make-stars (rating *object*)))))
   (beers
    :db-kind :join
    :db-info (:join-class beer
			  :home-key name
			  :foreign-key brewer
			  :set t)
    :accessor beers
    :html (let* ((beers (beers *object*))
		 (webaction (webaction-from-ent ent))
		 (websession (websession-from-req req))
		 (beer-path (locate-action-path webaction "beer" websession)))
	    (html
	      (:ul
	       (dolist (beer beers)
		 ;;(error "brewer: ~a; beer: ~a" (name *object*) (name beer))
		 (html (:li ((:a href (concatenate 'string
						  beer-path
						  "?"
						  (query-to-form-urlencoded `(("brewer" . ,(name *object*))
									      ("name" . ,(name beer))))))
			     (:princ (name beer) " (" (rating beer)
				     "-Star "
				     (style beer)) ")")))))))))
  (:base-table "brewers"))

These lines create a class named brewer, which has slots (members, if you’re familiar with that terminology) named rating & beers, and which inherits slots from the class named thing; it also creates nice little HTML-extension functions to display rating, beers & name, URL and notes inherited from thing. It also over-rides the default function provided for rating and displays it as a series of little asterisks instead as a number, and does the same for beers to instead create a nice little undelimited list (the :ul bit) with the list items being links to the beers.

Not too shabby for just a few lines, eh?


August
Sun Mon Tue Wed Thu Fri Sat
   
13
   
2006
Months
Aug

Powered by Blosxom | Subscribe with Bloglines | Listed on
BlogShares | Blogarama - The Blog Directory | Technorati Profile

This is my blogchalk:
United States, Colorado, Englewood, Centennial, English, , Robert, Male, 21–25, Free Software, Society for Creative Anachronism.