Monday, March 21, 2022

Vulnerability Check of Logjam Attack

 Run command "openssl s_client -connect ${SERVER}:${PORT} -cipher "EDH" | grep "Server Temp Key"" found in following article

(Note that openssl version used for testing needs to be 1.0.2 or above)

The key needs to be at least 2048 to be ok.

Saturday, October 16, 2021

Enable PWA for React App

1. Create project "npx create-react-app myapp --template cra-template-pwa"

2. Update "App.css" and "App.js" with the desired functionality implementation

3. Change "serviceWorkerRegistration.unregister()" of "index.js" to "serviceWorkerRegistration.register()"

4. Deploy the app

Sunday, October 10, 2021

Enable Running iOS Simulator with XCode on Mac M1

post_install do |installer|
 installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
 end
end

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.

Wednesday, November 27, 2019

Import SSL certication into Java Keystore

Prerequisite: "*.crt", "*.key" from CA, assume the file names are "cert.crt" and "cert.key"
Steps to be performed in Windows desktop:
  1. Rename "cert.crt" to "cert.cer" in Windows
  2. Double click "cert.cer" and "Ceritificate" popup window should be displayed
  3. Click "Certification Path" tab
  4. Double click intermediate certification, eg. "GeoTrust RSA CA 2018", another "Certificate" popup window should be displayed
  5. Click "Details" tab
  6. Click "Copy to File..." button and save the content as "intermediate.cer"
  7. Click "Certification Path" tab again"
  8. Double click root certification, eg. "DigiCert", another "Certificate" popup window should be displayed
  9. Click "Details" tab
  10. Click "Copy to File..." button and save the content as "root.cer"
  11. Concatenate "intermediate.cer" and "root.cer" into "allca.cer", eg. with command "cat intermediate.cer root.cer > allca.cer"
  12. Execute command "openssl pkcs12 -export -in cert.crt -inkey cert.key -out cert.p12 -name {aliasname} -CAfile allca.cer -caname root -chain"
  13. Append "$JAVA_HOME/bin" to "PATH" of cygwin, eg. "export PATH=$PATH:$JAVA_HOME/bin"
  14. Execute command "keytool -importkeystore -deststorepass {password} -destkeystore cert.jks -srckeystore cert.p12 -srcstoretype PKCS12 -srcstorepass {password} -alias {aliasname}"

To verify, use command "keytool -list -v -keystore cert.jks -storepass {password}".

Thursday, August 8, 2019

Terms to be checked after Python article reading

Regarding "Python is eating the world: How one developer's side project became the hottest programming language on the planet":
Global Interpreter Lock
https://realpython.com/python-gil/

Tuesday, July 2, 2019

To avoid overlapping during typing, add following lines into .bashrc

PS1='\[\e[32m\]\u@\h:\W> \[\e[0m\]'
TERM=cygwin
export PS1
export TERM

Install sshpass for cygwin

$ curl -LO http://downloads.sourceforge.net/sshpass/sshpass-1.06.tar.gz
$ md5sum sshpass-1.06.tar.gz
$ tar xvf sshpass-1.06.tar.gz
$ cd sshpass-1.06
$ ./configure
$ make
$ make install

Wednesday, June 26, 2019

Big Fat Jar Compilation

 mvn clean install -P fat-jar package shade:shade@spark-fat-jar assembly:single

Monday, May 27, 2019

Thursday, May 23, 2019