Skip to content

Instantly share code, notes, and snippets.

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

siddontang siddontang

🏠
Working from home
  • PingCAP
  • SunnyVale
View GitHub Profile
@siddontang
siddontang / song.py
Created January 31, 2024 01:09
Use ChatGPT to build a song
from music21 import stream, note, meter, tempo, expressions, instrument
# 创建一个音乐流
melody = stream.Stream()
# 设置拍号为4/4
melody.append(meter.TimeSignature('4/4'))
# # 设置曲速
# melody.append(tempo.MetronomeMark(number=120))
@siddontang
siddontang / Makefile
Created December 6, 2023 18:08
Support pre-build in Makefile
# Refer to https://stackoverflow.com/questions/1612278/pre-build-step-in-makefile
CC=gcc
.PHONY: all clean
.SECONDARY: main-build
all: pre-build main-build
pre-build:
@siddontang
siddontang / diff_directory.sh
Created December 2, 2023 01:26
Diff two directories and output the differences
#!/bin/bash
# Check for the correct number of arguments
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <directory1> <directory2> <output_directory>"
exit 1
fi
# Assign arguments to variables
DIR1="$1"
@siddontang
siddontang / BPF.txt
Last active July 19, 2023 08:21
BPF Performance Tools
Hello BPF
import subprocess
import socket
import time
import psutil
import glob
import requests
import concurrent.futures
def find_available_ports(num_ports):
func Escape(sql string) string {
dest := make([]byte, 0, 2*len(sql))
var escape byte
for i := 0; i < len(sql); i++ {
c := sql[i]
escape = 0
switch c {
case 0: /* Must be escaped for 'mysql' */
@siddontang
siddontang / haokan_down.go
Created March 20, 2023 03:18
Download Baidu Haokan video
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"strings"
)
@siddontang
siddontang / prompt_demo.md
Created February 6, 2023 01:53
Fortune 500 AI Prompt Run book
### MySQL SQL tables, with their properties:
#
# Table fortune.global_fortune_500_2018_2022, columns = [rank, company_name, country, employees_num, previous_rank, revenues_million, revene_change_percentage, profit_million, profit_change_percentage, asset_million, year]

Q: Compare the amount of businesses between china and the US
Let's think step by step, With the following template:

Start TiDB

tiup --tag 6.0 playground 6.0

Create Corteza database and account

Connect to TiDB

@siddontang
siddontang / build_leveldb.sh
Last active May 23, 2022 03:24
leveldb build shell
#!/bin/bash
SNAPPY_DIR=/usr/local/snappy
LEVELDB_DIR=/usr/local/leveldb
ROOT_DIR=$(pwd)
BUILD_DIR=/tmp/build_leveldb
mkdir -p $BUILD_DIR