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 genhtml –output-directory out   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 bin/ -server LD_LIBRARY_PATH=. cli_mt set /zk_test junk get /zk etcd: etcdctl put greeting “Hello, etcd” etcdctl get greeting Documents 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   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? , does it provider more performance than sync one? 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/ –arch=arm64’ in ‘/webrtcbuilds/out’ Installing Debian sid arm64 root image: /webrtcbuilds/out/src/build/linux/debian_sid_arm64-sysroot Downloading Running hooks: 50% (11/22) binutils ________ running ‘vpython src/third_party/binutils/’ in ‘/webrtcbuilds/out’ Host • Read More »

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

nlohmann::json is a popluar json lib. code at: document at:   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: Advance pattern:     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 »