{"@attributes":{"version":"2.0"},"channel":{"title":"Guihao Liang","description":"Do a tiny of this. Do a tiny of that.","link":"https:\/\/guihao-liang.github.io\/","item":[{"title":"Golang: string reading","description":"\n          Golang memory allocation during conversion between string and slice - \n          TL;DR, Memory allocation happens immediately when converting between string and slice. To avoid using unnecessary memory, below is the table when reading utf-encoded string: string content random read sequential read write ascii string string []byte utf-8 []rune range []rune Random read string to rune slice To random access character in...\n        ","pubDate":"Sun, 31 Jan 2021 17:51:46 +0000","link":"https:\/\/guihao-liang.github.io\/2021\/01\/31\/str-convesion","guid":"https:\/\/guihao-liang.github.io\/2021\/01\/31\/str-convesion"},{"title":"Golang interface value: fat pointer again?","description":"\n          A brief tour to golang interface value - \n          Recently, I have a project that requires me to learn golang in a short time. IMO, all language with GC is easy to learn and so does golang. Comparing golang with Rust I started my journey with a book, the go programming language, which is well written. I skimmed the...\n        ","pubDate":"Sun, 05 Jul 2020 00:00:00 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/07\/05\/interface-type-value","guid":"https:\/\/guihao-liang.github.io\/2020\/07\/05\/interface-type-value"},{"title":"Understand rust Vec indexing","description":"\n          declaration vs definition time compiler check - \n          As I read the documentation for rust Vec, I want to understand how index operator [] works. For example, v[0] is a syntax sugar for *v.index(0) and how index is implemented? This leads me to Index trait implementation. impl&lt;T, I: SliceIndex&lt;[T]&gt;&gt; Index&lt;I&gt; for Vec&lt;T&gt; { type Output = I::Output; #[inline]...\n        ","pubDate":"Sun, 14 Jun 2020 14:49:50 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/06\/14\/index-trait-for-Vec","guid":"https:\/\/guihao-liang.github.io\/2020\/06\/14\/index-trait-for-Vec"},{"title":"Learn Rust fat pointer and type erasure from a Cpp programmer's perspective","description":"\n          Understand TraitObject and Slice implementation - \n          The concept for Sized and Unsized is related to the type layout in Rust Types where all values have the same size and alignment known at compile time implement the Sized trait and can be checked with the size_of and align_of functions. Types that are not Sized are known as...\n        ","pubDate":"Sat, 06 Jun 2020 16:25:02 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/06\/06\/fat-pointer","guid":"https:\/\/guihao-liang.github.io\/2020\/06\/06\/fat-pointer"},{"title":"Learn rust mut from a Cpp programmer's perspective","description":"\n          Rust mut vs Cpp const - \n          At beginning of learning rust, I mistakenly thought mut is a type decorator, fn foo(v: mut i32) { \/\/ blah } This won\u2019t compile since there\u2019s no such type called mut i32. but in C, void foo(int const bar, const int baz) { \/\/ blah } It seems like there\u2019s...\n        ","pubDate":"Sat, 30 May 2020 18:04:37 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/05\/30\/mut-in-rust","guid":"https:\/\/guihao-liang.github.io\/2020\/05\/30\/mut-in-rust"},{"title":"Understand C++ vtable from assembly code (part 1)","description":"\n          A glance at vtable implementation - \n          tl;dr For simplicity, part 1 only discusses how vtable works with single-inheritance. Part 2 will come soon to cover how vtable works with multi-inheritance. Also, I assume the inheritance is done through virtual functions not the static shadowing. We all know virtual function call cannot be inlined and it has...\n        ","pubDate":"Sat, 30 May 2020 18:04:37 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/05\/30\/what-is-vtable-in-cpp","guid":"https:\/\/guihao-liang.github.io\/2020\/05\/30\/what-is-vtable-in-cpp"},{"title":"Run NASM hello world on macOS","description":"\n          My first NASM program on x86_64 arch - \n          TL;DR Recently, I start learning NASM and following this tutorial. Even though this is an example for Linux, I plan to run this on my Mac. global _start section .text _start: mov rax, 1 ; system call for write mov rdi, 1 ; file handle 1 is stdout mov rsi,...\n        ","pubDate":"Sun, 24 May 2020 12:04:56 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/05\/24\/hw-mac","guid":"https:\/\/guihao-liang.github.io\/2020\/05\/24\/hw-mac"},{"title":"Use docker-in-docker in CI\/CD","description":"\n          A brief intro to dind - \n          Dind Recently, I need to upgrade docker version in gitlab runner and I get some exposure to the dind or docker-in-docker service. build_some_thing: tags: - docker stage: build services: - docker:18.09-dind image: docker:18.09 variables: DOCKER_HOST: tcp:\/\/docker:2375 DOCKER_DRIVER: overlay2 DOCKER_CERTS: \"\" script: - apk add bash - bash -e echo \"this...\n        ","pubDate":"Mon, 04 May 2020 16:00:44 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/05\/04\/docker-in-docker","guid":"https:\/\/guihao-liang.github.io\/2020\/05\/04\/docker-in-docker"},{"title":"what does brk and sbrk stand for?","description":"\n          BSS - Better Save Space? - \n          brk or break I read one great article for introducing JIT. There\u2019s a section where it mentions heap memory can be requested by system call brk and sbrk. But what do they stands for? From the man page, brk() and sbrk() change the location of the program break, which defines...\n        ","pubDate":"Sat, 02 May 2020 15:40:43 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/05\/02\/brk","guid":"https:\/\/guihao-liang.github.io\/2020\/05\/02\/brk"},{"title":"Install-name-id and install-name-value on Mac","description":"\n          Runtime linking with install-name-id and value - \n          When you man install_name_tool, it doesn\u2019t really tell you what\u2019s the difference between install-name-id and install-name-value. id is used at link time and value is used at runtime. They are all information provided for the linker to locate the dylib. The example used below is inspired by this tutorial. Note...\n        ","pubDate":"Wed, 22 Apr 2020 18:49:12 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/04\/22\/install-name-id","guid":"https:\/\/guihao-liang.github.io\/2020\/04\/22\/install-name-id"},{"title":"How AWS CPP SDK handles retry on S3 errors?","description":"\n          An alternative documentation for retry strategy of AWS CPP SDK - \n          Summary AWS SDK will do retry for you under 3 conditions client network failures. Usually, requests are not made to the server. deciding from Http response code when the response body from server side is empty. The logic is in IsRetryableHttpResponseCode. It will retry on server (5xx), throttling (599, bandwidth-limited),...\n        ","pubDate":"Sun, 12 Apr 2020 21:33:32 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/04\/12\/aws-s3-retry","guid":"https:\/\/guihao-liang.github.io\/2020\/04\/12\/aws-s3-retry"},{"title":"AWS CPP SDK cannot resolve hostname","description":"\n          virtual-hosted style vs path-style - \n          Recently, I upgraded the AWS CPP SDK from 0.40, which was integrated to turicreate codebase around 2017, to 1.7.143. Later, I rewrote our S3 path with the latest SDK and deprecated the old CURL based implementation. After this refactoring, turicreate can interact with S3 that uses SIGV4 authentication, which is...\n        ","pubDate":"Wed, 08 Apr 2020 21:02:08 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/04\/08\/aws-virtual-address","guid":"https:\/\/guihao-liang.github.io\/2020\/04\/08\/aws-virtual-address"},{"title":"wheel not installed by pip","description":"\n          remember to check PYTHONPATH if package is already satisfied - \n          Recently, I\u2019m assigned to redesign the packaging pipeline for turicreate python wheel, which is a ZIP-formatted archive. After finishing packaging the wheel package, I want to install it into the site-package of my virtual environment. But it refuses to install it there by saying, $ pip install ~\/turicreate-6.1-cp36-cp36m-macosx_10_14_x86_64.whl Requirement already...\n        ","pubDate":"Thu, 26 Mar 2020 20:10:49 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/03\/26\/python-path","guid":"https:\/\/guihao-liang.github.io\/2020\/03\/26\/python-path"},{"title":"Compiler header search order","description":"\n          Compile Cython with setuptools - \n          Distinguish C and C++ header search path Recently, I was using setuptools to build Cython source files for turicreate library, which is a better way of building and linking Cython extensions. setup( ext_modules=cythonize( [ Extension( \"*\", [\"turicreate\/_cython\/*.pyx\"], include_dirs=include_dirs, libraries=[\"TuriCore\"], library_dirs=library_dirs, extra_compile_args=[\"-O3\", \"-DNDEBUG\", \"-std=c++11\", \"-w\"], ), ] ), ) The approach...\n        ","pubDate":"Thu, 26 Mar 2020 20:10:49 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/03\/26\/compiler-search-oder","guid":"https:\/\/guihao-liang.github.io\/2020\/03\/26\/compiler-search-oder"},{"title":"CMake 101: if I know how if works","description":"\n          Expalin rules for cmake if\/while - \n          TL;DR, check the decision tree and summary. Intro For most beginners, CMake if is a nightmare. It sometimes takes a quoted string as variable and sometimes it takes a quoted string as a pure string literal, as many other languages do. In CMake, everything is string. You may see CACHE...\n        ","pubDate":"Sat, 04 Jan 2020 12:23:20 +0000","link":"https:\/\/guihao-liang.github.io\/2020\/01\/04\/cmake-101","guid":"https:\/\/guihao-liang.github.io\/2020\/01\/04\/cmake-101"},{"title":"Build OpenMP with Apple Clang","description":"\n          In-tree and out-of-tree build in practice with CMake - \n          Summary TL;DR, clang in XCode toolchain (I call it Apple Clang, run xcrun -f clang to locate) doesn\u2019t support -fopenmp option. In order to use OpenMP, follow this post and this PR. set(ON_X86 ON CACHE BOOL \"build on x86 architecture\") set(LIBOMP_COPY_EXPORTS FALSE CACHE STRING \"build in place\") ... # build...\n        ","pubDate":"Wed, 18 Dec 2019 00:00:00 +0000","link":"https:\/\/guihao-liang.github.io\/2019\/12\/18\/build-opemmp-with-apple-clang","guid":"https:\/\/guihao-liang.github.io\/2019\/12\/18\/build-opemmp-with-apple-clang"},{"title":"How to detect compiler architecture when compiling?","description":"\n          \n          Conditional compilation for Hardware\/OS architectures Recently, I work on introducing OpenMP to our TuriCreate codebase for performance experiments. When I read the OpenMP source code, I feel really confused about how it can detect the architecture of the host machine. It turns out that special compiler flags need to be...\n        ","pubDate":"Tue, 17 Dec 2019 09:52:25 +0000","link":"https:\/\/guihao-liang.github.io\/2019\/12\/17\/clang-compiler-arch-flag","guid":"https:\/\/guihao-liang.github.io\/2019\/12\/17\/clang-compiler-arch-flag"},{"title":"Cross Compile OpenMP for IOS","description":"\n          \n          Generate XCode project In order to use xcodebuild to build targets for IOS device, we need to provide .xcodeproj, which can be generated through configure at Turicreate root directory. Under the hood, the .xcodeproject is generated by CMake which uses XCode as the underlying generator. cd &lt;turicreate_root&gt; .\/configure --no-visualization --no-python...\n        ","pubDate":"Tue, 17 Dec 2019 00:00:00 +0000","link":"https:\/\/guihao-liang.github.io\/2019\/12\/17\/build-omp-for-ios","guid":"https:\/\/guihao-liang.github.io\/2019\/12\/17\/build-omp-for-ios"}]}}