Skip to content

Instantly share code, notes, and snippets.

@sogaiu
sogaiu / gist:d7ac333b751ed964511bc22f75942293
Last active May 7, 2021
sample meg/match debug output
View gist:d7ac333b751ed964511bc22f75942293
(meg/match ~(sequence "ab"
(choice "c" "x"))
"abc")
;;; would like to improve the ability to visualize the following output
sequence >
captures: @[]
tagged_captures: @[]
peg: (sequence "ab" (choice "c" "x"))
@sogaiu
sogaiu / gist:ce48cb7ddc9421b5e457891d4763558f
Last active May 7, 2021
some issues encountered when learning to use janet's peg system
View gist:ce48cb7ddc9421b5e457891d4763558f
* the return value of `peg/match` is either `nil` -- which means that overall
matching failed (though submatches might have succeeded) -- or an array
that can contain matches (see below for more details). many of the
initial examples don't actually "capture" though so one keeps seeing
an empty array as a return value.
* `peg/match` does do matching, but it also "captures" along with the ability
to perform essentially arbitrary computations on values that are "captured".
so the name `peg/match` might be seen as a bit misleading.
View gist:b66b18d5ac28e909b85375a87f3edd4b
* each "card" has:
* one question
* set of answers (correct and incorrect)
* pointers to look up answers
* forum to discuss cards
* the traditional bottom-up approach based on learning individual elements
in isolation may sometimes not work so well. it may be that sometimes
it is better to try to start by teaching / learning simple combinations.
@sogaiu
sogaiu / main.janet
Last active May 6, 2021
leverage spork/regex to help transition to using pegs
View main.janet
(import spork/regex)
(comment
(regex/source "a")
# => "a"
(regex/source `\s`)
# => '(set "\n\t\r\v\f ")
View gist:40b063ffc6ab8135bb247e019cb5ca50
# instructions based on system crafters
# inside an ubuntu system (or any systemd-based system?)
cd /tmp
wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
chmod +x guix-install.sh
sudo ./guix-install.sh
wget "https://sv.gnu.org/people/viewgpg.php?user_id=127547" -qO - | sudo -i gpg --import -
wget "https://sv.gnu.org/people/viewgpg.php?user_id=15145" -qO - | sudo -i gpg --import -
@sogaiu
sogaiu / gist:912914c04e1d1948d45211767334ed14
Created May 5, 2021
listview demo with kamisori's jaylib
View gist:912914c04e1d1948d45211767334ed14
(use ./build/jaylib)
(defn- make-window
"open window with default values"
[]
(set-config-flags :msaa-4x-hint)
(init-window 800 600 "Place")
(set-target-fps 60)
(set-exit-key 0))
View gist:49ef2dbd37d3b8319cc5e70dfc166326
;; Install edebug read and eval functions.
(edebug-install-read-eval-functions)
;
(defun edebug-install-read-eval-functions ()
(interactive)
(add-function :around load-read-function #'edebug--read)
(advice-add 'eval-defun :override #'edebug-eval-defun))
@sogaiu
sogaiu / pretty-literals.lisp
Created May 3, 2021 — forked from rmoritz/pretty-literals.lisp
pretty hash table & vector literal syntax for common lisp
View pretty-literals.lisp
;;;; pretty-literals.lisp - pretty hash table & vector literal syntax
;;;; inspired by and uses code from http://frank.kank.net/essays/hash.html
(in-package #:pretty-literals)
;; vector literal syntax using brackets
(set-macro-character #\[
(lambda (str char)
(declare (ignore char))
(let ((*readtable* (copy-readtable *readtable* nil))
View gist:9e4c7e47353c43a18c5dc44b240c55c9
possible results
* janet source step debugger
* margaret source step debugger
* babashka source step debugger
* location or creation of clear description of edebug
* location or creation of clear description of cider debug
* location or creation of clear description of sly stepper
---
@sogaiu
sogaiu / mypr.el
Last active Apr 30, 2021
setting up s-x (super x) as prefix key in emacs
View mypr.el
;; mypr is short for "my prefix"
(defvar mypr-map (make-sparse-keymap)
"Global keymap for custom prefix commands.")
(defalias 'mypr-prefix mypr-map)
;; XXX: change "s-x" to something else if desired
(define-key global-map (kbd "s-x") 'mypr-prefix)
(define-key mypr-map "b" 'butterfly)