Skip to content

Instantly share code, notes, and snippets.

View w32zhong's full-sized avatar
⛹️
Trying to keep up.

Wei w32zhong

⛹️
Trying to keep up.
View GitHub Profile
@w32zhong
w32zhong / code.js
Created June 4, 2025 13:07 — forked from iiLaurens/code.js
Get all clickable elements on a page
window.scrollTo(0, 0)
var bodyRect = document.body.getBoundingClientRect();
var items = Array.prototype.slice.call(
document.querySelectorAll('*')
).map(function(element) {
var rect=element.getBoundingClientRect();
return {
element: element,
include: (element.tagName === "BUTTON" || element.tagName === "A" || (element.onclick != null) || window.getComputedStyle(element).cursor == "pointer"),
@w32zhong
w32zhong / train.py
Created May 17, 2025 19:42 — forked from ddh0/train.py
Janky pretraining script for small llama models using HF fineweb - modify according to your needs
import os
import torch
import psutil
import datasets
import glob
from transformers import (
AutoTokenizer, LlamaConfig, LlamaForCausalLM, Trainer, TrainingArguments,
DataCollatorForLanguageModeling
)
@w32zhong
w32zhong / grpo_demo.py
Created February 18, 2025 01:17 — forked from willccbb/grpo_demo.py
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
@w32zhong
w32zhong / Treap.py
Created February 28, 2023 17:14 — forked from irachex/Treap.py
Treap (tree + heap) in Python
import random
class TreapNode(object):
def __init__(self, key, data):
self.key = key
self.ran = random.random()
self.size = 1
self.cnt = 1
self.data = data
self.left = None
@w32zhong
w32zhong / mutual_info.py
Created February 4, 2022 19:44 — forked from GaelVaroquaux/mutual_info.py
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
This code is maintained at https://github.com/mutualinfo/mutual_info
Please download the latest code there, to have improvements and
bug fixes.
@w32zhong
w32zhong / README.md
Created July 30, 2020 02:31 — forked from nitaku/README.md
Minimal JSON HTTP server in python

A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.

python server.py 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
@w32zhong
w32zhong / font-awesome-v5.0.1.json
Created February 21, 2020 15:05
List of all free Font Awesome icons class names v5.0.1
view icons: https://fontawesomeicons.com/
{"name":"Font Awesome v5.0.1", "icons":[
"fab fa-500px",
"fab fa-accessible-icon",
"fab fa-accusoft",
"fas fa-address-book", "far fa-address-book",
"fas fa-address-card", "far fa-address-card",
"fas fa-adjust",
"fab fa-adn",
@w32zhong
w32zhong / mathjax-responsive-scaling.html
Created August 1, 2018 05:51 — forked from adrianwong/mathjax-responsive-scaling.html
Responsive scaling of MathJax formulae
<script type="text/javascript">
window.MathJax = {
jax: ["input/TeX", "output/CommonHTML"],
extensions: ["tex2jax.js"],
TeX: {
equationNumbers: { autoNumber: "AMS" },
extensions: ["AMSmath.js", "AMSsymbols.js", "noErrors.js", "noUndefined.js"]
},
/* The MathJax API provides us with the ability to register
callbacks on signals broadcast during its startup sequence.
#include "var.h"
#include <stdio.h>
#define hello1(s) hello2(s, "default string")
void hello2(const char *s, const char* s2) {
printf("hello2 %s and %s\n", s, s2);
}
#define hello(...) xglue(hello, PP_NARG(__VA_ARGS__))(__VA_ARGS__)
@w32zhong
w32zhong / spectre.c
Created January 14, 2018 16:02 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif