Skip to content

Instantly share code, notes, and snippets.

@ktakashi
ktakashi / output.txt
Created June 14, 2023 07:28
Random urban dictionary word card
┌─────────────────────────────────────────────────────────────────────────────┐
│ i am disappoint │
│ a 4chan meme. it is a series of badly drawn comics in which the son does │
│ an act the father disapproves of, and the father says: son, i am disappoint │
│ │
│ Example(s) │
│ fap fap fap- son, i am disappoint │
│ │
│ did you see the latest i am disappoint? it was hilarious │
└─────────────────────────────────────────────────────────────────────────────┘
@ktakashi
ktakashi / Ed25519vsRSA.scm
Created September 23, 2021 07:35
Performance of Ed25519 and RSA
(import (rnrs)
(crypto)
(crypto eddsa)
(math)
(time))
(define priv
(generate-private-key Ed25519
(integer->bytevector #x1498b5467a63dffa2dc9d9e069caf075d16fc33fdd4c3b01bfadae6433767d93)))
(define pub (eddsa-private-key-public-key priv))
@ktakashi
ktakashi / Result
Created July 9, 2019 15:23
Gauche benchmark 0.9.7
$ scheme-env run [email protected] bench-gauche.scm
Benchmark: ran equal?, loop, sym, each for 10000 times.
equal?: 0.032 real, 0.030 cpu ( 0.030 user + 0.000 sys)@333333.33/s n=10000
loop: 0.463 real, 0.470 cpu ( 0.470 user + 0.000 sys)@ 21276.60/s n=10000
sym: 8.174 real, 13.350 cpu (12.210 user + 1.140 sys)@ 749.06/s n=10000
Rate equal? loop sym
equal? 333333/s -- 15.667 445.000
loop 21277/s 0.064 -- 28.404
sym 749/s 0.002 0.035 --
@ktakashi
ktakashi / Gauche error message
Created July 9, 2019 14:27
Error during installation
gcc -g -O2 -Wall -Wextra -Wno-unused-label -no-cpp-precomp -fPIC -fno-common -bundle -flat_namespace -undefined suppress -o rfc--tls--mbed.so tls-mbed.o -L"../../src" \
"../../src/gosh" -ftest "../../ext/xlink" -l -g "rfc" \
-b "../.." -s . rfc--mime.so rfc--822.so mime.sci 822.sci
link /Users/takashi/.scheme-env/work/gauche/0.9.8/build-20190709_162252.dyMWDDMC/Gauche-0.9.8/ext/rfc/rfc--mime.so <- ../../src/rfc--mime.so
link /Users/takashi/.scheme-env/work/gauche/0.9.8/build-20190709_162252.dyMWDDMC/Gauche-0.9.8/ext/rfc/rfc--822.so <- ../../src/rfc--822.so
link /Users/takashi/.scheme-env/work/gauche/0.9.8/build-20190709_162252.dyMWDDMC/Gauche-0.9.8/ext/rfc/mime.sci <- ../../lib/rfc/mime.sci
link /Users/takashi/.scheme-env/work/gauche/0.9.8/build-20190709_162252.dyMWDDMC/Gauche-0.9.8/ext/rfc/822.sci <- ../../lib/rfc/822.sci
*** ERROR: string required, but got #f
Stack Trace:
@ktakashi
ktakashi / define-macro.scm
Created August 9, 2018 07:18
Simple define-macro by syntax-case
#!r6rs
(import (rnrs))
(define-syntax define-macro
(lambda (x)
(syntax-case x ()
((_ (name args ... . rest) body ...)
#'(define-macro name (lambda (args ... . rest) body ...)))
((_ name body)
(identifier? #'name)
#'(define-syntax name
@ktakashi
ktakashi / bench.scm
Created February 7, 2018 13:46
TLS benchmark
#!read-macro=sagittarius/bv-string
(import (rnrs)
(time)
(sagittarius control)
(sagittarius socket)
(rfc tls))
(define *poor-victim* "www.google.com")
(define iteration 100)
(let ((sock (make-client-tls-socket *poor-victim* "443"))
@ktakashi
ktakashi / foo.xml
Last active December 5, 2017 20:30
<?xml version="1.0" encoding="utf-8"?>
<d:data xmlns:d="defiant-namespace" d:mi="23">
<store d:mi="22">
<book price="12.99" d:price="Number" d:mi="4">
<title d:constr="String" d:mi="1">Sword of Honour</title>
<category d:constr="String" d:mi="2">fiction</category>
<author d:constr="String" d:mi="3">Evelyn Waugh</author>
</book>
<book price="8.99" d:price="Number" d:mi="9">
<title d:constr="String" d:mi="5">Moby Dick</title>
@ktakashi
ktakashi / bench.scm
Created November 15, 2017 07:51
Experimental PEG 2
(import (rnrs) (packrat) (time))
(define (generator tokens)
(let ((stream tokens))
(lambda ()
(if (null? stream)
(values #f #f)
(let ((base-token (car stream)))
(set! stream (cdr stream))
(values #f base-token))))))
@ktakashi
ktakashi / peg.scm
Created November 14, 2017 22:05
Experimental PEG
(import (rnrs) (sagittarius generators) (srfi :117))
;; peg consumes generator
(define $return
(case-lambda
((v) (lambda (g) (values 'success v g)))
((v state) (lambda (g) (values state v g)))
((v state g) (lambda (_) (values state v g)))))
@ktakashi
ktakashi / override.scm
Created September 1, 2017 06:59
Error on overriding imported variable
(import (rnrs))
(define (+ a b) "blabla")
(+ 1 2)
#|
$ sagittarius -r6 override.scm
Unhandled exception
Condition components:
1. &compile
program: (program (import (rnrs)) (define (+ a b) "blabla") (display