Skip to content

Instantly share code, notes, and snippets.

View michaeljforster-zz's full-sized avatar

Michael J. Forster michaeljforster-zz

View GitHub Profile
| h c |
h := Hello new.
h m. "'Hello'"
h melf. "'Hello'"
h muper. "dnu"
c := CommaSpaceWorld new.
c m. "'Hello World!'"
c melf. "'Hello World!'"
;;;; leaflet-quick-start.paren
;;; Map and Tile Layers
(defvar *default-lat-lng* '(51.505 -0.09))
(defvar *default-zoom* 13)
(defvar *map* (ps:chain -l (map "map") (set-view *default-lat-lng* *default-zoom*)))
;;;; react.lisp - Common Lisp/Parenscript wrapper for React v0.11.2
;;; The MIT License (MIT)
;;;
;;; Copyright (c) 2015 Michael J. Forster
;;;
;;; Permission is hereby granted, free of charge, to any person obtaining a copy
;;; of this software and associated documentation files (the "Software"), to deal
;;; in the Software without restriction, including without limitation the rights
;;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@michaeljforster-zz
michaeljforster-zz / agent-ui.lisp
Last active August 29, 2015 14:03
Roughing out UI with Parenscript, React, and Bootstrap
;;;; agent-ui.paren
(pt:defcomponent left-main-column ()
(pt:jsl
(:div :class-name "col-md-4" ;; left main column
(:div :id "status-box")
(:button :class "btn btn-default btn-xs" :on-click (ps:@ this props on-callback-click) "(Re)Schedule Callback")
(:button :class "btn btn-default btn-xs" :on-click (ps:@ this props on-last-call-click) "Code Other")
(:button :class "btn btn-default btn-xs" :on-click (ps:@ this props on-sale-authorised-click) "Authorise Sale")
)))
@michaeljforster-zz
michaeljforster-zz / react-tutorial2.lisp
Last active August 29, 2015 14:02
Assimilation of Facebook's React progresses
(in-package #:grok-cl-parenscript-react)
(hunchentoot:define-easy-handler (handle-tutorial :uri "/tutorial")
()
(cl-who:with-html-output-to-string (stream)
(:html
(:head
(:title "React Tutorial")
(:script :type "text/javascript" :src *react-url*))
(:body
@michaeljforster-zz
michaeljforster-zz / react-tutorial.lisp
Created May 9, 2014 12:11
Facebook's React assimilated
(in-package #:grok-cl-parenscript-react)
(hunchentoot:define-easy-handler (handle-tutorial :uri "/tutorial")
()
(cl-who:with-html-output-to-string (stream)
(:html
(:head
(:title "React Tutorial")
(:script :type "text/javascript" :src *react-url*))
(:body
@michaeljforster-zz
michaeljforster-zz / query-composition.sql
Created February 16, 2014 17:33
Composing SQL queries from table expressions and functions
-- other types, base relvars (tables), derived relvars (views), and functions elided ...
create view project_pk_in_campaign_started as
select distinct cli_id, prj_id from campaign join campaign_started using (cli_id, cmp_id);
create view active_project as
select cli_id, prj_id, prj_next_cold_call_limit
from project join project_pk_in_campaign_started using (cli_id, prj_id);
create view cold_call_queued as select * from cold_call where cc_status = 'queued';
foobar=# begin; create table foo (id serial primary key); alter table foo rename to bar; commit;
BEGIN
NOTICE: CREATE TABLE will create implicit sequence "foo_id_seq" for serial column "foo.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "foo_pkey" for table "foo"
CREATE TABLE
ALTER TABLE
COMMIT
foobar=# \d
List of relations
Schema | Name | Type | Owner
(defmacro defenum (name (&rest keys))
"Define a function named %NAME, that takes an argument KEY and returns
an associated value from KEYS. If KEYS are scalar values, the associated
values are zero-based indices."
(let ((function-name (intern (format nil "%~:@(~A~)" name))))
(flet ((ensure-alist (list)
(let ((i -1))
(mapcar #'(lambda (x)
(destructuring-bind (key &optional (value (incf i)))
(alexandria:ensure-list x)