Skip to content

Instantly share code, notes, and snippets.

View ashok-khanna's full-sized avatar
🏠
Working from home

Ashok Khanna ashok-khanna

🏠
Working from home
View GitHub Profile
(defun make-url-part (title)
"Generate a url-part from a title. A url-part should only have alphanumeric characters or dashes (in place of spaces)."
(string-downcase
(delete-if #'(lambda (x) (not (or (alphanumericp x) (char= #\- x))))
(substitute #\- #\Space title))))
(ql:quickload '("clack" "lack" "lack-middleware-mount" "cl-dotenv" "quri" "uuid" "dexador" "jsown"))
(defpackage #:example
(:use #:common-lisp))
(in-package #:example)
(.env:load-env (merge-pathnames ".env"))
(defvar *okta-authorize-uri* (quri:uri (uiop:getenv "OKTA_AUTHORIZE_URI")))
@ashok-khanna
ashok-khanna / _reader-macros.md
Created August 25, 2021 17:52 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@ashok-khanna
ashok-khanna / test.lisp
Created September 29, 2021 18:25
common lisp implementation limits
CL-USER> (values call-arguments-limit lambda-parameters-limit multiple-values-limit (lisp-implementation-type))
4611686018427387903 (62 bits, #x3FFFFFFFFFFFFFFF)
4611686018427387903 (62 bits, #x3FFFFFFFFFFFFFFF)
4611686018427387903 (62 bits, #x3FFFFFFFFFFFFFFF)
"SBCL"
CL-USER> (values call-arguments-limit lambda-parameters-limit multiple-values-limit (lisp-implementation-type))
65536
4096
200
@ashok-khanna
ashok-khanna / gist:36f4732018661d84dc0687a7ecf969d6
Created October 1, 2021 19:03 — forked from romainl/gist:1f93db9dc976ba851bbb
Vim: available lowercase key pairs in normal mode…
cd cm co cp cq cr cs cu cv cx cy cz
dc dm dq dr ds du dv dx dy dz
gb gc gl gs gy
vc vd vm vo vp vq vr vs vu vv vx vy vz
yc yd ym yo yp yq yr ys yu yv yx yz
@ashok-khanna
ashok-khanna / cl-history.txt
Created October 6, 2021 08:44 — forked from agumonkey/cl-history.txt
Detailed account and personal insights on the history of common-lisp
From welch@thor.oar.net Thu Oct 20 16:53:41 EDT 1994
Article: 15160 of comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!usenet.eel.ufl.edu!usenet.cis.ufl.edu!caen!math.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ns.mcs.kent.edu!kira.cc.uakron.edu!malgudi.oar.net!malgudi.oar.net!welch
From: welch@thor.oar.net (Arun Welch)
Newsgroups: comp.lang.lisp
Subject: CL History (was Re: Why do people like C?)
Date: 20 Oct 94 15:34:10
Organization: OARnet
Lines: 3244
Message-ID: <WELCH.94Oct20153410@thor.oar.net>
@ashok-khanna
ashok-khanna / tfidf.lisp
Created October 9, 2021 10:20 — forked from death/tfidf.lisp
tfidf
;; Suppose we have a collection of N documents.
;; Define Fij to be the frequency of term i in document j.
;; Define TFij to be Fij/max(k,Fkj),
;; that is, the term frequency of term i in document j is Fij
;; normalized by dividing it by the maximum number of occurrences
;; of any term in the same document.
;; Define IDFi to be log2(N/ni).
;; The TF.IDF score for term i in document j is then defined to be
;; TFij x IDFi. The terms with the highest TF.IDF score are often
;; the terms that best characterize the topic of the document.
@ashok-khanna
ashok-khanna / filename.md
Created October 22, 2021 17:41
How to get file name of a defined function?
@ashok-khanna
ashok-khanna / irc.txt
Created October 30, 2021 08:00 — forked from nikodemus/irc.txt
Notes re. debugging Common Lisp with SBCL and Slime
Context from IRC logs for future reference.
[12:36] <kushal> nikodemus, can you point me to some tutorial on debugging on sbcl ?
[12:37] * andreer (andreer@flode.pvv.ntnu.no) has joined #quicklisp
[12:38] <nikodemus> kushal: no really good ones actually exist at the moment. i'm planning on writing one before the year is out, but... in the meanwhile, i can give some pointers
[12:38] <nikodemus> a couple of questions: is this a general question, or do you have a specific issue you need to debug?
[12:39] <kushal> right now , general, managed to debug the specific issue somehow :)
[12:39] <nikodemus> ok. are you using slime?
[12:39] <kushal> nikodemus, yes and no both
[12:40] <nikodemus> good. :)
;;;;****************************************************************************
;;;; SPECIALIZING SLOTS WITH THE DEFINE-CLASS MACRO
;;;;****************************************************************************
;;;;***** RATIONALE ************************************************************
;;; In this file, we introduce a DEFINE-CLASS macro that proposes a particular
;;; approach to defining CLOS classes such that type information is retained