Skip to content

Instantly share code, notes, and snippets.

View mmontone's full-sized avatar

Mariano Montone mmontone

View GitHub Profile
@mmontone
mmontone / Common Lisp hash table syntax
Created October 27, 2013 23:03
Common Lisp hash table syntax
(defun read-separator (str)
(let
((*readtable* (copy-readtable *readtable* nil)))
(set-macro-character #\, (lambda (stream char)
(declare (ignore char) (ignore stream))
'break))
(read str nil)))
(set-macro-character #\{
(lambda (str char)
@mmontone
mmontone / Common Lisp symbol syntax
Created October 27, 2013 23:26
Implementation of syntax for symbols to be able to use spaces instead of '-' in them. The default enclosing chars are '<' and '>'.
;; Implementation of syntax for symbols to be able to use spaces instead of '-' in them.
;; The default enclosing chars are '<' and '>'.
;; Example:
;; (defclass <My Class> (<Standard Object>)
;; ((<My Slot> :accessor <My Slot>
;; :initarg :my-slot)))
;;
;; (<with slots> (<My slot>)
;; (<make instance> '<My class> :my-slot "Value")
@mmontone
mmontone / install.sh
Last active August 29, 2015 14:05
cl-travis
#!/bin/sh
set -e
# get <url> <destination>
get() {
url=$1
destination=$2
echo "Downloading ${url}..."
curl --no-progress-bar --retry 10 -o "$destination" -L "$url"
@mmontone
mmontone / dynamic-functions.lisp
Created July 10, 2017 00:03
Dynamic functions
(defun make-dfun-varname (fname)
(intern (format nil "*DFUN-~A*" fname)))
(defmacro dflet (fbindings &body body)
`(let
,(loop for fbinding in fbindings
collect
(destructuring-bind (fname args &body body) fbinding
(let ((dfun-varname (make-dfun-varname fname)))
`(,dfun-varname (cons (lambda ,args
@mmontone
mmontone / 2FA-test.lisp
Last active July 13, 2017 16:43
2FA test - Two Factor Authentication test via FreeOTP and Common Lisp
(ql:quickload :cl-base32)
(ql:quickload :hunchentoot)
(ql:quickload :cl-one-time-passwords)
(ql:quickload :cl-qrencode)
(ql:quickload :cl-pass)
(ql:quickload :babel)
(ql:quickload :flexi-streams)
(ql:quickload :cl-who)
(ql:quickload :ironclad)
@mmontone
mmontone / who-templates.lisp
Last active July 26, 2017 21:20
CL-WHO templating system
(defpackage :who-templates
(:nicknames :whot)
(:use :cl)
(:export
:deftemplate
:block
:include
:parent
:render-template
:render-template-to-string
@mmontone
mmontone / Morphic-Layouts-Table.st
Created July 10, 2018 15:53
Simple Table layout for Cuis Smalltalk
!classDefinition: #TableCellMorph category: #'Morphic-Layouts-Table'!
BorderedRectMorph subclass: #TableCellMorph
instanceVariableNames: 'hAlignment vAlignment hResizing vResizing padding'
classVariableNames: ''
poolDictionaries: ''
category: 'Morphic-Layouts-Table'!
!TableCellMorph commentStamp: '<historical>' prior: 0!
A table cell.
It's instances are added as submorphs to a TableLayoutMorph.!
@mmontone
mmontone / html2who.lisp
Created February 3, 2019 21:27
Convert HTML to CL-WHO templates
(defpackage html2who
(:use :cl))
(in-package :html2who)
(defun empty-string-p (string)
(let ((empty-chars (list #\space #\newline #\return #\tab)))
(every (lambda (char)
(member char empty-chars))
string)))
@mmontone
mmontone / clgshell.py
Created February 11, 2019 22:15
Python clg (command line generator) shelll extensions
# clgshell
#
# clgshell is an extension to python-clg (command line generator) for writing shell commands
#
# Usage:
#
# 1. create a commands.py file
# 2. import clgshell from there
# 3. use @cmd decorator for defining shell commands
# 4. reference those commands from YAML python-clg spec:
(defpackage :plump-xpath
(:use :cl))
(in-package :plump-xpath)
(defstruct plump-attribute
name val)
(defun plump-node-attributes (node)
(loop for name being the hash-keys of (plump-dom:attributes node)