Skip to content

Instantly share code, notes, and snippets.

View hzhangxyz's full-sized avatar

Hao Zhang(张浩) hzhangxyz

View GitHub Profile
@hzhangxyz
hzhangxyz / log.txt
Created August 11, 2025 02:47
check-for-ib-net
command:
for j in `seq 2 6`; do ip=192.168.0.$j; echo $ip; for i in `seq 0 7`; do id=`talosctl --nodes $ip ls /sys/class/infiniband/mlx5_$i --long | grep device | awk '{print $12}' | sed 's/\.\.\///g'`; echo $id; talosctl --nodes $ip cat /sys/bus/pci/devices/$id/class; done; echo; done;
output:
192.168.0.2
0000:29:00.0
0x020000
0000:3b:00.0
0x020000
0000:4b:00.0
#include <format>
#include <print>
#include <string>
#include <vector>
struct Dog {
std::string name;
void Say() const {
std::print("{}: Woof!\n", name);
}
@hzhangxyz
hzhangxyz / learn-autograd.ipynb
Last active July 9, 2025 10:12
learn-autograd.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hzhangxyz
hzhangxyz / haskell.md
Created May 21, 2025 08:04
haskell.md

Monad

pure vs impure

  • pure
def add(a: int, b: int) -> int:
    return a + b
@hzhangxyz
hzhangxyz / main.py
Last active September 23, 2023 13:26
gpt-3.5-instruct-webui.py
import os
import openai
import asyncio
import gradio as gr
MODEL = "gpt-3.5-turbo-instruct"
if "OPENAI_PROXY" in os.environ:
openai.proxy = os.environ["OPENAI_PROXY"]
openai.api_key = os.environ["OPENAI_API_KEY"]
@hzhangxyz
hzhangxyz / Tools.f90
Created August 30, 2023 13:40
For lfortran issue reproduction
!
! _ooOoo_
! o8888888o
! 88" . "88
! (| -_- |)
! O\ = /O
! ____/`---'\____
! .' \\| |// `.
! / \\||| : |||// \
! / _||||| -:- |||||- \
@hzhangxyz
hzhangxyz / P2M.py
Created August 19, 2023 03:33
Python AST Transformer
import ast
import inspect
import types
class Apply(ast.NodeTransformer):
def __init__(self):
super().__init__()
self._never_function = True
@hzhangxyz
hzhangxyz / nonebot_zhipuai.py
Last active December 23, 2023 06:34
nonebot_zhipuai_bot
from nonebot.adapters import Event, Message
from nonebot.params import EventPlainText, CommandArg
from nonebot.plugin.on import on_message, on_command
from nonebot.adapters.onebot.v11.message import MessageSegment
import os
import ast
import json
import shelve
import aiohttp
@hzhangxyz
hzhangxyz / main.py
Last active April 22, 2023 10:53
Cli chatgpt bot program(The main part of this program is copied from https://github.com/zzh1996/chatgpt-telegram-bot/blob/master/main.py)
import asyncio
import fire
import openai
import os
import prompt_toolkit
import tiktoken
# Authenticate with OpenAI API
assert "OPENAI_API_KEY" in os.environ, "OPENAI_API_KEY environment variable not set."
openai.api_key = os.environ["OPENAI_API_KEY"]
@hzhangxyz
hzhangxyz / mwe.py
Created February 28, 2023 10:39
An example to reproduce a bug(maybe) of mkl
import TAT
Tensor = TAT.No.D.Tensor
L1 = 2
L2 = 4
D = 5
def construct_tensor(l1, l2):