Skip to content

Instantly share code, notes, and snippets.

View svetlyak40wt's full-sized avatar
💭
Making Ultralisp.org

Alexander Artemenko svetlyak40wt

💭
Making Ultralisp.org
View GitHub Profile
@svetlyak40wt
svetlyak40wt / ningle-defroute.lisp
Created March 4, 2022 13:04
Example of a simple DEFROUTE macro for Ningle Common Lisp web framework
(uiop:define-package #:ningle-defroute
(:use #:cl))
(in-package #:ningle-defroute)
(defmacro defroute (app path-or-path-with-options (&rest view-arguments) &body view-body)
(let* ((path-with-options (uiop:ensure-list path-or-path-with-options))
(params (gensym "PARAMS"))
(bindings (loop for arg-name in view-arguments
@svetlyak40wt
svetlyak40wt / ningle-uploader.lisp
Created February 11, 2022 16:36
Example of a simple file uploader using Common Lisp and Ningle framework
;; License: MIT
(uiop:define-package #:ningle-upload
(:use #:cl)
(:import-from #:cl-fad)
(:import-from #:ningle)
(:import-from #:spinneret)
(:import-from #:log4cl))
(in-package #:ningle-upload)
fossil clone https://tumbleweed.nu/r/usim /Users/art/tmp/l/usim.fossil
Round-trips: 5 Artifacts sent: 0 received: 3193
Clone done, wire bytes sent: 1326 received: 22819371 ip: 46.23.94.31
Rebuilding repository meta-data...
100.0% complete...
Extra delta compression...
Vacuuming the database...
project-id: 7e9f9fd6c8f1267e4a87a4fc69bf425acba15339
server-id: f91e714aaf26b8d2b6e61d49c7751b304c10d095
admin-user: art (password is "CohXS3R9d4")
@svetlyak40wt
svetlyak40wt / histogram.lisp
Last active June 22, 2021 14:02
Common Lisp function to put data into buckets and print historgram
;; License BSD
(defpackage #:histogram
(:use #:cl)
(:export
#:print-histogram))
(in-package histogram)
(defun min-value (values)
@svetlyak40wt
svetlyak40wt / cl-dbi-server-side-cursor.lisp
Created April 17, 2021 17:38
An example of using server-side cursor with fukamachi/cl-dbi
(defmacro do-rows ((row sql &key params) &body body)
(with-gensyms (prepared cursor-name)
(let ((cursor-sql (fmt "DECLARE ~A CURSOR FOR ~A"
cursor-name
sql))
(fetch-sql (fmt "FETCH FROM ~A"
cursor-name)))
`(progn
(dbi:do-sql *connection* ,cursor-sql ,params)
@svetlyak40wt
svetlyak40wt / README.md
Created March 11, 2021 10:40
Example how to restore SBCL_HOME and be able to (REQUIRE :SB-INTROSPECT)

To check, use Roswell to build the script:

ros build foo.ros

and run it

./foo
@svetlyak40wt
svetlyak40wt / svn-blame-stats.lisp
Created January 22, 2021 20:46
A short script to calculate how many lines belong to each SVN commiter
(defpackage #:blame-stats
(:use #:cl))
(in-package blame-stats)
(ql:quickload '(alexandria cl-fad str lparallel)
:silent t)
(defun merge-hash-table-into (left right)
"Merges values from right hash map into the left"
@svetlyak40wt
svetlyak40wt / travis-badges.lisp
Last active January 20, 2021 22:30
A generator for Travis Matrix badges.
;; Run (ql:quickload :cl-yaml) before loading this script
(defpackage #:travis-badges
(:use #:cl)
(:import-from #:cl-yaml)
(:export
#:make-badges))
(in-package travis-badges)
@svetlyak40wt
svetlyak40wt / weblocks-toast.lisp
Last active December 31, 2020 13:19 — forked from bamboospirit/weblocks toast.lisp
weblocks simple toast effect (common lisp web framework ui frontend)
(ql:quickload '(:weblocks :weblocks-lass :weblocks-navigation-widget :weblocks-ui :find-port))
(defpackage app-package
(:use #:cl
#:weblocks-ui/form
#:weblocks/html)
(:import-from #:parenscript #:ps #:chain)
(:import-from #:weblocks-navigation-widget #:defroutes)
(:import-from #:weblocks/routes #:reset-routes)
(:import-from #:weblocks/session #:*session*)
@svetlyak40wt
svetlyak40wt / lw-current-lang.lisp
Created December 12, 2020 17:03
An example how to get user's preferred language on OSX and Windows using LispWorks.
#+cocoa
(defun current-language ()
(let ((lang (objc:with-autorelease-pool ()
(objc:invoke-into
'string
(objc:invoke
(objc:invoke "NSUserDefaults" "standardUserDefaults")
"objectForKey:" "AppleLanguages")
"objectAtIndex:" 0))))
;; 2019-04-29