Skip to content

Instantly share code, notes, and snippets.

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

Yunze Xu BewareMyPower

🏠
Working from home
View GitHub Profile
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: MLDataFormats.proto
"""Generated protocol buffer code."""
from google.protobuf import descriptor as _descriptor
from google.protobuf import descriptor_pool as _descriptor_pool
from google.protobuf import symbol_database as _symbol_database
from google.protobuf.internal import builder as _builder
# @@protoc_insertion_point(imports)
@BewareMyPower
BewareMyPower / build-pulsar-cpp-dependencies-centos7.sh
Last active September 8, 2023 09:09
Build the dependencies of Pulsar C++ client on CentOS 7
export PLATFORM=aarch64
# An example to switch to GCC 10
#sudo yum install centos-release-scl
#sudo yum install devtoolset-10
#scl enable devtoolset-10 bash
set -ex
BOOST_VERSION=1.80.0
@BewareMyPower
BewareMyPower / build-pulsar-cpp-dependencies-ubuntu.sh
Created August 25, 2023 09:35
Build the dependencies of Pulsar C++ client on Ubuntu 22.04
#!/bin/bash
set -ex
cd `dirname $0`
# define dependency versions
BOOST_VERSION=1.80.0
CMAKE_VERSION=3.4.2
PROTOBUF_VERSION=3.20.0
ZLIB_VERSION=1.2.12
ZSTD_VERSION=1.5.2
@BewareMyPower
BewareMyPower / GitConfigHttpProxy.md
Created January 31, 2023 05:49 — forked from evantoli/GitConfigHttpProxy.md
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

@BewareMyPower
BewareMyPower / cyclic_references.cc
Last active September 4, 2022 16:32
c++ shared_ptr cyclic references by capturing shared_from_this()
#include <atomic>
#include <functional>
#include <iostream>
#include <memory>
using namespace std;
static std::atomic_int idGenerator{0};
struct Object {
int id;
@BewareMyPower
BewareMyPower / InterleavingTransactionExample.java
Last active June 30, 2022 08:54
Verify the interleaving transactional messages in Kafka
import java.time.Duration;
import java.util.Collections;
import java.util.Properties;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.annotation.Nullable;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.admin.AdminClient;
@BewareMyPower
BewareMyPower / TimerTask.cc
Last active December 14, 2020 01:48
Simulate pulsar cpp client's ExecutorService and timer registration
// TimerTask.cc: simulate pulsar cpp client's ExecutorService and timer registration.
// Compile:
/*
BOOST_DIR=/your/path/to/boost
g++ -g TimerTask.cc -std=c++11 \
-I $BOOST_DIR/include -L $BOOST_DIR/lib -lboost_system -lpthread
*/
#include <boost/asio.hpp>
#include <chrono>
#include <iostream>
@BewareMyPower
BewareMyPower / install_pulsar_client_cpp.sh
Created October 20, 2020 14:44
安装 libpulsar.so 到系统路径(Ubuntu/Debian 版本)
#!/bin/bash
# 适用于 Ubuntu/Debian 系统的 pulsar-client-cpp 编译脚本
set -e
# 0. 安装基本工具
apt install -y git wget
# 1. 安装编译工具,在 Debian 4.9.210-1 (2020-01-20) 上面是 g++ 6.3 和 cmake 3.7
# 最低要求:g++ >= 4.8.5,cmake >= 3.4
apt install -y gcc g++ cmake
@BewareMyPower
BewareMyPower / run-single-pulsar-cluster.sh
Last active January 13, 2021 01:37
Run a simplest pulsar cluster without standalone
#!/bin/bash
###################################################################################################
# Deploy a simplest Pulsar cluster. It's more flexible than deploying a Pulsar standalone
#
# conf/log4j2.yaml:
#
# ```
# immediateFlush: true
# ```
#
// g++ ObjectPool.cc -std=c++14 -pthread -O2
#include "ObjectPool.h" // https://github.com/apache/pulsar/tree/master/pulsar-client-cpp/lib/ObjectPool.h
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
using namespace std;
inline auto now() { return std::chrono::high_resolution_clock::now(); }