Skip to content

Instantly share code, notes, and snippets.

@vwood
vwood / ecldemo.c
Created November 4, 2010 03:49
Example of ECL in a C program.
/*
Example of a C program embedding ECL with callbacks to C functions.
Compiled via: gcc ecldemo.c -lecl
*/
#include <stdio.h>
#include <stdlib.h>
#include "ecl/ecl.h"
#define DEFUN(name,fun,args) \
cl_def_c_function(c_string_to_object(name), \
@eschulte
eschulte / gist:902174
Created April 4, 2011 18:52
use bind to restructure arguments to lambda expressions
(defmacro lambdab ((&rest instrs) &rest body)
"Use `bind' to allow restructuring of argument to lambda expressions."
(declare (indent 1))
(let* ((evald-instrs instrs)
(syms (mapcar (lambda (_) (gensym)) evald-instrs)))
`(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body))))
;; example usage
(let ((fn (lambdab ((a b) c) (cons a c))))
(funcall fn '(1 2) 3)) ;; => (1 . 3)
; The Lisp defined in McCarthy's 1960 paper, translated into CL.
; Assumes only quote, atom, eq, cons, car, cdr, cond.
; Bug reports to lispcode@paulgraham.com.
(defun null. (x)
(eq x '()))
(defun and. (x y)
(cond (x (cond (y 't) ('t '())))
('t '())))
\ This is an implementation of quotations and some combinators
\ for use with Forth. The combinators should work with most
\ Forth systems; the quotation implementation here is gForth
\ specific.
\ ************************************************************
\ dip
\ Stack: value quote -- value
\ Executes a quotation with a value being temporarily removed
@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active July 27, 2024 18:46
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@nicebyte
nicebyte / dyn_arr.h
Last active July 1, 2024 10:44
dyn_arr
#pragma once
#define DYN_ARR_OF(type) struct { \
type *data; \
type *endptr; \
uint32_t capacity; \
}
#if !defined(__cplusplus)
#define decltype(x) void*
@mfikes
mfikes / ESP32-REPL.md
Last active July 6, 2022 22:32
ClojureScript REPL into ESP32

To set up a REPL that has cljs.core available, we need to re-partition the ESP32 and allocate more memory in Espruino for "JsVars".

The default Espruino bootloader.bin, pre-built variants of partitions_esprinuo.bin and rebuilt espruino_esp32.bin, and the ClojureScript runtime core.bin are also available here.

bootloader.bin gets flashed to 0x1000, partitions_espruino.bin gets flashed to 0x8000, and espruino_esp32.bin gets flashed to 0x10000 as per a usual ESP32 Espruino setup, and we put the ClojureScript runtime at 0x2C0000:

@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

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)

(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