Skip to content

Instantly share code, notes, and snippets.

@tcsullivan
tcsullivan / day3.fth
Created January 18, 2025 14:18
Breakdown of day 3 solution for Advent of Code 2024
\ "string =", really a "starts with" check. Returns true if the first u2 characters
\ in c-addr2 match c-addr1.
: s= ( c-addr1 c-addr2 u2 -- b )
tuck compare 0= ;
\ Reads up to 99 digits from c-addr and parses them into a number. Returns the number
\ and c-addr2 which points to the character beyond the parsed number.
: get-number ( c-addr -- n c-addr2 )
99 0 s>d 2swap >number rot 2drop ;
@Lovesan
Lovesan / excel-interop.lisp
Created February 22, 2024 21:45
Excel interop using bike library
(eval-when (:compile-toplevel :load-toplevel :execute)
(unless (find-package 'bike)
(ql:quickload 'bike)))
(named-readtables:in-readtable bike:bike-syntax)
(bike:use-namespace 'System)
;; The below is required to overcome internal bike optimizations related to property retrieval,
;; which utilize Type.GetProperty internally, which does not work for COM objects.
;; Note that you should also use bike:reflection-invoke instead of invoke, for the same reasons.

sb-simd: Multiplying a 4x4 matrix with a 4-length vector (AVX)

(require 'sb-simd)
(defpackage :simd-pack-user
  (:use :sb-simd-avx :cl))
(in-package :simd-pack-user)

I'm assuming you are referring to the following operation:

@ivan4th
ivan4th / 1password.lisp
Created June 24, 2022 23:37
Inecobank scraping
(in-package :yobabank)
(defparameter *1pw-secure-note-name* "Yobabank Data")
(defparameter *1pw-vault* "Personal")
(defun 1pw-get-field (object name)
(when (typep object 'st-json:jso)
(st-json:getjso name object)))
(defun 1pw-get-id (object)
@ArooBaito
ArooBaito / webhook.scm
Last active August 7, 2021 20:35
Minimal Discord http-post requests from various Scheme implementations
;; Documentation on http post requests is a lot of guess-work in certain Scheme implementations.
;; To save some frustration, here is a compilation of examples on how to get a Discord
;; webhook bot to say a simple message from the various Schemes using default libraries
;; To the right is also the command to connect Emacs using inferior Scheme
;; BiwaScheme [browser] (setq scheme-program-name "shamisen-emacs") [see biwa-shamisen]
(http-post "https://discord.com/api/webhooks/[your info here]"
'(("content" . "Hello from BiwaScheme!")))
;; BiwaScheme [node] [not implemented] (setq scheme-program-name "biwas")
@Bike
Bike / dcont.lisp
Last active November 3, 2024 23:03
delimited continuation macro transformer
(defpackage #:delimited-continuations
(:use #:cl)
(:export #:with/dc #:reset #:shift))
(in-package #:delimited-continuations)
(defmacro letcont ((&whole binding name lambda-list &body cbody) &body body)
(let ((old (gensym "OLD")))
(multiple-value-bind (cforms cdecls)
(alexandria:parse-body cbody :whole binding)
@christophejunke
christophejunke / events.lisp
Last active June 26, 2021 19:42
Event loop with ncurse
(ql:quickload '(:iolib :cl-charms))
(defpackage :tui (:use :cl :cl-charms :iomux))
(in-package :tui)
;;; From http://turtleware.eu/posts/cl-charms-crash-course.html
(defun start-color ()
(when (eql (charms/ll:has-colors) charms/ll:FALSE)
(error "Your terminal does not support color."))
(let ((ret-code (charms/ll:start-color)))
(defpackage :LISP-1.5-compiler
(:use :Common-Lisp)
(:shadow :length ; defined by the compiler
:reverse ; defined by the compiler
:member ; defined by the compiler
:map ; like mapl, and function is first argument
:exp ; used as special variable in the compiler
:compile ; defined by the compiler
:maplist ; takes function first
:mapcon ; takes function first

Guix on WSL2

(updated versions of this document, plus more, live here)

This will show you how to get Guix running on WSL2.
We're going to go as "minimal" as possible, without starting off one of the readily available WSL2 distros.
Parts of this guide should help with understanding how to set up any custom distro on WSL, not just Guix.

Disclaimer: I'm a Guix nOOb! (hence going through the trouble of installing it on WSL2)

@belmarca
belmarca / cb.ss
Created April 26, 2020 01:05
Hooking gambit's ##wr.
;; cb.ss
(defstruct ugly-struct (a b c))
(defstruct wonderful-struct (a b c))
(defmethod {:wr wonderful-struct}
(lambda (self we obj)
(with ((wonderful-struct a b c) self)
(##wr-str we "🦄<")
(##wr-str we " 🌈🌈🌈 ")
(##wr-str we (string-append