This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#+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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 :/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage regexp | |
(:use :cl :fsm)) | |
(in-package :regexp) | |
(match-sequence "Hello") | |
;; fsm | |
(deffsm regexp () | |
()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deffsm bdecode-int () | |
()) | |
(defstate bdecode-int :initial (fsm c) | |
(if (char= c #\i) | |
:read-number | |
:error)) | |
(defstate bdecode-int :read-number (fsm c) | |
(if (char= c #\e) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ql:quickload :ironclad) | |
(ql:quickload :flexi-streams) | |
(defgeneric authenticate (user secret) | |
(:documentation "Authentication user with secret. Secret may be a | |
password or a token.")) | |
(defclass user () | |
((email :initarg :email :accessor email) | |
(password :initarg :password) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This works | |
(defun read-until (character stream) | |
"Read the stream until it matches the character. all the characters | |
read." | |
(coerce (loop | |
for char = (read-char stream) | |
until (char= char character) | |
until (char= char #\>) | |
collect char) | |
'string)) |