Wednesday, May 26, 2021

Install CMake on Mac

 Could be achieved with the following steps:

  1. Download CMake dmg file from https://cmake.org/download/
  2. Install CMake with dmg file
  3. sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install
Note: Instead of install VSCode with CMake, could also consider to generate XCode project file with command "cmake -G XCode ."

Saturday, May 15, 2021

Deploy React App to Firebase

1. Install Firebase CLI
    sudo npm install -g firebase-tools

2. Login to Firebase
    firebase login

3. Initiate your project
    firebase init
    (a) Select "Hosting"
    (b) Choose "Use an existing project" (if already created)
    (c) Choose the desired project
    (d) Enter "build" for public directory
    (e) Enter "No" for single-page app
    (f) Enter "N" to avoid overwritten index.html

4. Perform "npm run build"

5. Deploy with "firebase deploy"

Note: The above command is recommended to be executed in the React project directory

Reference: https://dzone.com/articles/react-apps-firebase

Saturday, April 17, 2021

Setup Unit Test and Code Coverage for C++ in Linux

Setup Unit Test

  1. Clone Google Test repo https://github.com/google/googletest
  2. Checkout latest release tag (Optional)
  3. Install the gtest library with the following commands:
    a. mkdir build
    b. cd build
    c. cmake ..
    d. sudo make install

Setup Code Coverage

  1. Get lcov source code tar bar from http://ltp.sourceforge.net/coverage/lcov.php
  2. Extract lcov tar ball
  3. Execute  sudo make install 

Implementation

At the beginning of "CMakeLists.txt", include the "test" option to allow test running to be optional.
option(test "Build and tests." OFF) # Makes boolean 'test' available.

In addition, at the end of "CMakeLists.txt", include the following.  Add more files under "add_executable" to include more unit tests.
if (test)
    enable_testing()

    add_executable(runUnitTests
        main_test.cpp)

    target_link_libraries(runUnitTests -pthread
        gtest gtest_main
        gcov
        )

    target_compile_options(runUnitTests PRIVATE
        -std=c++11
        -Wall
        -fprofile-arcs
        -ftest-coverage
        )

    add_test(NAME unittest COMMAND runUnitTests)
endif()

The following should be included in "main_test.cpp":

#include <gtest/gtest.h>

int main(int argc, char *argv[]) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}


Running Unit Test and Generate Code Coverage Report


./runUnitTests --gtest_output="xml:gtest.xml"
gcov main_test.cpp.gcno
lcov --capture --directory . --output-file LCOVOUTPUT.info
genhtml LCOVOUTPUT.info --output-directory ./code_coverage

Friday, January 8, 2021

Enable CocoaPods on Mac M1

 

  1. Duplicate the Terminal application in the Utilities folder.
  2. Right click on the app and choose Get Info.
  3. Rename the other version of the app as you like.
  4. Check the option "open with Rosetta".
  5. Install Cocoapods with the command "sudo gem install cocoapods"
  6. Type the command line "gem install ffi" to fix the ffi bundle problem. Now you can do a "pod install" without problem.

Courtesy from https://stackoverflow.com/questions/64901180/running-cocoapods-on-apple-silicon-m1

Friday, August 7, 2020

Secure Remote Password (SRP)

https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol


1. Client sends username

2. Server gets username and sends salt and B

3. Client gets salt and B, sends A (randomized number) and M1 (calculate with salt, B, A and password, SCarol = (B − kgx)(a + ux))

4. Server verifies M1

Thursday, August 6, 2020

Wednesday, January 8, 2020

Using CocoaPods in IOS

After "pod install", open ".xcworkspace" instead of ".xcodeproj". Otherwise, the module could not be imported during compilation.