Archives: software programming

open source linter and code coverage for C/C++ No ratings yet.

A poor man C/C++ linter and code coverage (gtests) C/C++ Linter: Cppcheck apt-get install cppcheck cppcheck –enable=all /your_cpp_source_dir   Test Code coverage : gcov/lcov g++ -o main –fprofile-arcs -ftest-coverage main_test.cpp -L /usr/lib -I/usr/include ./main gcov main_test.cpp lcov –coverage –directory . –output-file main_coverage.info genhtml main_coverage.info –output-directory out   https://medium.com/@naveen.maltesh/generating-code-coverage-report-using-gnu-gcov-lcov-ee54a4de3f11 https://dr-kino.github.io/2019/12/22/test-coverage-using-gtest-gcov-and-lcov/   CMake and code coverage for: • Read More »


zookeeper vs etcd 1/5 (1)

Use cases both provide strong consistance for key/value store. zookeeper use ZAB, etcd use raft, usually one leader. normally use as configure store Zookeeper more like file system https://zookeeper.apache.org/doc/r3.3.6/zookeeperStarted.html bin/zkCli.sh -server 127.0.0.1:2181 LD_LIBRARY_PATH=. cli_mt 127.0.0.1:2181 set /zk_test junk get /zk etcd: https://etcd.io/docs/v3.5/quickstart/ etcdctl put greeting “Hello, etcd” etcdctl get greeting Documents https://www.youtube.com/watch?v=BhosKsE8up8&ab_channel=BitTiger%E5%AE%98%E6%96%B9%E9%A2%91%E9%81%93BitTigerOfficialChannel Please rate this • Read More »


Raft consensus algorithm on distributed system No ratings yet.

Raft: paxos hard to understand, new consensus algorithm consensus algorithm:  Leader elections, log replicate https://github.com/etcd-io/etcd/blob/main/raft/README.md   This Raft library is stable and feature complete. As of 2016, it is the most widely used Raft library in production, serving tens of thousands clusters each day. It powers distributed systems such as etcd, Kubernetes, Docker Swarm, Cloud Foundry Diego, • Read More »


grpc deep drive No ratings yet.

GRPC   client side msg: header, msg, EOS server side msg:  header, msg, msg,  Trailer over http2 keep live? c++ async or sync? https://grpc.io/docs/languages/cpp/async/ , does it provider more performance than sync one? https://github.com/grpc/grpc/blob/v1.41.0/examples/cpp/helloworld/greeter_async_server.cc https://stackoverflow.com/questions/68767309/difference-between-sync-and-async-grpc https://docs.microsoft.com/en-us/dotnet/standard/async-in-depth https://www.hellsoft.se/understanding-cpu-and-i-o-bound-for-asynchronous-operations/ CPU Bound means the rate at which process progresses is limited by the speed of the CPU. A task that • Read More »


vim cheat sheet No ratings yet.

useful .vimrc set tabstop=2 set shiftwidth=2 set expandtab inoremap <S-Tab> <C-V><Tab> syntax on set t_Co=256 set colorcolumn=80 “crazy vim, do not allow copy/paste set mouse=v setlocal spell spelllang=en_us “for vert term  ( split vertical vim window) :set splitright :set splitbelow   useful .screenrc # Enable mouse scrolling and scroll bar history scrolling termcapinfo xterm* ti@:te@ • Read More »



cross compile native libwebrtc ( on x86_64 host) for arm64 No ratings yet.

Direct compile webrtc on arm64 will fail: webrtc seems does not support direct support on arm, we will get errors: … Running hooks: 18% ( 4/22) sysroot_arm64 ________ running ‘vpython src/build/linux/sysroot_scripts/install-sysroot.py –arch=arm64’ in ‘/webrtcbuilds/out’ Installing Debian sid arm64 root image: /webrtcbuilds/out/src/build/linux/debian_sid_arm64-sysroot Downloading https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/953c2471bc7e71a788309f6c2d2003e8b703305d/debian_sid_arm64_sysroot.tar.xz Running hooks: 50% (11/22) binutils ________ running ‘vpython src/third_party/binutils/download.py’ in ‘/webrtcbuilds/out’ Host • Read More »


c++ json lib: nlohmann::json No ratings yet.

nlohmann::json is a popluar json lib. code at: https://github.com/nlohmann/json document at: https://nlohmann.github.io/json/doxygen/index.html   sample code: #include <iostream> 2 #include <nlohmann/json.hpp> 3 4 using json = nlohmann::json; 5 6 int main() 7 { 8  // create a JSON object with different entry types 9  json j = 10  { 11  {“integer”, 1}, 12  {“floating”, 42.23}, 13  {“string”, “hello world”}, 14  • Read More »


webassembly and web audio worklet No ratings yet.

Some notes: web assembly: a cool technology allows you to compile c/c++/rust and other languages into wasm, expose API to javascript world. Web audio worklet/worker: allows developer to intercept audio stream/custom processing A good introduction is at: https://developers.google.com/web/updates/2017/12/audio-worklet Advance pattern: https://developers.google.com/web/updates/2018/06/audio-worklet-design-pattern https://github.com/GoogleChromeLabs/web-audio-samples/tree/master/audio-worklet/design-pattern/shared-buffer/     Combination of wasm and audio worklet can do a fair amount • Read More »


C++ how to replace mutex code with CAS ( compare and exchange ) ( lock-less programming ) 5/5 (2)

It is well known that if  mutex protected codes could potentially be replaced by atomic compare exchange,  thus we cab achieve lock-less programming. In practice, it may need several techniques to get it working. Let’s look at a subscription example: Normal mutex An subscriber  can subscribe some content from a publisher, in other word, a publisher • Read More »