Skip to content

Instantly share code, notes, and snippets.

@chenziliang
chenziliang / Dockerfile
Created March 21, 2023 15:35 — forked from tylerchr/Dockerfile
Compiling V8 for alpine (link against musl)
#
# Building V8 for alpine is a real pain. We have to compile from source, because it has to be
# linked against musl, and we also have to recompile some of the build tools as the official
# build workflow tends to assume glibc by including vendored tools that link against it.
#
# The general strategy is this:
#
# 1. Build GN for alpine (this is a build dependency)
# 2. Use depot_tools to fetch the V8 source and dependencies (needs glibc)
# 3. Build V8 for alpine
@chenziliang
chenziliang / benchmark-commands.md
Created July 17, 2021 05:48 — forked from ueokande/benchmark-commands.md
Kafka Benchmark Commands

Benchmark commands

Producer

Setup

bin/kafka-topics.sh \
  --zookeeper zookeeper.example.com:2181 \
  --create \
@chenziliang
chenziliang / sampling.sql
Created January 13, 2021 05:30 — forked from den-crane/sampling.sql
SAMPLING
https://stackoverflow.com/questions/64369622/using-sample-in-clickhouse-seems-to-read-all-rows-and-more-bytes-is-this-expect
CREATE TABLE table_one
( timestamp UInt64,
transaction_id UInt64,
banner_id UInt16,
value UInt32
)
ENGINE = MergeTree()
PARTITION BY toYYYYMMDD(toDateTime(timestamp))
@chenziliang
chenziliang / clickhouse-config.patch
Last active January 11, 2021 00:00
debug friendly clickhouse config
diff --git a/programs/server/config.xml b/programs/server/config.xml
index 851a7654d5..ac7b2510b1 100644
--- a/programs/server/config.xml
+++ b/programs/server/config.xml
@@ -123,7 +123,7 @@
<!-- Listen specified host. use :: (wildcard IPv6 address), if you want to accept connections both with IPv4 and IPv6 from everywhere. -->
<!-- <listen_host>::</listen_host> -->
<!-- Same for hosts with disabled ipv6: -->
- <!-- <listen_host>0.0.0.0</listen_host> -->
+ <listen_host>0.0.0.0</listen_host>

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@chenziliang
chenziliang / DPDK on AWS howto
Created May 29, 2019 06:44 — forked from PatrickDehkordi/DPDK on AWS howto
Installing and configuring DPDK on AWS
sudo yum install numactl-devel
wget https://fast.dpdk.org/rel/dpdk-17.11.2.tar.xz
cd dpdk-stable-17.11.2/
make config T=x86_64-native-linuxapp-gcc
make
sudo modprobe uio
sudo insmod /home/ec2-user/dpdk-stable-17.11.2/build/kmod/igb_uio.ko
sudo yum install pciutils
sudo vi /etc/sysctl.conf vm.nr_hugepages = 1024
sudo sysctl -p

Building Kafka from the Hardware - up

  • Higher Message Retention ? - Increase disk size
  • Higher Message Throughput ? - Increase network capacity
  • Higher Producer Performance ? - Increase Disk I/O speed
  • Higher Consumer Performance ? - Increase Memory

Critical Configurations (Consumer)

  • queued.min.messages
  • fetch.wait.max.ms
  • socket.blocking.max.ms
@chenziliang
chenziliang / golang-tls.md
Created April 23, 2019 04:36 — forked from denji/golang-tls.md
Simple Golang HTTPS/TLS Examples

Moved to git repository: https://github.com/denji/golang-tls

Generate private key (.key)
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048

# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
@chenziliang
chenziliang / main.cpp
Created December 11, 2018 19:27 — forked from nazgee/main.cpp
linux file descriptors passing between processes
#include <errno.h>
#include <string.h>
#include <iostream>
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@chenziliang
chenziliang / client.go
Created March 17, 2018 20:05 — forked from xjdrew/client.go
golang tls client and server, require and verify certificate in double direction
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"os"