Origin link 2024-3-17
racket is one of scheme dialect and I want to use racket to learn "the litte schemer". One of problem I meet is how to load file with scheme code (not racket code) into REPL and run relate function. In guile, it is very simple: guile -l my_function.scm. but in racket, it is little complex.
- with load (traditional scheme file, no #lang)
it could work "racket -if <my_function.scm>" but my_function.scm should not start with "#lang racket". it is same with load function.
- with module (racket file, with #lang)
Racket has concept of module, every file is module and each module need "initial-module-path" which is "The #lang at the start of a module file begins a shorthand for a module form"First, like import in python, you could use (require my_function.scm) in source code and "-t " in command line to import a module, but you need to list which function is export by (provide function) in my_function.scm, or (provide (all-defined-out)) to export all functions.
-t <file>, --require <file> Like -e '(require (file "<file>"))' [*]
Another trick point is you need "racket -i -t my_function.scm" instead of "racket -t my_function.scm -i". I don't know why but I guess it is related to "If -t/-l/-p/-u appears before the first -i/-e/-f/-r, -n is added".
Second, you could config initial-module in command line with "racket -I typed/racket" (#lang typed/racket in source code). The magic of of initial-module-path is you could define a new language with different syntax.
Third, you could always start "racket -i" and use ",enter my_function.scm" or "racket -i -e '(enter! "my_function.scm")'" to go to my_function namespace.
Origin link 2023-12-1
if you want a remote repository and put local source into remote, you need to set up remote repository with "git init bare . ", not "git init ."
link1, link2
Origin link 2023-11-24
rotorrent could use xmlrpc to send command remotely without any ui interface.
- how to setup xmlrpc support (link, link2 )
- configure scgi port on rtorrent.rc
- install nginx and setup location for scgi and configure same scgi port from rtorrent.rc
- rtorrent from Archlinux has dependency (libxmlrpc from http://xmlrpc-c.sourceforge.net/). there is binary application in this package to send xmlrpc command to rtorrent
- xmlrpc basic
- xmlrpc is specification for request sent to client (link)
- xmlrpc has scalar (int,boolean, string, double), struct (dictionary), array.
- xmlrpc binary command convert command parameter into request. Different binary command has different command parameter but request is same.
- for xmlrpc (http://xmlrpc-c.sourceforge.net/), it need to escape ":" as "\:" since ":" is separator for struct. (link ). The parenthesis, brace, comma, colon, and backslash characters are special. If you want to include one in a string value, escape it with a backslash.
- usag
- "2838954B0BBB1A87A668308DCC08AAF56D83D20D" is infohask for one rtorrent.
- "2838954B0BBB1A87A668308DCC08AAF56D83D20D\:t0" is tracker1 for one rtorrent.
- xmlrpc localhost system.listMethods
- xmlrpc localhost system.methodHelp t.id
- xmlrpc localhost load.normal "magnet:?xt=urn:btih:59066769B9AD42DA2E508611C33D7C4480B3857B&dn=ubuntu-17.04-desktop-amd64.iso&tr=http%3A%2F%2Ftorrent.ubuntu.com%3A6969%2Fannounce&tr=http%3A%2F%2Fipv6.torrent.ubuntu.com%3A6969%2Fannounce"
- xmlrpc localhost download_list
- xmlrpc localhost d.is_open 2938964B0BAB1A87A668308DCC08AAF56D83C20D
- xmlrpc localhost d.state <hash>
- xmlrpc localhost d.chunk_size 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.size_files "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B"
- xmlrpc localhost d.size_chunks "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B"
- xmlrpc localhost d.size_bytes "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B"
- xmlrpc localhost d.completed_chunks "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B"
- xmlrpc localhost d.complete 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.ratio 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.down.total 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.down.rate 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.up.total 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost d.up.rate 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost p.multicall 2838954B0BBB1A87A668308DCC08AAF56D83D20D p.id
- xmlrpc localhost d.tracker.insert 2838954B0BBB1A87A668308DCC08AAF56D83D20D 0 "udp\://tracker.openbittorrent.com\:80"
- xmlrpc localhost d.tracker.insert 2838954B0BBB1A87A668308DCC08AAF56D83D20D 1 "udp\://tracker.opentrackr.org\:1337/announce"
- xmlrpc localhost d.tracker_size 2838954B0BBB1A87A668308DCC08AAF56D83D20D
- xmlrpc localhost t.id <hash>
- xmlrpc localhost t.is_open "2838954B0BBB1A87A668308DCC08AAF56D83D20D\:t1"
- xmlrpc localhost t.id "2838954B0BBB1A87A668308DCC08AAF56D83D20D\:t0"
- xmlrpc localhost f.multicall "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B" "*" f.path=
- xmlrpc localhost f.frozen_path "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B\:f2"
- xmlrpc localhost f.path "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B\:f3"
- xmlrpc localhost f.completed_chunks "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B\:f2"
- xmlrpc localhost f.size_bytes "BBAB39AF48A4BD6FD23F1CCA39246A3E9D22F76B\:f2"
Origin link 2023-11-24
GPU accelerator on WSL need WDDM 2.9 (link ). Windows 10 support WDDM from 20H2 (link) but Intel driver only support WDDM > 2.9 from Windows 11 (link). You could use "dxdiag" to check WDDM version on your windows.
My laptop is Intel GPU + Windows 10. Intel driver doesn't support WDDM v2.9 or later on Windows 10 but it is OK on Windows 11. It means WSL couldn't support GPU accelerator on Windows 10.
If you want to use webgpu under wsl2, use following chrome command since webgpu on chrome only support vulkan now according to Chrome ships WebGPU.
- "--enable-unsafe-webgpu --enable-features=Vulkan --use-vulkan=swiftshader"
- "This initial release of WebGPU is available in Chrome 113 on ChromeOS devices with Vulkan support, Windows devices with Direct3D 12 support, and macOS. Linux, Android, and expanded support for existing platforms will come soon."
Origin link 2023-4-26
some tips when i trying compile opengl programs in conda
- g++ -I/home/hongy19/miniconda3/envs/opengl/include/ : include *.h
- g++ -L/home/hongy19/miniconda3/envs/opengl/lib :add folder of *.so for link(ld)
- g++ -lglfw: use libglfw.so for link(ld)
- LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hongy19/miniconda3/envs/opengl/lib ./a.out: add library search path for dynamic *.so
- static compile
- -static compile for static link need *.a and *.o library and *.so doesn't work for static compile, see link. The error of following code is due to missing of *.a or *.o even *.so existed.
(opengl) hongy19@WSL opengl$ gcc glfw-1.cpp -static -lglfw -lGL
/usr/sbin/ld: cannot find -lglfw: No such file or directory
/usr/sbin/ld: cannot find -lGL: No such file or directory
collect2: error: ld returned 1 exit status- pkgconfig
- PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --list-all
- PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --cflags glfw3 -I/home/hongy19/miniconda3/envs/opengl/include
- PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig pkg-config --cflags gtk+-3.0
Origin link 2023-4-22
see Environment variables for Wayland hackers and Wayland-specific environment variables for detail and what is setting in wsl2.
- WAYLAND_DISPLAY
- wayland unix socket
- WAYLAND_DISPLAY=wayland-0
- XDG_RUNTIME_DIR
- directory of wayland unix socket
- XDG_RUNTIME_DIR=/mnt/wslg/runtime-dir/ or XDG_RUNTIME_DIR=/run/user/1000/
- DISPLAY
- X11 unix socket
- DISPLAY=:0 and /tmp/.X11-unix/X0
- GDK_BACKEND
gtk3/gtk3 in conda has disabled wayland support, see
link.
- with pygobject, GDK_BACKEND=wayland doesn't work but chrome/weston-terminal is OK and pygobject is OK with GDK_BACKEND=wayland, x11 or GDK_BACKEND=x11.
- with GDK_BACKEND=help, gtk3 only support x11, not wayland
- condas gtk3.0/gtk4.0 only support x11, not wayland since no ~/miniconda3/envs/gtk/include/gtk-3.0/gdk/gdkwayland.h.
(gtk) hongy19@WSL cairo$ GDK_BACKEND=help python test1.py
Supported GDK backends: x11
Origin link 2023-4-16
According to Archlinux wiki and How Keys Are Turned Into Actions , here comes how keystroke information is transferred in computer.
- Keyboard send scancode to computer
- Linux kernel convert scancode to keycode
- Keyboard layout convert keycode to symbol/keysym
- Linux terminal convert keysym into ASCII sequences
And there are two types of key (see link )- Ordinary key, like "a", "b". we should use them to input text
- Special keys, which you would use to tell xterm to perform some action. They could not be to used to input text. They will generate escape sequences.
.inputrc is readline initialization file and used to map key sequence to readline function like "end-of-history". Then you need to use text to describe "special keys" or "escape sequences", see following example.
- "\e[1~": beginning-of-line # Home Key
- "\e[4~": end-of-line # End Key
- "\e[3~": delete-char # Delete Key
- "\e\e[C": forward-word # Alt-Right
You could use "showkey -k" or "od -c" to show escape sequence of special keys.
Origin link 2023-4-10
- Wayland
- see overview: Wayland Weston overview
- Wayland is a communication protocol that specifies the communication between a display server and its clients, from wikipedia
- Weston is the reference implementation of a Wayland compositor, from weston github.
- Weston
- backends, from "man weston"
- drm-backend.so: The DRM backend uses Linux KMS for output and evdev devices for input
- wayland-backend.so: The Wayland backend runs on another Wayland server, a different Weston instance
- x11-backend.so: The X11 backend runs on an X server
- rdp-backend.so: The RDP backend runs in memory without the need of graphical hardware.
- to run weston from wsl2, use wayland-backend.so.
- to run weston for rdp connection, use rdp-backend.so
- all for drm connector, see "/sys/class/drm"
- modules/shell
- all *.so are located at usr/lib/weston for modules and shell in weston.ini
- weston terminal
- scale: scale text for high DPI screen
- GDK setting for GTK application from application level
- export GDK_BACKEND=wayland
- #To scale UI elements by an integer only factor
- #GTK3/4 does not support fractional scaling currently, so fractional factors will be ignored
- export GDK_SCALE=1
- #GDK_DPI_SCALE can be used to scale text only
- export GDK_DPI_SCALE=1.2
- composition level
- "[output]" on weston.ini, only work for drm and X11. set "scale=1.5".
Origin link 2023-4-10
Here come several basic concept for font, drawing on linux
- font
- Anti-aliasing and subpixel rendering, see "A Closer Look At Font Rendering" for concept introduction.
- black and white rendering is first generation rendering and print still use it.
- gray-scale rending (anti-aliasing) is second generation rendering to utilize controlling the brightness of each pixel.
- subpixel (ClearType in windows) is third generation rendering to utilize controlling pixel colors. it is for LCD on which screens, the red, green and blue subpixels that control the color and brightness of the pixel.
- Archlinux enable Anti-aliasing and subpixel by default.
- font configuration on Archlinux wiki introduce default configuration for Archlinux.
- fontconfig/freetype/pango
- Very good overview introduction: Modern text rendering with Linux: Overview
- Text Rendering Notes
- Font basic concept introduction, see CSS Fonts Module Level 3
- pango
- what pango is doing: "here's a piece of text render it in this box I don't care what you do." from link.
- See one pango code example: link.
- harfbuzz is text shaping engine which is incorporated into Pango .
- pango-view --font=monospace --language=zh 1.txt or pango-view --height=300 --width=100 --font=monospace --language=zh 1.txt
- fontconfig
- user guideline: fonts-conf
- pattern, element:
- font patterns may contain essentially any properties, fontconfig use pattern to query fonts. element is which properties are listed on output
- basic syntax of pattern are: <families>-<point sizes>:<name1>=<values1>:<name2>=<values2>, see "Font Names" section of fonts-conf
- fc-list also use this pattern, see link.
- fc-list lists fonts and styles available on the system for applications using fontconfig. if no font match query pattern, then nothing return. If wrong pattern used, then fc-list output result of "fc-list", see link. fc-list not read configuration file.
- fc-match matches pattern (empty pattern by default) using the normal fontconfig matching rules to find the best font available.
- fc-query queries font-file(s) using the normal fontconfig rules and prints out font pattern for each face found. fc-qury not read configuration file.
- charset
- charset is Unicode chars encoded by the font.
- charset from output of fc-list and fc-match is base85, not human-readable, see link for detai.
- The difference Between Unicode and UTF-8, see link and link.
- Encoding translates numbers into binary. Character sets translates characters to numbers.
- Unicode is a character set. UTF-8 is encoding.
- Unicode is a list of characters with unique decimal numbers (code points). A = 65, B = 66, C = 67, ....
- This list of decimal numbers represent the string "hello": 104 101 108 108 111
- Encoding is how these numbers are translated into binary numbers to be stored in a computer:
- UTF-8 encoding will store "hello" like this (binary): 01101000 01100101 01101100 01101100 01101111
- 4E00 is for one of CJK unicode charset, see link.
- lang, see CSS Fonts Module Level 3 - 6.2. Language-specific display
- "lang causing a glyph change on the same codepoint given", see link.
- No zh, but using :lang=zh-cn
Origin link 2023-4-7
- X11 forwarding, see my blog.
- RDP
- xrdp
- this one seems only work for Xwindows, not wayland.
- Wayland
- Not all wayland application support RDP, some only support VNC.
- sway doesn't support rdp but only vnc, see link.
- weston, see link
- On the target linux device, install freerdp and weston
- pacman -S freerdp
- pacman -S weston
- On the target linux device, generate RDP certificates
- sudo mkdir -p /etc/freerdp/keys/
- sudo winpr-makecert -rdp -path /etc/freerdp/keys/
- On the target linux device, start weston
- weston --backend=rdp-backend.so --rdp-tls-cert=/etc/freerdp/keys/server.crt --rdp-tls-key=/etc/freerdp/keys/server.key
- On the windows side, start "Remote Desktop Connection" and fill in targe linux server ip.
- waypipe, see link.
- installed waypipe on both the local and remote computers
- run waypipe on local linux/wsl
- waypipe ssh user@theserver weston-terminal
old page page 0
new page