Skip to content

Instantly share code, notes, and snippets.

View zhiteng's full-sized avatar

HUANG Zhiteng zhiteng

  • eBay Inc.
  • China
View GitHub Profile
@zhiteng
zhiteng / microgpt.py
Created February 12, 2026 06:08 — forked from karpathy/microgpt.py
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@zhiteng
zhiteng / byobuCommands
Created December 9, 2016 08:42 — forked from jshaw/byobuCommands
Byobu Commands
Byobu Commands
==============
byobu Screen manager
Level 0 Commands (Quick Start)
------------------------------
<F2> Create a new window
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
@zhiteng
zhiteng / volume_transfer_cleanup.py
Last active August 29, 2015 14:04
!!!Caution!!! This script can mess up your DB, do backup before you make any change with it. Script to update provider_auth (CHAP username and secret) for transferred volumes, for now it only works for volume hosted on SolidFire. related bug: https://launchpad.net/bugs/1349475
#!/usr/bin/env python
"""
volume_transfer_cleanup.py
Script to update provider_auth (CHAP username and secret) for transferred
volumes, for now it only works for volume hosted on SolidFire.
related bug: https://launchpad.net/bugs/1349475
Usage: volume_transfer_cleanup --mode={readonly, write}
If you only want to find out corrupted records without updating them, set
mode to readonly (the default value), e.g
@zhiteng
zhiteng / unused_config_opts.sh
Created January 7, 2014 15:50
Script roughly to scan all unused config options in OpenStack/Cinder repo.
#!/bin/sh
ALL_OPTS=`egrep -e '^#?\w*\s?=' etc/cinder/cinder.conf.sample|sed 's/#//g'|sed 's/=/ /g'|awk '{print $1}'|sed 's/\n/ /g'`
for i in $ALL_OPTS;
do
#RES=`find cinder -type f -name "*.py" ! -path "cinder/tests/*" -exec egrep -l "CONF.$i|configuration.$i" {} \; | sort -u`
RES=`egrep -l --include '*.py' --mmap "CONF.$i|configuration.$i|conf.$i" * -rn`
if [ $? -eq 1 ]; then
echo $i is unused
UNUSED=`echo $UNUSED $i`
@zhiteng
zhiteng / find_swift_untracked_objects
Created January 6, 2014 09:12
This is a script that can find all objects that exists on Swift storage node but aren't seen by Swift (can't be access via Swift proxy).
#!/bin/bash
# Script to detect untracked objects in Swift, it's been tested against
# Grizzly Swift (keystone as auth) without problem
# It could take very LONG time (several minutes ~ hours) if there are lots of
# objects.
#
# This script must be run on storage nodes
# Prerequisites:
# - have access to object directory
# - swift client is installed
# Openstack API
## Keystone
http http://localhost:5000/v2.0/tokens auth:='{"passwordCredentials":{"username": "demo", "password":"pass"}, "tenantId":"f24d505c225641a3a728319a166db960"}'
## Cinder
http POST http://localhost:8776/v1/5d36abf49d654799b843e2c010e10649/volumes X-Auth-Token:'65d175eb2899496f8f948e113d06e537' volume:='{"display_name":"foo", "size": 1}'
http GET http://localhost:8776/v1/dff93e4df7354ac283f8f957a10c1caa/volumes X-Auth-Token:'da3c04fee49f442e8c934692c90468f3'