Skip to content

Instantly share code, notes, and snippets.

@takikawa
takikawa / gist:bd1cb0563bdf7a76cb88105b2e354b40
Created January 27, 2020 23:28
Size text picts based on slide size
#lang racket
(require racket/draw
pict
slideshow)
;; Create a text pict that fits in target pixels of the slide
(define (auto-text str [style null] [target (* 0.8 client-w)] [angle 0])
(define initial-min 0)
(define initial-max 1000)
GC: 0:min @ 1,451K(+164K)[+164K]; free 1,049K(-5,145K) 0ms @ 40
GC: 0:min @ 1,426K(+4,285K)[+168K]; free 686K(-686K) 0ms @ 44
GC: 0:min @ 1,993K(+3,718K)[+236K]; free 967K(-2,263K) 0ms @ 48
GC: 0:min @ 3,785K(+3,542K)[+248K]; free 1,408K(-1,408K) 0ms @ 56
GC: 0:min @ 5,027K(+2,732K)[+256K]; free 1,359K(-6,751K) 4ms @ 60
GC: 0:min @ 7,130K(+6,021K)[+276K]; free 1,913K(-3,209K) 4ms @ 72
GC: 0:min @ 9,977K(+4,470K)[+280K]; free 2,679K(-3,975K) 0ms @ 84
GC: 0:min @ 13,298K(+3,917K)[+288K]; free 3,163K(-16,747K) 4ms @ 96
GC: 0:min @ 16,686K(+14,113K)[+300K]; free 4,123K(-5,419K) 8ms @ 112
racket/contract: no late-neg-projection passed to build-contract-property
#!/bin/bash
case $1 in
paste)
xclip -o -selection "clipboard" > /keybase/private/$USER/clipboard;;
copy)
xclip -i /keybase/private/$USER/clipboard -selection "clipboard";;
esac
### Keybase proof
I hereby claim:
* I am takikawa on github.
* I am asumu (https://keybase.io/asumu) on keybase.
* I have a public key ASBxw_jEWr8iVP6KFW1ckGVobdGsnbe0M9OdbCo41RNHZQo
To claim this, I am signing this object:
$ LD_LIBRARY_PATH="../src" ./pflua-compile --native "tcp"
mcode dump:
7f9f42a14000 4883FE22 cmp rsi, +0x22
7f9f42a14004 7C4E jl 0x7f9f42a14054
7f9f42a14006 480FB7470C movzx rax, word [rdi+0xc]
7f9f42a1400b 4883F808 cmp rax, +0x08
7f9f42a1400f 750D jnz 0x7f9f42a1401e
7f9f42a14011 480FB64F17 movzx rcx, byte [rdi+0x17]
7f9f42a14016 4883F906 cmp rcx, +0x06
7f9f42a1401a 743A jz 0x7f9f42a14056
$ sudo ./snabb snsh -t apps.lwaftr.multi_copy
selftest: multi_copy
selftest: ok
$ ../lib/luajit/usr/local/bin/luajit dynasm.lua apps/lwaftr/multi_copy.dasl > /tmp/multi_copy.lua
$ cd /tmp
$ cp ~/igalia/dynasm/* ./
cp: omitting directory ‘/home/asumu/igalia/dynasm/bin’
cp: omitting directory ‘/home/asumu/igalia/dynasm/csrc’
$ LD_LIBRARY_PATH="." ~/igalia/snabb/lib/luajit/usr/local/bin/luajit
LuaJIT 2.1.0-beta1 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 69
model name : Intel(R) Celeron(R) 2957U @ 1.40GHz
stepping : 1
microcode : 0x15
cpu MHz : 1400.000
cache size : 2048 KB
physical id : 0
@takikawa
takikawa / Both mand & opt
Last active June 17, 2016 19:34
Racket expansion of contract
(module anonymous-module racket
(#%module-begin
(module configure-runtime '#%kernel
(#%module-begin (#%require racket/runtime-config) (#%app configure '#f)))
(#%provide (rename provide/contract-id-f f))
(define-syntaxes (f)
(#%app
make-keyword-syntax
(lambda () (#%app values (quote-syntax f5) (quote-syntax f7)))
'1
`(
(start #f)
(visit
,(datum->syntax
#f
'(module anonymous-module typed/racket (#%module-begin "hello world"))))
(start #f)
(enter-check
,(datum->syntax
#f
File "typing.ml", line 430, characters 4-28:==== ] 00432 / 00555
Error: This pattern matches values of type
[? `Star of
[? `ID_False
| `ID_Nil
| `ID_Scope of Cfg.identifier * string
| `ID_Self
| `ID_True
| `ID_UScope of string
| `ID_Var of Cfg.var_kind * string