Skip to content

Instantly share code, notes, and snippets.

View cwfoo's full-sized avatar

Foo Chuan Wei cwfoo

View GitHub Profile
@cwfoo
cwfoo / polyml-syntax-check.sml
Created May 21, 2022 06:45
Check syntax of Standard ML program using Poly/ML without executing the program
(* Check for syntax errors and type errors in a Standard ML file without
* executing the program. Tested in Poly/ML 5.9 on Ubuntu 20.04.
*
* To check for the existence of errors in a Standard ML file using Poly/ML, it
* is sufficient to use `PolyML.compiler (TextIO.input1 inStream, [])`. However,
* that will not show line and column numbers when there are errors or warnings.
* This program adds line and column numbers to the error and warning messages.
*
* Usage:
* poly --script this-file.sml file-to-check.sml
@cwfoo
cwfoo / scheme-coin.lisp
Created April 28, 2022 12:26 — forked from BusFactor1Inc/scheme-coin.lisp
A Common Lisp Blockchain - Scheme Coin
;;
;; scheme coin - a common lisp blockchain
;;
;; Burton Samograd
;; 2017
(load "~/quicklisp/setup.lisp")
(defconstant *coin-name* "Scheme Coin")
@cwfoo
cwfoo / rot13.sh
Created April 27, 2022 06:03
The ROT13 substitution cipher
#!/bin/sh
# The ROT13 substitution cipher.
[ "$#" -ne 1 ] && printf 'usage: rot13 string\n' && exit 1
printf '%s\n' "$1" | LC_ALL=C tr 'A-Za-z' 'N-ZA-Mn-za-m'
abbey
abducts
ability
ablaze
abnormal
abort
abrasive
absorb
abyss
academy
@cwfoo
cwfoo / eval-when-test.lisp
Created April 15, 2022 20:28 — forked from ANDRON94/eval-when-test.lisp
Explanation of how 'eval-when' works in Common Lisp
;;; explanation for LOAD *.lisp
;;; 1. Load ignores :compile-toplevel, :load-toplevel
;;; Result: NIL is returned
;;; explanation for COMPILE
;;; 1. not-compile-time(NCT)
;;; 2. ignore mode, EVAL, remains in current mode
;;; Result: print to output 'foo-compile'
;;; explanation for LOAD *.fasl
@cwfoo
cwfoo / html.lisp
Created November 16, 2021 04:38 — forked from markasoftware/html.lisp
html->string (Super simple HTML templating for Lisp)
;; Copyright (c) 2020 Mark Polyakov
;; Released under the WTFPL (Do What The Fuck You Want To Public License)
(defvar *html-void-tags* '(:area :base :br :col :embed :hr :img :input :link
:meta :param :source :track :wbr)
"String designators for self-closing/void tags.
https://html.spec.whatwg.org/multipage/syntax.html#void-elements")
(defvar *html-escapes*
'(#\> ">"
@cwfoo
cwfoo / srfi-1-symbols.txt
Created October 30, 2021 00:58
List of all symbols from SRFI 1 (List Library). https://srfi.schemers.org/srfi-1/srfi-1.html
alist-cons
alist-copy
alist-delete
alist-delete!
any
append
append!
append-map
append-map!
append-reverse
@cwfoo
cwfoo / scheme-r7rs-small-symbols.txt
Last active October 30, 2021 00:46
List of all symbols from Scheme R7RS-small (all libraries).
*
+
-
...
/
<
<=
=
=>
>
@cwfoo
cwfoo / common-lisp-symbols.txt
Created October 30, 2021 00:41
List of Common Lisp symbols from the Common Lisp HyperSpec alphabetical symbol index.
&allow-other-keys
&aux
&body
&environment
&key
&optional
&rest
&whole
*
**
@cwfoo
cwfoo / xv6-rev11.patch
Created October 19, 2021 13:13
Prevent 100% CPU utilization by QEMU when running xv6 OS.
Patch for the xv6 operating system (version: xv6-rev11).
Prevents 100% CPU utilization by QEMU.
diff --git a/proc.c b/proc.c
index 806b1b1..bd35f7b 100644
--- a/proc.c
+++ b/proc.c
@@ -322,6 +322,7 @@ wait(void)
void
scheduler(void)