Skip to content

Instantly share code, notes, and snippets.

Ok so a while back a ran into a problem when extending the slot options in CLOS. I went digging in SBCL and saw it uses a case based approach to process the slot arguments/options. The AMOP in page 95 shows a way to use the CLOS famework to 'teach' CLOS how to process custom options (for slots and classes) inserting a generic function to hook into called 'canonicalized-{defclass,slot}-option'. However due to bootstraping issues IIUC (which I probably don't) defgeneric isn't avaiable at the time that code is evaluated so that extension can't be included willy nilly in SBCL itself.** So it occured to me that maybe a CLOS implemented on top the implementations CLOS could provide a path of least resistance to continue improving the CLOS framework*.

* I use framework not in the software sense but in the general sense.

** A possibl

@PuercoPop
PuercoPop / regexp.lisp
Created March 15, 2014 07:39
Friday Night Coding with @ivoscc and @marsam
(defpackage regexp
(:use :cl :fsm))
(in-package :regexp)
(match-sequence "Hello")
;; fsm
(deffsm regexp ()
())
function repeat(x,n) { var a=[]; for (;n>0;n--) a.push(x); return a; }
// returns an array of the first `n` natural numbers
function range(n) {
return repeat('10', n+2).map(parseInt).slice(2).map(function(x) {
return x-2;
});
}
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, NaN, NaN, NaN, NaN, NaN]
for item in collection:
do_stuff(item)
#becomes:
iterator = iter(collection)
while True:
try:
item = iterator.next()
# The code from the for indent block goes here. (No lambdas :/)
(ql:quickload :optima)
(ql:quickload :split-sequence)
(defun process-auth-header (auth-header)
"Validate that is the correct 'scheme' (NOQ) and return the id and the
digest."
(match (split-sequence #\: auth-header)
((list first digest) (cons digest . first))))
;; Error
(defun to-auth-header (user &optional (date (http-date (now))))
"Encode a user's email, password and a timestamp with hmac."
(let* ((hmac (make-hmac *hmac-secret* :sha256))
(message (string-to-octets (format nil "~S ~S" (password user) date)))
(digest (progn
(update-hmac hmac message)
(hmac-digest hmac)))
(b64-digest (usb8-array-to-base64-string digest)))
(values (format nil "NOQ ~A:~A" (email user) b64-digest)
(format nil "Date: ~A" date))))
(defun helm-venv-workon ()
"Like venv-work, for helm."
(interactive)
(helm :sources 'helm-source-venv
:helm-buffer "*Virtual Environments*"))
(defun helm-venv-workon (candidate)
nil)
(defvar helm-source-venv
#+BEGIN_SRC lisp :results
(defun square (x)
(* x x))
(macro-expand '(loop
:for num :from 3 upto 6
:collect (square num)))
#+END_SRC
What I get
(add-hook 'save-hook (lambda () (shell-command "Youur command"))
loginButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// First check if email or password are empty, if any of those
// is empty, focus them. Else try to authenticate on the
// endpoint.
final EditText email = (EditText) rootView.findViewById(R.id.login_email);
final EditText password = (EditText) rootView.findViewById(R.id.login_password);
AuthenticatorMock authenticator = new AuthenticatorMock();
try {