Skip to content

Instantly share code, notes, and snippets.

@lilac
lilac / Makefile
Created October 17, 2023 01:34
Wasm with threads
.phony: run
run: thread.wasm
wasmtime run --wasm-features threads --wasi-modules experimental-wasi-threads ./thread.wasm
thread.wasm: thread.wat
wat2wasm --debug-names --enable-threads thread.wat
@lilac
lilac / HelloWorld.java
Last active October 8, 2023 02:53
Native Image of Java Hello World
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
@lilac
lilac / A ReadMe.md
Last active August 6, 2023 09:43
Run tailscale on WDMyCloud

Install service

Since this linux is an old version, it still use sysv scripts for service management. To run tailscaled as a daemon (service), follow the procedure below.

  1. Copy the script to /etc/rc0.d/K20tailscaled. The script is mainly borrowed from this gist.
  2. Adjust the script as appropriate.
  3. Reboot the system via reboot.
  4. Check the service is started.
    1. By listing all services with service --status-all.
    2. Or check the status of this specific service with service tailscaled status. If it's alright, you should get the following output.
@lilac
lilac / dag.star
Last active March 30, 2023 06:19
DAG for home page recommendation
# builtin functions
# graph is a builtin module exposed by the host environment
# graph.nodes = {}
# graph.edges = []
def node(name, operation, conf={}, predicate=None):
"""
:rtype: str the node name is returned
@lilac
lilac / demo.scala
Last active March 16, 2023 14:14
Starlark interoperation to JVM
package example
import com.google.common.collect.{ImmutableCollection, ImmutableList, ImmutableMap}
import net.starlark.java.annot.{Param, StarlarkBuiltin, StarlarkMethod}
import net.starlark.java.eval.{Dict, EvalException, Module, Mutability, Starlark, StarlarkFunction, StarlarkInt, StarlarkList, StarlarkSemantics, StarlarkThread, Structure, Tuple}
import net.starlark.java.syntax.{FileOptions, ParserInput}
import scala.collection.mutable.ListBuffer
object StarlarkDemo extends App {
@lilac
lilac / ReadMe.md
Created March 6, 2023 04:31
A js interpreter in WebAssembly (wasm)

Playground

  • Install wazero with the following commmand.

    go get github.com/tetratelabs/wazero@latest
  • Download the wasm file of a Javascript interpreter. For simplicity, the following ways are listed.

    • If you have wapm installed, you could download one with
@lilac
lilac / fstore.md
Last active October 20, 2023 03:45
A database tailored for feature store

Build a persistent, high availability and low latency key-value storage engine for derived data. One of such use cases is feature store. These use cases share some common characteristics, that we could utililze to build a better performing database.

  1. The data is derived, so no need to handle replication or data recovery.
  2. All the writes are through bulk loading, so no concurrency control needed.

In summary, it's like a scalable cache engine.

Features

  • High throughput bulk load
@lilac
lilac / a-guide.md
Last active December 4, 2022 09:13
Embed javascript in JVM

Prerequisites

  1. Install graalvm.
sdk install java 22.3.r19-grl
  1. Change current JVM to graalvm.
sdk use java 22.3.r19-grl
  1. Install Graal js following the guide.
@lilac
lilac / ReadMe.md
Created November 30, 2021 15:25
Implement method overriding of OOP in SML

It follows the interface (trait) oriented programming style.