Skip to content

Instantly share code, notes, and snippets.

View Spico197's full-sized avatar
🛴
Fresh Man

Tong Zhu (朱桐) Spico197

🛴
Fresh Man
View GitHub Profile
@Spico197
Spico197 / ck-fishing.ahk
Created April 14, 2025 03:44
Core Keeper Automatic Fishing Script
#Persistent
#SingleInstance Force
; ---------- 用户配置区 ----------
targetColor := "0X2B23DE" ; 格式为 0xRRGGBB(注意是 BGR 顺序),感叹号中的红色颜色
colorVariation := 30 ; 颜色容差(0-255,越大越宽松)
; 感叹号区域坐标。如果不确定是多少的话,可以任意调整,鼠标会先显示两次。多显示器设置下,游戏必须处于主显示器
X1 := 1446 ; 左上角 X
Y1 := 590 ; 左上角 Y
@Spico197
Spico197 / flops_calculator_v2.py
Last active November 29, 2024 14:39
FLOPs calculator for LLaMA-MoE-v2
"""
Inference FLOPs calculation
Borrowed from nanotron: https://github.com/huggingface/nanotron/blob/cfcdeae812d4c7210990932ebcce5f672084408d/src/nanotron/models/llama.py#L1100
"""
def convert_to_human_readable_size(num):
if num / 1e9 > 1:
return f"{num / 1e9:.2f} B"
elif num / 1e6 > 1:
return f"{num / 1e6:.2f} M"
@Spico197
Spico197 / remote_debugging.py
Created June 13, 2024 06:36
Remote debugging with VSCode
import socket
import debugpy # pip install debugpy
import torch.distributed as dist
def remote_breakpoint(host: str = "0.0.0.0", port: int = 5678, rank: int = 0):
"""
If you found any problems, please contact zhutong (tzhu1997@outlook.com)
@Spico197
Spico197 / oneie_to_mirror_udi.ipynb
Created May 9, 2024 07:31
OneIE to Mirror UDI format @fairyshine
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Spico197
Spico197 / side_adapter.py
Created November 23, 2023 14:16
side adapter speed test
import time
import torch
import torch.optim as optim
import torch.nn as nn
from tqdm import trange
class SideAdapterFFNProbing(nn.Module):
"""
@Spico197
Spico197 / shut_the_door_please.py
Created February 17, 2023 15:14
Raspberry Pi with photoelectric sensor and bluetooth speaker to notify shutting the door.
"""
Play sound while reading signal is 0 on Raspberry Pi 3 Model B
Installation:
- python -m pip install gpiozero playsound
- sudo apt install python3-gst-1.0
"""
import time
import logging
@Spico197
Spico197 / find_same_password_with_username.py
Created May 27, 2022 09:21
Find all users whose username and password are the same
# Find all users whose username and password are the same
# Tested under linux
# NOTICE: ssh to target IP first to receive fingerprint
# Installation: pip install rich paramiko
import sys
from rich.console import Console
from rich.table import Table
from rich.progress import Progress
# be like:
# (torch) tzhu @ hostname : ~/REx (main)
# $
bold=`echo -en "\e[1m"`; underline=`echo -en "\e[4m"`; dim=`echo -en "\e[2m"`; strickthrough=`echo -en "\e[9m"`; blink=`echo -en "\e[5m"`; reverse=`echo -en "\e[7m"`; hidden=`echo -en "\e[8m"`; normal=`echo -en "\e[0m"`; black=`echo -en "\e[30m"`; red=`echo -en "\e[31m"`; green=`echo -en "\e[32m"`; orange=`echo -en "\e[33m"`; blue=`echo -en "\e[34m"`; purple=`echo -en "\e[35m"`; aqua=`echo -en "\e[36m"`; gray=`echo -en "\e[37m"`; darkgray=`echo -en "\e[90m"`; lightred=`echo -en "\e[91m"`; lightgreen=`echo -en "\e[92m"`; lightyellow=`echo -en "\e[93m"`; lightblue=`echo -en "\e[94m"`; lightpurple=`echo -en "\e[95m"`; lightaqua=`echo -en "\e[96m"`; white=`echo -en "\e[97m"`; default=`echo -en "\e[39m"`; BLACK=`echo -en "\e[40m"`; RED=`echo -en "\e[41m"`; GREEN=`echo -en "\e[42m"`; ORANGE=`echo -en "\e[43m"`; BLUE=`echo -en "\e[44m"`; PURPLE=`echo -en "\e[45m"`; AQUA=`echo -en "\e[46m"`; GRAY=`echo -en "\e[47m"`; DARKGRAY=`echo -en "\e[100m"`; LIGHTRED=`ec
@Spico197
Spico197 / sent_seg.py
Last active August 6, 2020 12:54
sentence segmentation
import re
def sent_seg(text, special_seg_indicators=None, lang='zh',
punctuations=None, quotation_seg_mode=True) -> list:
"""
cut texts into sentences (in chinese language).
Args:
text <str>: texts ready to be cut
special_seg_indicators <list>: some special segment indicators and
@Spico197
Spico197 / draw.py
Created July 23, 2020 13:27
use matplotlib to draw histogram and horizontal bar plots
import json
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.sans-serif'] = ['SimHei'] # 指定默认字体
mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
mpl.rcParams['axes.titlesize'] = 20