Skip to content

Instantly share code, notes, and snippets.

View mistivia's full-sized avatar

小葉薜荔 mistivia

View GitHub Profile
@mistivia
mistivia / define-macro.rkt
Created February 22, 2024 11:34
Common Lisp-like macro definition(defmacro) in Racket
#lang racket
(provide define-macro)
(define-syntax define-macro
(lambda (x)
(syntax-case x ()
((_ (macro . args) body ...)
#'(define-macro macro (lambda args body ...)))
((_ macro transformer)
# Adapted from `make chibi-scheme-static SEXP_USE_DL=0`
CC = musl-gcc
CFLAGS = -Iinclude -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -DSEXP_USE_DL=0 -g -g3 -O3
all: libchibi-scheme-static.a
libchibi-scheme-static.a: gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o
ar rcs $@ $^
@mistivia
mistivia / define-macro.scm
Last active March 7, 2024 11:06 — forked from yuhr/macro.ss
macro.ss: Defining macros simply on chez scheme.
;; Defining macros simply on chez scheme. This code is in the public domain.
(define-syntax define-macro
(syntax-rules ()
((k (name . args) body ...)
(define-macro name (lambda args body ...)))
((k name transformer)
(define-syntax name
(lambda (stx)
(syntax-case stx ()
@mistivia
mistivia / blog-font.css
Created March 17, 2024 08:39
font config of my blog
@font-face {
font-family: "sans-chinese";
src: local("WenQuanYi Micro Hei"), local("PingFang SC"), local("Noto Sans SC"), local("Noto Sans CJK SC"), local("Source Han Sans CN"), local("Microsoft YaHei"), local("PingFang TC"), local("Noto Sans TC"), local("Noto Sans CJK TC"), local("Source Han Sans TW"), local("Microsoft JhengHei"), local("sans-serif");
unicode-range: U+2000-FFFF
}
body {
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", sans-chinese, monospace;
// ....
}
;; This is a new version of pmatch (August 8, 2012).
;; It has two important new features:
;; 1. It allows for a name to be given to the pmatch if an error ensues.
;; 2. A line from the specification has been removed. (see below). Without
;; that line removed, it was impossible for a pattern to be (quote ,x),
;; which might be worth having especially when we write an interpreter
;; for Scheme, which includes quote as a language form.
;;; Code written by Oleg Kiselyov
;; (http://pobox.com/~oleg/ftp/)
@mistivia
mistivia / my-guile.sh
Created April 5, 2024 04:38
fitler guile's auto compile message
#!/bin/bash
exec rlwrap /usr/bin/guile "$@" 2> >(grep -E -v '^;;; ' >&2)
@mistivia
mistivia / longdoc-template.typ
Last active December 1, 2024 08:02
typst template for documents
// typst compile doc-template.typ
// Output: doc-template.pdf
#set text(font: (
"Libertinus Serif",
"Source Han Serif",
))
#set heading(numbering: "1.")
#set page(
paper: "a4",
@mistivia
mistivia / tex2jpg.sh
Created September 1, 2024 08:32
convert latex formula to jpeg image
#!/bin/bash
# usage: echo '$$E=mc^2$$' | tex2jpg out.jpg
PPWD=$(pwd)
DIR=/tmp/$(head -c10 /dev/urandom | base32)
mkdir -p $DIR
cd $DIR && \
echo '\documentclass{minimal}' > input.tex && \
@mistivia
mistivia / define-macro.scm
Created November 21, 2024 02:03
procedure macro in chicken scheme
(import (chicken syntax))
(define-syntax define-macro
(er-macro-transformer
(lambda (exp r c)
(let ((def (cadr exp))
(body (cddr exp)))
`(define-syntax ,(car def)
(er-macro-transformer
(lambda (e2 r2 c2)
@mistivia
mistivia / dhcpd.conf
Last active November 26, 2024 03:31
Tap Network with NAT for QEMU
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.50.0 netmask 255.255.255.0 {
option domain-name-servers 8.8.8.8, 8.8.4.4;
option routers 192.168.50.1;
option subnet-mask 255.255.255.0;
range 192.168.50.100 192.168.50.200;
}