37/this section is left blank
Monday, 2023-12-11 to Sunday, 2023-12-17
Created:
Programming
Templ templating
templ is a nice find this week. It
is a golang library that
allows you render fragments of HTML in a composable manner. It does so
by adding a templ
keyword.
If its tiring to even start doing front-end “component” based development, this is a great option to ship a self-contained executable that has the entire web app.
mkdir hello-world
cd hello-world
go mod init github.com/a-h/templ-examples/hello-world
the hello.templ
file contains a component:
package main
(name string) {
templ hello<div>Hello, { name }</div>
}
Compile this templ file to generate a go file:
templ generate
func hello(name string) templ.Component {
// ...
}
Use this generated file in a Go program:
package main
import (
"context"
"os"
)
func main() {
:= hello("John")
component .Render(context.Background(), os.Stdout)
component}
The templ
library dovetails nicely into the HTMX mindset
of doing maximum amount of rendering etc on the server. See their HTMX page.
Also learnt about similar templating language solutions for:
- Scala – Scalatags
- Java and Kotlin – JTE; Java Template Engine; has good IDEA support.
- Rust – Maud
- and Python – Pyxl
¶ As part of the templ’s example code there is counter which allowed me to learn about cdk, AWS’s Cloud Development Kit. Studying the stack.go code, we can see how the entire “Stack” can be setup with Go code, which includes, DynamoDB, Lambda, Cloudfront, S3, etc. This is quite a departure from more familiar deployment strategies.
Is it fair to say that if you know your AWS services, and know how to
use CDK, you may not lean towards services like fly? especially for
“production” uses in a company (for personal uses, and small projects
fly.io’s fly deploy
is fairly unbeatable combo).
¶ Also learnt about Air,
live-reloading command line utility for developing Go applications.
Run air
in your project root directory, leave it alone, and
focus on your code. Note: This tool has nothing to do with hot-deploy
for production. Creating an .air.toml
in the project
directory and running air
–
go install github.com/cosmtrek/air@latest
will keep
everything hot and reloading. Example .air.toml
is quite illustrative of how to configure the various stages of the
lifecycle.
C to WASM to C, but now Sandboxed
The best WebAssembly runtime may be no runtime at all by Frank Denis exposed me to a very intriguing use of WASMs.
Take existing C code, compile it to WebAssembly, transpile it back to C, and you get the same code, but sandboxed. The transformation acts as a sanitizer that improves safety by restricting the range of virtual memory accessible to each instance.
He goes on to give instructions on how to achieve this using Zig to compile the a Zig file to WASM and then use w2c2, a WASM to C transpiler to compile it to a safer C, and then again use Zig to compile the generated C to native binary (since Zig is also a C compiler).
Comments mentioned Firefox having tried this approach in RLBox – WebAssembly and Back Again: Fine-Grained Sandboxing in Firefox 95
You can read this announcement by ziglang creator on how they used wasm to get rid of C++ from Zig’s codebase – Goodbye to the C++ Implementation of Zig ⚡ Zig Programming Language
#wasm #zig
This monograph is a wonderful introduction to the world of data streams algorithms and applications. The chapters abstract all mathematical ideas, algorithmic techniques as well as lower bound approaches for data stream models that comprise together the foundation of the theory of data streams. Data Streams: Algorithms and Applications - by S. Muthukrishnan – via
debasishg
Tools and tech
¶ used NCurses Disk Usage to identify and delete a bunch of files from this website’s root folder and moved it off to https://files.btbytes.com; can definitely see myself using it again. #unix #tools
¶ This mindset is close to how I run my own website (this one) – How I run my servers
- i use nginx
- i use systemd to start services
- i automate deployment using ansible
- i generate static html pages and seldom have any dynamic pages (so far)
- use letsencrypt for ssl certs that are served by nginx
- i use cron, which is also configured via ansible.
Some of the other things he mentions like sqlite.backup, and automatic letsencrypt cert renewals, static builds using rust are interesting things to examine for future uses.
¶ Has India managed to escape many of these self-inflicted injuries? or no? A list of factors that act(ed) as drag on the European Tech/Startup scene. Related reading: Is Europe Just Not Good at Innovating? - Bert Hubert’s writings.
Kannada
Chokkaramayana to Chokkaramayana written by Smt Chokkamma.
From around the web
Essays on woodblocks. Excellent new find about a japanese woodblock shop and it’s creator.
“Was there life before computer? The calculation before we went digital”. Very fascinating and educational monograph about calculating machinery that made the modern world possible, many of which were conceived in the 17th century, and were in use (some still are) till the advent of computers.
🔄 Updated pages
- clickhouse – there
is now an embeddable version of ch -
chdb
. - pl – added cyber.
- deep-learning – new textbook from Christopher Bishop