Skip to content

Instantly share code, notes, and snippets.

View tianchaijz's full-sized avatar
🏠
Working from home

tianchaijz tianchaijz

🏠
Working from home
View GitHub Profile
@tianchaijz
tianchaijz / micromusic.py
Last active September 3, 2026 11:32 — forked from kaizenman/micromusic.py
micromusic
"""
micromusic.py - A GPT that learns to compose melodies.
Pure Python, zero dependencies, one file.
Inspired by @karpathy's microgpt. Same algorithm, different domain.
Instead of learning the pattern of names, it learns the pattern of music
python micromusic.py trains on CPU, prints hallucinated melodies
python micromusic.py --save same + saves MIDI files you can listen to
@kaizenman
  1. Gen cert
openssl req -x509 -nodes -newkey rsa:2048 -sha256 -keyout client.key -out client.crt -subj "/C=US/ST=FL/L=Ocala/O=Company/CN=x.org"
  1. tunnel.service
@tianchaijz
tianchaijz / HighTrafficServerSettings.md
Created April 6, 2022 05:05 — forked from fschiettecatte/HighTrafficServerSettings.md
High Traffic Server Settings on CentOS 8

High Traffic Server Settings on CentOS 8

I recently did some work to optimize the network configuration of a CentOS 8 based web server that receives a lot of traffic.

There is a lot of information on the web for this and it distills down to a minimum recommended configuration, and a recommended configuration.

The minimum recommended configuration should be sufficient for servers with less than 10Gb, and the recommended configuration should be sufficient for servers with 10Gb or more.

@tianchaijz
tianchaijz / CGO.md
Created February 16, 2022 03:21 — forked from dwbuiten/CGO.md

Problems & Solutions for Interaction Between C and Go

At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.

Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.

Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.

Table of Contents

当年,微软规定的编码风格是,(变量名里面)2个或3个字母的缩写词必须全部大写,4个或4个以上字母的缩写词必须首字母大写。
-- Chris Wilson(前微软员工)回答为什么 XMLHttpRequest 会有如此奇葩的大小写组合。
package main
import (
"fmt"
"golang.org/x/net/http2/hpack"
)
func main() {
fmt.Println("nginx", "→", Encode("MYWS"))
fmt.Println("nginx", "→", Encode("nginx"))
package main
import (
"fmt"
"net/http"
"os"
"path"
"strconv"
)