Skip to content

Instantly share code, notes, and snippets.

View fstamour's full-sized avatar

Francis St-Amour fstamour

View GitHub Profile
@fstamour
fstamour / google-keep-to-org-file.lisp
Last active July 23, 2023 17:31
Common lisp code to extract keep notes from google takeout into org-mode files
;;;; code to extract keep notes from google takeout into org-mode files
;; It's messy code it the result of an interactive coding session.
(in-package #:common-lisp-user)
(ql:quickload '(alexandria zip cl-ppcre cl-json flexi-streams))
(defpackage #:scratch-keep
@fstamour
fstamour / vimium.md
Last active November 28, 2022 14:28
vimium configurations

Custom search

w: https://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia
man: https://www.die.net/search/?q=%s
whois: https://www.whois.com/whois/%s
isup: http://www.isup.me/%s Is it down for Everyone or Just Me?

ql: http://quickdocs.org/search?q=%s Quickdocs
cl: https://duckduckgo.com/?q=common+lisp+%s Common Lisp
(defun box (thing) (cons :box thing))
(defun ref (box)
(assert (eq (car box) :box))
(cdr box))
(defun (setf ref) (value box)
(assert (eq (car box) :box))
(setf (cdr box) value))
@fstamour
fstamour / fizzbuzz.fth
Last active June 30, 2019 13:44
fizzbuzz in forth
#! /usr/bin/env gforth
( n -- )
: fizz? 3 mod 0= if ." Fizz" then ;
( n -- )
: buzz? 5 mod 0= if ." Buzz" then ;
( n -- )
: fizzbuzz? dup fizz? buzz?;
@fstamour
fstamour / hunchentoot-no-ssl.lisp
Created April 18, 2019 01:17
hunchentoot without openSSL
;; To be able to load hunchentoot without openSSL
(push :hunchentoot-no-ssl *features*)
@fstamour
fstamour / acl-repl.lisp
Created April 18, 2019 01:16
sbcl-specific code to have a repl with :commands for quicklisp and swank
(ignore-errors (require 'sb-aclrepl))
(when (find-package 'sb-aclrepl)
(push :aclrepl cl:*features*))
(require 'sb-aclrepl)
#+aclrepl
(progn
(sb-aclrepl:alias ("ql" 1 "Load system with quicklisp") (sys) (ql:quickload sys))
@fstamour
fstamour / setup-cffi-on-nix.lisp
Created April 18, 2019 01:14
hacky way to work with libraries in lisp with nix
(require 'cl-ppcre)
(defpackage :cffi)
(defparameter cffi::*foreign-library-directories*
`(,(merge-pathnames ".nix-profile/lib/"
(user-homedir-pathname))
,@(loop for path in (cl-ppcre:all-matches-as-strings
"-L[-\\w/.]+"
(uiop:getenv "NIX_LDFLAGS"))
@fstamour
fstamour / mintest.lisp
Created March 5, 2019 00:13
most minimalistic test library
(defparameter *tests* (make-hash-table))
(defun make-test (package body)
(list package body))
(defmacro deftest (name &body body)
(check-type name symbol)
`(setf (gethash ',name *tests*) (make-test *package* '(progn ,@body))))
(defun run-test (name)
@fstamour
fstamour / edit-distance.lisp
Created February 16, 2019 20:30
Some edit-distances in common lisp
;; a.k.a restricted damereau-levenshtein distance
(defun optimal-string-alignment-distance (vec-a vec-b)
(let ((d (make-array (list (1+ (length vec-a))
(1+ (length vec-b)))
:element-type 'integer)))
;; Initialize the matrix
(loop :for i :upto (length vec-a) :do
(setf (aref d i 0) i))
(loop :for i :upto (length vec-b) :do
@fstamour
fstamour / guid-to-clipboard.ps1
Created February 13, 2019 18:36
powershell that generate a new Guid (uuid) and put it in the clipboard
[guid]::newguid() | set-clipboard