Skip to content

Instantly share code, notes, and snippets.

View anthonyquizon's full-sized avatar

Anthony Quizon anthonyquizon

  • Sydney, Australia
View GitHub Profile
@anthonyquizon
anthonyquizon / example-html.bqn
Last active September 23, 2024 23:40
BQN String interpolation
string ← •Import "string.bqn"
# Poor mans templating engine
Fmt←{ 𝕨⊸string.Fmt¨<˘𝕩}
foo←∾∾⟨
"<div>"
"<span>{value}</span>" Fmt ↕10
"<span class='{0}'>{1}</span>" Fmt [⟨"foo",1⟩,⟨"bar",2⟩]
Bytecode: ⟨ 0 1 33 0 0 48 6 0 1 0 0 34 0 0 17 7 ⟩
Loc: ⟨ ⟨ 2 2 0 0 0 1 3 6 6 5 5 4 4 4 5 4 ⟩ ⟨ 2 2 0 0 0 1 3 6 6 5 5 4 4 4 5 4 ⟩ ⟩
Token:
┌─
· ⟨ 95 72 96 64 95 0 96 ⟩ ⟨ 0 ¯3 0 ¯1 0 1 0 ⟩ ⟨ ⟨ "a" ⟩ ⟨⟩ ⟨ 2 ⟩ ⟨⟩ ⟨⟩ ⟩ ⟨ 0 1 2 3 4 5 6 ⟩ ⟨ 0 1 2 3 4 5 6 ⟩
lib.so: lib.c
gcc -shared lib.c -o lib.so
@anthonyquizon
anthonyquizon / data.csv
Last active February 27, 2024 04:55
Segmentation fault example bqn
Date Description Credit Debit Balance
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
26/02/2024 Foo Bar Baz Card 12345xxxxxx5678 -11.19 2017.05
@anthonyquizon
anthonyquizon / unicode.d
Created July 30, 2021 11:52
print out valid unicode identifier characters for dlang
import std.stdio;
import std.uni;
import std.conv;
///Taken from https://github.com/dlang/dmd/blob/0517fc93ceb9e74e979bbbc9de64eb64d610094c/src/dmd/utf.d
static immutable wchar[2][] ALPHA_TABLE =
[
[0x00AA, 0x00AA],
[0x00B5, 0x00B5],
[0x00B7, 0x00B7],
[0x00BA, 0x00BA],
@anthonyquizon
anthonyquizon / read-dt.org
Created December 5, 2020 03:35 — forked from queertypes/read-dt.org
Implement a Dependently Typed Language and Then Some
@anthonyquizon
anthonyquizon / server.d
Created June 9, 2020 01:21
Dlang Vibe.d REST with CORS example
const PORT = 8008;
interface APIInterface {
@safe:
string postMatches();
string get();
}
class APIHandlers : APIInterface {
@anthonyquizon
anthonyquizon / guile-http-client.scm
Created June 5, 2020 03:50
Example of using web client in guile
(use-modules (web client)
(web response)
((rnrs) :version (6)))
(define port "8000")
(define body "{\"foo\": \"xyx\"}" )
;; GOTCHAs
;; Body needs to be converted from string to utf8 and back again
;; Need to destructure response with let-values in order to get body string
// db.zig
const std = @import("std");
const warn = std.debug.warn;
const Allocator = std.mem.Allocator;
const util = @import("../util.zig");
const c = @cImport({
@cInclude("lmdb.h");
});
@anthonyquizon
anthonyquizon / example.rkt
Created July 24, 2019 02:01
Stacktrace information in racket repl (command line)
#lang racket
(require racket/trace)
(define (example)
(error a b c))
(trace example)