Skip to content

Instantly share code, notes, and snippets.

@laohyx
laohyx / view-gpu-with-model.sh
Last active July 7, 2025 03:00
Show k8s nodes with GPU model, allocated and free resources.
#!/usr/bin/env bash
# -----------------------------------------------------------------------------
# view-gpu-with-model.sh
# -----------------------------------------------------------------------------
# Wrapper for `kubectl-view-allocations -r gpu`:
# 1. Retrieves each Node's NVIDIA GPU model
# 2. Appends the model name at end of each line (preserves column alignment)
# 3. Highlights models by performance class (H100, A100, 5090, 4090, 3090)
# 4. Colorizes utilization percentages "(XX%)" in a gradient (green→yellow→red)
#
@laohyx
laohyx / irqtop.py
Created April 28, 2023 09:58
Liux interrupts watcher and list top IRQs
import time
__doc__ = """This script greps from /proc/interrupts and print the top interrupts of CPU cores and sources.
Super useful for 64+ cores machine, whose /proc/interrupts is totally unreadable.
"""
def get_interrupts_dict():
cpu_count = 0
result = {}
with open('/proc/interrupts') as f:
@laohyx
laohyx / time.cpp
Last active December 15, 2017 05:25
One liner for getting current microsecond of unix timestamp.
#include <chrono>
int64_t timeInMicroseconds() {
auto now = std::chrono::system_clock::now();
auto duration = now.time_since_epoch();
return std::chrono::duration_cast<std::chrono::microseconds>(duration).count();
}
@laohyx
laohyx / LaoRenren.py
Created January 23, 2012 04:42
LaoRenren - Laohyx Renren simulation processor in Python
#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
LaoRenren 人人网模拟登录类 v0.1 2012/1/22 除夕夜
以LaoWeb.py封闭的人人网模拟登录、发状态、传照片等类。
支持保存状态,避免验证码
那些GPL就不废话了,转载修改请注明原作者。
[email protected]
By Laohyx.
@laohyx
laohyx / LaoWeb.py
Created January 23, 2012 04:37
LaoWeb - Laohyx web processor in python
#!/usr/bin/python
# coding=utf-8
import urllib2,cookielib,urllib,re,time
'''
LaoWeb HTTP封装类 v0.2 2012/1/22 除夕夜
Http操作模拟类,支持正则等简易功能。
那些GPL就不废话了,转载修改请注明原作者。
[email protected]