diff options
author | EuAndreh <eu@euandre.org> | 2025-03-31 21:51:40 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2025-03-31 21:51:40 -0300 |
commit | 570ec471d1605318aeefb030cd78682ae442235b (patch) | |
tree | 51e17eabe37c6689f8799b55e6875c3480329a2c /src/content/pastebins | |
parent | Makefile, mkdeps.sh: Derive index.html and feed.xml from more static "sortdat... (diff) | |
download | euandre.org-570ec471d1605318aeefb030cd78682ae442235b.tar.gz euandre.org-570ec471d1605318aeefb030cd78682ae442235b.tar.xz |
src/content/: Update all files left to asciidoc
Diffstat (limited to 'src/content/pastebins')
22 files changed, 160 insertions, 424 deletions
diff --git a/src/content/pastebins/2016/04/05/rpn.adoc b/src/content/pastebins/2016/04/05/rpn.adoc index 25ca6ba..c567d0d 100644 --- a/src/content/pastebins/2016/04/05/rpn.adoc +++ b/src/content/pastebins/2016/04/05/rpn.adoc @@ -1,18 +1,7 @@ ---- += RPN macro setup -title: RPN macro setup - -date: 2016-04-05 - -layout: post - -lang: en - -ref: rpn-macro-setup - ---- - -```lisp +[source,lisp] +---- (defmacro rpn (body) (rpn-expander body)) @@ -31,4 +20,4 @@ Just a quick stub. One could easily improve #'RPN-EXPANDER in order to better suit one's needs. |# -``` +---- diff --git a/src/content/pastebins/2018/07/11/nix-pinning.adoc b/src/content/pastebins/2018/07/11/nix-pinning.adoc index 2d35e09..d4bc905 100644 --- a/src/content/pastebins/2018/07/11/nix-pinning.adoc +++ b/src/content/pastebins/2018/07/11/nix-pinning.adoc @@ -1,20 +1,7 @@ ---- += Nix pinning -title: Nix pinning - -date: 2018-07-11 - -layout: post - -lang: en - -eu_categories: nix - -ref: nix-pinning - ---- - -```nix +[source,nix] +---- let # Pin the nixpkgs version stdenv = pkgs.stdenv; @@ -35,4 +22,4 @@ in rec { patches = []; }; } -``` +---- diff --git a/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc b/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc index c2b8b62..729e981 100644 --- a/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc +++ b/src/content/pastebins/2018/07/13/guix-nixos-systemd.adoc @@ -1,20 +1,7 @@ ---- += GNU Guix systemd daemon for NixOS -title: GNU Guix systemd daemon for NixOS - -date: 2018-07-13 - -layout: post - -lang: en - -eu_categories: nix,guix - -ref: gnu-guix-systemd-daemon-for-nixos - ---- - -```nix +[source,nix] +---- # Derived from Guix guix-daemon.service.in # https://git.savannah.gnu.org/cgit/guix.git/tree/etc/guix-daemon.service.in?id=00c86a888488b16ce30634d3a3a9d871ed6734a2 systemd.services.guix-daemon = { @@ -30,4 +17,4 @@ ref: gnu-guix-systemd-daemon-for-nixos }; wantedBy = [ "multi-user.target" ]; }; -``` +---- diff --git a/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc b/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc index 880d347..b000cd3 100644 --- a/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc +++ b/src/content/pastebins/2018/07/13/guixbuilder-nixos.adoc @@ -1,20 +1,7 @@ ---- += Guix users in NixOS system configuration -title: Guix users in NixOS system configuration - -date: 2018-07-13 - -layout: post - -lang: en - -eu_categories: nix,guix - -ref: guix-users-in-nixos-system-configuration - ---- - -```nix +[source,nix] +---- users = { mutableUsers = false; @@ -50,4 +37,4 @@ ref: guix-users-in-nixos-system-configuration name = "guixbuild"; }; }; -``` +---- diff --git a/src/content/pastebins/2018/07/13/guixbuilder.adoc b/src/content/pastebins/2018/07/13/guixbuilder.adoc index 82204a8..84e84d9 100644 --- a/src/content/pastebins/2018/07/13/guixbuilder.adoc +++ b/src/content/pastebins/2018/07/13/guixbuilder.adoc @@ -1,20 +1,7 @@ ---- += Guix builder user creation commands -title: Guix builder user creation commands - -date: 2018-07-13 - -layout: post - -lang: en - -eu_categories: guix - -ref: guix-builder-user-creation-commands - ---- - -```shell +[source,shell] +---- groupadd --system guixbuild for i in `seq -w 1 10`; do @@ -23,4 +10,4 @@ do -c "Guix build user $i" --system \ guixbuilder$i; done -``` +---- diff --git a/src/content/pastebins/2018/07/13/nix-strpad.adoc b/src/content/pastebins/2018/07/13/nix-strpad.adoc index 359bda5..0557b79 100644 --- a/src/content/pastebins/2018/07/13/nix-strpad.adoc +++ b/src/content/pastebins/2018/07/13/nix-strpad.adoc @@ -1,19 +1,6 @@ ---- += Nix string padding -title: Nix string padding - -date: 2018-07-13 - -layout: post - -lang: en - -eu_categories: nix - -ref: nix-string-padding - ---- - -```nix +[source,nix] +---- padString = (n: if n < 10 then "0" + toString n else toString n) -``` +---- diff --git a/src/content/pastebins/2018/07/25/nix-exps.adoc b/src/content/pastebins/2018/07/25/nix-exps.adoc index 23d75b6..824be69 100644 --- a/src/content/pastebins/2018/07/25/nix-exps.adoc +++ b/src/content/pastebins/2018/07/25/nix-exps.adoc @@ -1,20 +1,7 @@ ---- += Nix exps -title: Nix exps - -date: 2018-07-25 - -layout: post - -lang: en - -eu_categories: nix - -ref: nix-exps - ---- - -```nix +[source,nix] +---- let pkgsOriginal = import <nixpkgs> {}; pkgsSrc = pkgsOriginal.fetchzip { @@ -55,4 +42,4 @@ in rec { ''; }; } -``` +---- diff --git a/src/content/pastebins/2018/07/25/nix-showdrv.adoc b/src/content/pastebins/2018/07/25/nix-showdrv.adoc index 813965d..d7a2d9a 100644 --- a/src/content/pastebins/2018/07/25/nix-showdrv.adoc +++ b/src/content/pastebins/2018/07/25/nix-showdrv.adoc @@ -1,20 +1,7 @@ ---- += nix show-derivation sample output -title: nix show-derivation sample output - -date: 2018-07-25 - -layout: post - -lang: en - -eu_categories: nix - -ref: nix-show-derivation-sample-output - ---- - -```nix +[source,nix] +---- $ nix show-derivation /nix/store/zzz9cl2ly0mb2njr7vwa5528fxmn29m8-combofont-0.2.drv { "/nix/store/zzz9cl2ly0mb2njr7vwa5528fxmn29m8-combofont-0.2.drv": { @@ -83,4 +70,4 @@ $ nix show-derivation /nix/store/zzz9cl2ly0mb2njr7vwa5528fxmn29m8-combofont-0.2. } } } -``` +---- diff --git a/src/content/pastebins/2019/06/08/inconsistent-hash.adoc b/src/content/pastebins/2019/06/08/inconsistent-hash.adoc index 51d8ad3..5877018 100644 --- a/src/content/pastebins/2019/06/08/inconsistent-hash.adoc +++ b/src/content/pastebins/2019/06/08/inconsistent-hash.adoc @@ -1,35 +1,24 @@ ---- += Inconsistent hash of buildGoModule -title: Inconsistent hash of buildGoModule +:commit: https://euandre.org/git/servers/commit?id=6ba76140238b5e3c7009c201f9f80ac86063f438 -date: 2019-06-08 +'''' -layout: post +FIXED: The `<nixpkgs>` was different on different environments. See +https://discourse.nixos.org/t/inconsistent-hash-of-buildgomodule/3127/2. -lang: en +'''' -eu_categories: nix +The {commit}[commit that made this visible]. -ref: inconsistent-hash-of-buildgomodule +== Offending derivation: ---- +:orig-src: https://euandre.org/git/servers/tree/default.nix?id=6ba76140238b5e3c7009c201f9f80ac86063f438#n3 -FIXED: The `<nixpkgs>` was different on different environments. -See <https://discourse.nixos.org/t/inconsistent-hash-of-buildgomodule/3127/2>. +{orig-src}[Full source code on the repository]: ---- - -The [commit that made this visible][0]. - -[0]: https://euandre.org/git/servers/commit?id=6ba76140238b5e3c7009c201f9f80ac86063f438 - -## Offending derivation: - -[Full source code on the repository][1]: - -[1]: https://euandre.org/git/servers/tree/default.nix?id=6ba76140238b5e3c7009c201f9f80ac86063f438#n3 - -```nix +[source,nix] +---- terraform-godaddy = pkgs.buildGoModule rec { name = "terraform-godaddy-${version}"; version = "1.6.4"; @@ -43,11 +32,12 @@ terraform-godaddy = pkgs.buildGoModule rec { postInstall = "mv $out/bin/terraform-godaddy $out/bin/terraform-provider-godaddy"; }; -``` +---- -## Local build: +== Local build: -```shell +[source,shell] +---- $ nix-build -A terraform-godaddy these derivations will be built: /nix/store/3hs274i9qdsg3hsgp05j7i5cqxsvpcqx-terraform-godaddy-1.6.4-go-modules.drv @@ -193,14 +183,15 @@ hash mismatch in fixed-output derivation '/nix/store/jgbfkhlsz6bmq724p5cqqcgfyc7 got: sha256:10n2dy7q9kk1ly58sw965n6qa8l0nffh8vyd1vslx0gdlyj25xxs cannot build derivation '/nix/store/y5961vv6y9c0ps2sbd8xfnpqvk0q7qhq-terraform-godaddy-1.6.4.drv': 1 dependencies couldn't be built error: build of '/nix/store/y5961vv6y9c0ps2sbd8xfnpqvk0q7qhq-terraform-godaddy-1.6.4.drv' failed -``` +---- -## Build [on CI](https://builds.sr.ht/~euandreh/job/67836#task-setup-0): +== Build https://builds.sr.ht/~euandreh/job/67836#task-setup-0[on CI]: -The `setup.sh` script contains a call to `nix-shell` which in turns -build the same `terraform-godaddy` derivation: +The `setup.sh` script contains a call to `nix-shell` which in turns build the +same `terraform-godaddy` derivation: -```shell +[source,shell] +---- $ cd vps/ $ ./scripts/ci/setup.sh warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring @@ -1058,4 +1049,4 @@ hash mismatch in fixed-output derivation '/nix/store/q8y0mzjl78hfhazjgq2sc84i7dp cannot build derivation '/nix/store/w4ghinrmpq524k3617ikfc8i42aa0dbb-terraform-godaddy-1.6.4.drv': 1 dependencies couldn't be built copying path '/nix/store/63gjp25l4cmdkl63zy0rcgmsvd2p2p34-terraform-0.11.14' from 'https://cache.nixos.org'... error: build of '/nix/store/9drkn1qxkkcrz5g3413lpmbc2xysa582-terraform-0.11.14.drv', '/nix/store/w4ghinrmpq524k3617ikfc8i42aa0dbb-terraform-godaddy-1.6.4.drv' failed -``` +---- diff --git a/src/content/pastebins/2019/12/29/raku-tuple-type.adoc b/src/content/pastebins/2019/12/29/raku-tuple-type.adoc index 3d5ff34..8bb7250 100644 --- a/src/content/pastebins/2019/12/29/raku-tuple-type.adoc +++ b/src/content/pastebins/2019/12/29/raku-tuple-type.adoc @@ -1,18 +1,7 @@ ---- += Raku tuple type annotation -title: Raku tuple type annotation - -date: 2019-12-29 - -layout: post - -lang: en - -ref: raku-tuple-type-annotation - ---- - -```perl +[source,perl] +---- # Single Str return value: this works sub f1(Str $in --> Str) { $in; @@ -27,11 +16,12 @@ sub f2(Str $in) { sub f2(Str $in --> (Str, Str)) { ($in, $in); } -``` +---- Error log is: -```perl +[source,perl] +---- ===SORRY!=== Error while compiling /path/to/my/file Malformed return value -``` +---- diff --git a/src/content/pastebins/2020/01/04/guix-import-failure.adoc b/src/content/pastebins/2020/01/04/guix-import-failure.adoc index 3388a8d..9e5d987 100644 --- a/src/content/pastebins/2020/01/04/guix-import-failure.adoc +++ b/src/content/pastebins/2020/01/04/guix-import-failure.adoc @@ -1,20 +1,7 @@ ---- += Failure on Guix TeX Live importer -title: Failure on Guix TeX Live importer - -date: 2020-01-04 - -layout: post - -lang: en - -eu_categories: guix - -ref: failure-on-guix-tex-live-importer - ---- - -```shell +[source,shell] +---- $ guix import texlive fontspec redirection vers « https://ctan.org/xml/1.2/pkg/fontspec »... Backtrace: @@ -44,4 +31,4 @@ In guix/build/utils.scm: guix/build/utils.scm:652:6: In procedure invoke: Throw to key `srfi-34' with args `(#<condition &invoke-error [program: "svn" arguments: ("export" "--non-interactive" "--trust-server-cert" "-r" "49435" "svn://www.tug.org/texlive/tags/texlive-2018.2/Master/texmf-dist/source/latex/fontspec" "/tmp/guix-directory.WtLohP") exit-status: 1 term-signal: #f stop-signal: #f] 7fe80d229c80>)'. -``` +---- diff --git a/src/content/pastebins/2020/02/14/guix-shebang.adoc b/src/content/pastebins/2020/02/14/guix-shebang.adoc index 67d504d..862b12f 100644 --- a/src/content/pastebins/2020/02/14/guix-shebang.adoc +++ b/src/content/pastebins/2020/02/14/guix-shebang.adoc @@ -1,23 +1,10 @@ ---- += Guix shebang -title: Guix shebang - -date: 2020-02-14 - -layout: post - -lang: en - -eu_categories: guix - -ref: guix-shebang - ---- - -```shell +[source,shell] +---- #!/usr/bin/env -S guix environment --ad-hoc bash -- bash set -Eeuo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" pwd -``` +---- diff --git a/src/content/pastebins/2020/11/27/guix-build-local.adoc b/src/content/pastebins/2020/11/27/guix-build-local.adoc index 350d50f..e703ba6 100644 --- a/src/content/pastebins/2020/11/27/guix-build-local.adoc +++ b/src/content/pastebins/2020/11/27/guix-build-local.adoc @@ -1,25 +1,14 @@ ---- += Guix build local module -title: Guix build local module +FIXED: rename `name` on line 9 of the first snippet, and use `"my-hello"` +instead of `"hello"`. -date: 2020-11-27 - -layout: post - -lang: en - -eu_categories: guix - -ref: guix-build-local-module - ---- - -FIXED: rename `name` on line 9 of the first snippet, and use `"my-hello"` instead of `"hello"`. - ---- +''''' Inside a file named `build.scm`: -```scheme + +[source,scheme] +---- (define-module (build) #:use-module (guix packages) #:use-module (guix download) @@ -42,19 +31,20 @@ Inside a file named `build.scm`: (description "") (home-page "") (license gpl3+))) - -``` +---- A plain build command didn't work: -```shell +[source,shell] +---- $ guix build -L. my-hello guix build: error: my-hello : paquet inconnu -``` +---- But with an eval expression it did: -```shell +[source,shell] +---- $ guix build -L. -e '(@ (build) my-hello)' # works -``` +---- diff --git a/src/content/pastebins/2020/12/15/guix-pack-fail.adoc b/src/content/pastebins/2020/12/15/guix-pack-fail.adoc index 2834f90..72172db 100644 --- a/src/content/pastebins/2020/12/15/guix-pack-fail.adoc +++ b/src/content/pastebins/2020/12/15/guix-pack-fail.adoc @@ -1,28 +1,15 @@ ---- += Failure with relocatable Guix pack tarball -title: Failure with relocatable Guix pack tarball - -date: 2020-12-15 - -layout: post - -lang: en - -eu_categories: guix - -ref: failure-with-relocatable-guix-pack-tarball - ---- +:post: https://guix.gnu.org/blog/2018/tarballs-the-ultimate-container-image-format/ FIXED: Use `GUIX_PROFILE= source etc/profile` ---- +''''' -The example from the [blog post][guix-tarball-article] fails. +The example from the {post}[blog post] fails. -[guix-tarball-article]: https://guix.gnu.org/blog/2018/tarballs-the-ultimate-container-image-format/ - -```shell +[source,shell] +---- $ tar xf `guix pack --relocatable -S /bin=bin -S /etc=etc guile gnutls guile-json` $ source etc/profile $ bin/guile -c '(use-modules (json))' @@ -83,14 +70,16 @@ In ice-9/boot-9.scm: ice-9/boot-9.scm:3300:6: In procedure resolve-interface: no code for module (gnutls) -``` +---- My Guix version if fairly recent: -```shell + +[source,shell] +---- $ guix describe Génération 83 14 déc. 2020 00:28:16 (actuelle) guix 41807eb URL du dépôt : https://git.savannah.gnu.org/git/guix.git branche: master commit : 41807eb5329299b8c45cd49356a4ead01ce0d469 -``` +---- diff --git a/src/content/pastebins/2021/04/03/naive-slugify-js.adoc b/src/content/pastebins/2021/04/03/naive-slugify-js.adoc index f765495..648e5fa 100644 --- a/src/content/pastebins/2021/04/03/naive-slugify-js.adoc +++ b/src/content/pastebins/2021/04/03/naive-slugify-js.adoc @@ -1,20 +1,7 @@ ---- += JavaScript naive slugify -title: JavaScript naive slugify - -date: 2021-04-03 - -updated_at: 2021-08-15 - -layout: post - -lang: en - -ref: javascript-naive-slugify - ---- - -```javascript +[source,javascript] +---- const s = "Pézão: açaí, saci-pererê."; const slugify = s => @@ -37,4 +24,4 @@ const slugify = s => .replaceAll("ç", "c"); console.log(slugify(s)); -``` +---- diff --git a/src/content/pastebins/2021/06/08/reading-session-pt1.adoc b/src/content/pastebins/2021/06/08/reading-session-pt1.adoc index b97ef08..d9f1f91 100644 --- a/src/content/pastebins/2021/06/08/reading-session-pt1.adoc +++ b/src/content/pastebins/2021/06/08/reading-session-pt1.adoc @@ -1,18 +1,7 @@ ---- += Debit Reading Session - SICP solutions pt.1 -title: Debit Reading Session - SICP solutions pt.1 - -date: 2021-06-08 - -layout: post - -lang: en - -ref: debit-reading-session-sicp-solutions-pt-1 - ---- - -```scheme +[source,scheme] +---- ;; 1.41 (define (double f) (lambda (x) @@ -72,6 +61,6 @@ ref: debit-reading-session-sicp-solutions-pt-1 ;;; 2.32 TODO -``` +---- FYI: I just typed those in, I didn't yet test them yet. diff --git a/src/content/pastebins/2021/06/22/curl-wget.adoc b/src/content/pastebins/2021/06/22/curl-wget.adoc index 1030c7b..08caf12 100644 --- a/src/content/pastebins/2021/06/22/curl-wget.adoc +++ b/src/content/pastebins/2021/06/22/curl-wget.adoc @@ -1,20 +1,9 @@ ---- - -title: "cloc: curl and wget" - -date: 2021-06-22 - -layout: post - -lang: en - -ref: cloc-curl-and-wget - ---- += "cloc: curl and wget" `curl`: -```shell +[source,shell] +---- $ pushd `mktemp -d` /tmp/tmp.AZkwvk7azD ~/ $ git clone git://github.com/curl/curl . @@ -62,11 +51,12 @@ TOML 1 0 0 ------------------------------------------------------------------------------------ SUM: 1309 39501 56083 254078 ------------------------------------------------------------------------------------ -``` +---- `wget`: -```shell +[source,shell] +---- $ pushd `mktemp -d` /tmp/tmp.NX0udlJMiz ~/ $ git clone git://git.savannah.gnu.org/wget.git . @@ -99,4 +89,4 @@ lex 1 29 65 73 -------------------------------------------------------------------------------- SUM: 342 11400 14185 52018 -------------------------------------------------------------------------------- -``` +---- diff --git a/src/content/pastebins/2021/08/11/h1-spacing.adoc b/src/content/pastebins/2021/08/11/h1-spacing.adoc index 9a00ece..e8a6986 100644 --- a/src/content/pastebins/2021/08/11/h1-spacing.adoc +++ b/src/content/pastebins/2021/08/11/h1-spacing.adoc @@ -1,29 +1,17 @@ ---- += Spaces around h1 tags -title: Spaces around h1 tags +// FIXME updated_at: 2021-08-15 -date: 2021-08-11 +_EDIT_: Apparently, the behaviour below is consistent between Firefox and +Chromium for links, but not for `<h1>`. My conclusion is that the `<h1>` +behaviour is a Firefox quirk, but the `<a>` is expected. -updated_at: 2021-08-15 - -layout: post - -lang: en - -ref: spaces-around-h1-tags - ---- - -*EDIT*: Apparently, the behaviour below is consistent between Firefox and -Chromium for links, but not for `<h1>`. -My conclusion is that the `<h1>` behaviour is a Firefox quirk, but the `<a>` is -expected. - ---- +''''' The HTML below has selectable extra spaces after `<h1>` tags: -```html +[source,html] +---- <!DOCTYPE html> <html lang="en"> <head> @@ -43,23 +31,22 @@ The HTML below has selectable extra spaces after `<h1>` tags: </main> </body> </html> -``` +---- The rendered output is: -<h1> - With spaces around when selecting this heading -</h1> -<h1>Without spaces around</h1> -<p> - Is this expected behaviour? -</p> +With spaces around when selecting this heading + +Without spaces around ---- +Is this expected behaviour? + +''''' The same with links: -```html +[source,html] +---- <!DOCTYPE html> <html lang="en"> <head> @@ -80,17 +67,10 @@ The same with links: </main> </body> </html> -``` +---- The rendered output is: -<p> - <a href="#"> - With extra underlined space - </a> - after the link. -</p> -<p> - <a href="#">Without extra underlined space</a> - after the link. -</p> +With extra underlined space after the link. + +Without extra underlined space after the link. diff --git a/src/content/pastebins/2021/09/02/sicp-3-19.adoc b/src/content/pastebins/2021/09/02/sicp-3-19.adoc index 75ee346..f6aa8cf 100644 --- a/src/content/pastebins/2021/09/02/sicp-3-19.adoc +++ b/src/content/pastebins/2021/09/02/sicp-3-19.adoc @@ -1,18 +1,7 @@ ---- += SICP exercise 3.19 -title: SICP exercise 3.19 - -date: 2021-09-02 - -layout: post - -lang: en - -ref: sicp-exercise-3-19 - ---- - -```scheme +[source,scheme] +---- (define (cycle? l) (define (rec l x) (cond @@ -20,11 +9,12 @@ ref: sicp-exercise-3-19 ((eq? l x) true) (true (rec l (cdr x))))) (rec l (cdr l))) -``` +---- Sample interactive session: -```scheme +[source,scheme] +---- scheme@(guile-user)> (define true #t) scheme@(guile-user)> (define false #f) scheme@(guile-user)> @@ -39,4 +29,4 @@ scheme@(guile-user)> (cycle? '(1 2 3)) $9 = #f scheme@(guile-user)> (cycle? (make-cycle '(1 2 3))) $10 = #t -``` +---- diff --git a/src/content/pastebins/2021/09/03/sicp-persistent-queue.adoc b/src/content/pastebins/2021/09/03/sicp-persistent-queue.adoc index 8cf7ea2..2b4a8a2 100644 --- a/src/content/pastebins/2021/09/03/sicp-persistent-queue.adoc +++ b/src/content/pastebins/2021/09/03/sicp-persistent-queue.adoc @@ -1,36 +1,25 @@ ---- += SICP persistent amortized O(1) queue -title: SICP persistent amortized O(1) queue - -date: 2021-09-03 - -layout: post - -lang: en - -ref: sicp-persistent-amortized-o1-queue - ---- - -```scheme +[source,scheme] +---- (define (queue) (cons '() - '())) + '())) (define (enqueue x q) (cons (car q) - (cons x (cdr q)))) + (cons x (cdr q)))) (define (flush q) (cons (reverse (cdr q)) - '())) + '())) (define (dequeue q) (if (null? (car q)) (dequeue (flush q)) (cons (caar q) - (cons (cdar q) - (cdr q))))) + (cons (cdar q) + (cdr q))))) (define (empty? q) (and (null? (car q)) @@ -43,7 +32,7 @@ ref: sicp-persistent-amortized-o1-queue (define (rec l leading-space?) (when (not (null? l)) (when leading-space? - (display " ")) + (display " ")) (display (car l)) (rec (cdr l) #t))) @@ -52,10 +41,12 @@ ref: sicp-persistent-amortized-o1-queue (rec (reverse (cdr q)) (not (null? (car q)))) (display ")") (newline)) -``` +---- Sample interactive session: -```scheme + +[source,scheme] +---- scheme@(guile-user)> (define true #t) scheme@(guile-user)> (define false #f) scheme@(guile-user)> (define q (queue)) @@ -82,4 +73,4 @@ scheme@(guile-user)> (print-queue q) #q(b c d e) scheme@(guile-user)> (print-queue (cdr (dequeue (cdr (dequeue (enqueue 'g (enqueue 'f q))))))) #q(d e f g) -``` +---- diff --git a/src/content/pastebins/2022/07/14/git-cleanup.adoc b/src/content/pastebins/2022/07/14/git-cleanup.adoc index 52cd17f..b223f86 100644 --- a/src/content/pastebins/2022/07/14/git-cleanup.adoc +++ b/src/content/pastebins/2022/07/14/git-cleanup.adoc @@ -1,18 +1,7 @@ ---- += git-cleanup command -title: git-cleanup command - -date: 2022-07-14 - -layout: post - -lang: en - -ref: git-cleanup-command - ---- - -``` +[source,sh] +---- #!/bin/sh set -eu @@ -67,4 +56,4 @@ shift $((OPTIND - 1)) git branch --merged | grep -v -e '^\*' -e '^. main$' | xargs git branch -d -``` +---- diff --git a/src/content/pastebins/2023/07/22/funcallable-amop.adoc b/src/content/pastebins/2023/07/22/funcallable-amop.adoc index 37c79fe..47a8089 100644 --- a/src/content/pastebins/2023/07/22/funcallable-amop.adoc +++ b/src/content/pastebins/2023/07/22/funcallable-amop.adoc @@ -1,22 +1,10 @@ ---- - -title: Funcallable AMOP - -date: 2023-07-22 - -layout: post - -lang: en - -ref: funcallable-amop - ---- - += Funcallable AMOP Using `macrolet` to allow a `funcallable-standard-class` to be invoked without using `funcall` directly, and let the macroexpansion do that instead: -``` +[source,lisp] +---- #!/usr/bin/env li (asdf:load-system :closer-mop) @@ -40,4 +28,4 @@ using `funcall` directly, and let the macroexpansion do that instead: `(funcall c ,@body))) (funcall c 2) (c 3))) -``` +---- |