Skip to content

Instantly share code, notes, and snippets.

zhangw / gist:0c4bd6ec53b493b0b5d60af752eb4b1a
Created May 11, 2024 14:01 — forked from chrisdone/gist:02e165a0004be33734ac2334f215380e
Build and run minimal Linux / Busybox systems in Qemu


export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

zhangw /
Created February 21, 2024 02:53
# 启动测试
import openai
openai.api_key = "" # Not support yet
openai.api_base = ""
# 选择你启动的模型
model = "codellama_34b"
# create a chat completion
completion = openai.ChatCompletion.create(
zhangw / fschat-codefuse-codellama-34B-4bits
Last active February 4, 2024 09:23
fastchat load model
python -m fastchat.serve.cli --gptq-wbits 4 --gptq-group 64 --model-path $HOME/.cache/modelscope/hub/codefuse-ai/CodeFuse-CodeLlama-34B-4bits --device cuda --style rich
python -m fastchat.serve.controller
python -m fastchat.serve.model_worker --gptq-wbits 4 --gptq-group 64 --model-path $HOME/.cache/modelscope/hub/codefuse-ai/CodeFuse-CodeLlama-34B-4bits --device cuda
python -m fastchat.serve.test_message --model-name CodeFuse-CodeLlama-34B-4bits
python -m fastchat.serve.gradio_web_server
zhangw /
Last active February 21, 2024 02:52
import os
import torch
import time
from modelscope import AutoTokenizer, snapshot_download
from auto_gptq import AutoGPTQForCausalLM
os.environ["TOKENIZERS_PARALLELISM"] = "false"
def load_model_tokenizer(model_path):

Libuv and libev, two I/O libraries with similar names, recently had the privilege to use both libraries to write something. Now let's talk about my own subjective expression of common and different points.

The topic of high-performance network programming has been discussed. Asynchronous, asynchronous, or asynchronous. Whether it is epoll or kqueue, it is always indispensable to the asynchronous topic.

Libuv is asynchronous, and libev is synchronous multiplexing IO multiplexing.

Libev is a simple encapsulation of system I/O reuse. Basically, it solves the problem of different APIs between epoll and kqueuq. Ensure that programs written using livev's API can run on most *nix platforms. However, the disadvantages of libev are also obvious. Because it basically just encapsulates the Event Library, it is inconvenient to use. For example, accept(3) requires manual setnonblocking after connection. EAGAIN, EWOULDBLOCK, and EINTER need to be detected when reading from a socket. This is a

zhangw /
Created June 20, 2023 12:09 — forked from ragul28/
k8s Trick to Scale down daemonset to zero
  • Scaling k8s daemonset down to zero
kubectl -n kube-system patch daemonset myDaemonset -p '{"spec": {"template": {"spec": {"nodeSelector": {"non-existing": "true"}}}}}'
  • Scaling up k8s daemonset
kubectl -n kube-system patch daemonset myDaemonset --type json -p='[{"op": "remove", "path": "/spec/template/spec/nodeSelector/non-existing"}]'
zhangw /
Created June 14, 2023 08:10 — forked from ayosec/
GDB commands to trace calls to malloc/free

Attach to a running process with

  gdb -x trace-dyn-mem -p $PID

After every malloc the returned value (the allocated address) will be read from the RAX (64 bits) register.

After every free the last item in the backtrace (the free itself) will be shown. With the libc6-dbg package installed you can see the address passed as the first argument of free.

zhangw / gist:06624e63baefda8523fb76b6003d2aa7
Last active March 30, 2023 04:02
Building starrocks fe on MacOS
# check the specific thrift version from fe-core, for 2.5.3
ag THRIFT_DOWNLOAD thirdparty/
# install the specific thrift version, using brew which help to compile automatically
brew tap-new $USER/local-tap
brew extract --version='0.13.0' thrift $USER/local-tap
brew install thrift@0.13.0
## check the installation path, for me
/opt/homebrew/Cellar/thrift@0.13.0/0.13.0/bin/thrift --version
zhangw / rust-openssl-musl-archlinux-build
Created February 18, 2023 15:03
rust + openssl + musl + archlinux
## install musl
sudo pacman -Syu musl
## install headers of musl
sudo pacman -Syu kernel-headers-musl
## cargo add musl target and toolchain
rustup target add --toolchain stable x86_64-unknown-linux-musl
## download openssl source code, version is 3.0.7
zhangw / rust-cross-compile-openssl
Last active February 18, 2023 05:16 — forked from marirs/rust-cross-compile-openssl
Rust OpenSSL Cross Compile for Linux on Mac M1
# Install the toolchain
brew tap SergioBenitez/osxct
brew install x86_64-unknown-linux-gnu
# this should get installed in:
# /opt/homebrew/Cellar/x86_64-unknown-linux-gnu/
# Installing the macOS OpenSSL - if not already installed