React homepage setup

To update my earlier blog post PUBLIC_URL in React is not dynamic , I have found a solution to it.

Outlook web add-in traps

  1. Cache of the Outlook add-in needs to be cleared before any update of it can apply
    • Reinstall the add-in
    • for /d %d in ("%LOCALAPPDATA%\Microsoft\Office\16.0\Wef\*") do @rmdir /s /q "%d"
    • del /s /f /q /a:h %LOCALAPPDATA%\Packages\Microsoft.Win32WebViewHost_cw5n1h2txyewy\AC\#!123\INetCache\*
    • rmdir /s /q %userprofile%\AppData\Local\Microsoft\Outlook\HubAppFileCache
      References:
      MS docs to clear cache
      Some ways to clear cache

Postgres SQL skills

E.g.1:

SELECT 
	TO_CHAR(DATE_TRUNC('month', TO_TIMESTAMP(epoch_sec)), 'MM/YY') AS month,
	COUNT(CASE WHEN my_val = 3 THEN 1 END) AS matched,
	COUNT(*) AS total
FROM my_tab
GROUP BY month
ORDER BY month

Postgres connection maxed out for Hikari Connection Pool

Error:

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  sorry, too many clients already

npm install failed in Azure pipeline

Error:

    #8 [4/5] RUN npm install
    #8 18.80 npm ERR! code EMFILE
    #8 18.80 npm ERR! syscall open
    #8 18.80 npm ERR! path /root/.npm/_cacache/index-v5/a0/7a/7e48bcbef3e333c0cda8208f4902ea385bb700f4d8c414525a120c4bba14
    #8 18.80 npm ERR! errno -24
    #8 18.80 npm ERR! EMFILE: too many open files, open '/root/.npm/_cacache/index-v5/a0/7a/7e48bcbef3e333c0cda8208f4902ea385bb700f4d8c414525a120c4bba14'
    #8 18.85 
    #8 18.85 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-03-24T20_54_30_709Z-debug-0.log
    #8 ERROR: process "/bin/sh -c npm install" did not complete successfully: exit code: 232

Code Signing Certificate

There’s an industry wide change of where to store the private key of a code signing certificate. Most if not all CAs have adopted and announced this change, e.g. DigiCert: https://knowledge.digicert.com/generalinformation/new-private-key-storage-requirement-for-standard-code-signing-certificates-november-2022.html

Move from MySql to PostgreSQL

Things to be changed as migrating from MySql to PostgreSQL

PUBLIC_URL in React is not dynamic

Symptom
PUBLIC_URL is a system variable defined in file .env and used by Create React App.
Once we run npm run build, this is the base URL as a static string.
It cannot be dynamically set in a configuration file at run time.
As a result, if two builds are using different PUBLIC_URL then they have to be built separately, which is bad for containerization.

solution
So far I have found no solution

MongoDB upgrade error in .NET

Upgrading MongoDB driver in .NET project causing dependent assembly error

Docker-compose port mapping

How to route network traffic from same port to different containers

Azure pipeline pitfalls

Some Azure pipeline pitfalls to be aware of

CSS table max height not working

CSS <td> max-height is not working for large text

Some hints for Azure pipeline

Below are some hints to use Azure pipeline

Serialize enums to ints with Gson

How to serialize enums to ints instead of strings with Gson?
(Below answer is from chatGPT)
By default, the Gson library serializes enums into strings. However, if you want to serialize enums into integers instead of strings, you can create a custom Gson serializer/deserializer for your enum class. Here’s an example of how you can achieve this:

Null-coalesce operator

What is the output of below? 1? 3? 5? 6?\

int? x = null;
int val = 1 + x ?? 2 + 3;
Console.WriteLine(val);

some ways to share data among React components

some ways to share data among React components
1.static data of a class

Returning null trap

Problem
In the example below, GetData_1() throws null pointer exception whereas GetData_2() returns a value. Why?

React state life cycle

React state life cycle
See the link from offical webiste:
https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/

React state pitfall

setState() may have delayed effect
This is because it is asynchronous method.
Reading this.state may get the wrong state.

React.js basics for beginners

You may want to use npx create-react-app my-app-name as a starting point.

But there still can be issues like below.

Intellij basics

Intellij intellisense does not recognize classes or methods. How to fix it?

Powershell tips

1. Find cmd parameter needs to be double quoted

Dependency injection via Unity Container

Summary:
UnityContainer is one of the libraries to implement dependency injection in C#.

GitHub Dependabot alerts on old libraries

Problem:
GitHub Dependabot alerts on old libraries, pointing out security vulnerabilities.

grep does not support UTF-16

Problem:
grep command in Linux doesn’t support UTF-16. my_image

Dependency update mechanism

Problem:

// Create an Image class with two properties, Width and Height
// Whenever Width is updated, Height should be updated in proportion
// Tips: avoid below 2 traps
// 1. Updating Width and Height triggers an infinite dead loop
// 2. The dependent update triggered incorrectly by the object initialization or copy

Async and await brief summary

Please refer to the link below:
https://saebamini.com/common-async-and-await-misconceptions/

Crash before class instantiation

Is it possible to crash in a class before its constructor runs?
Yes.
One possibility is it cannot load the libraries it’s referencing.
E.g.
my_image

If the actual log4net.dll is not under version 1.2.13.0, then the crash will happen.

Tips for beginners using Kotlin in Android Studio

Some tips for beginners developing Android apps using Kotlin in Android Studio

  1. Useful references:

Java spring-boot configuration error reflect.InaccessibleObjectException

Error message:

17:12:28.224 ERROR [com.Company.program.boot.programApplicationLauncher.main()] o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Cannot load configuration class: com.Company.program.boot.config.ApplicationConfiguration
 at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:395) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]
 ......
 at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.lang.ExceptionInInitializerError: null
 at org.springframework.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:166) ~[spring-core-4.1.6.RELEASE.jar:4.1.6.RELEASE]
 ......
 ... 17 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @43905a1d
 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354) ~[na:na]
 ......
 ... 28 common frames omitted

Code block highlight not working in Jekyll

Triple back ticks ``` used to work but no longer does now.

SQL traps - DISTINCT and IN clauses

Test your knowledge with below questions:

LINQ outer join

Some tips on how to do outer joins in LINQ

Git branching tips

Some tips of Git branching

T-SQL practical tips

Some practical tips against traps in T-SQL

LINQ compared with SQL

LINQ is better than SQL in some ways. https://www.linqpad.net/WhyLINQBeatsSQL.aspx

IEnumerable and yield usage

Below is an example of using IEnumerable and yield.

Microsoft Azure Administrator Associate

Early this month I got the Microsoft Azure Administrator Associate Certificate.
Badge as below.

SQL table joining special skill

An example of SQL table joining special skill

Microsoft Ignite Azure Admin Challenge

Microsoft Ignite Azure Admin Challenge

Ansible variable precedence

Ansible variable precedence
(Bottom has the highest precedence)

Ansible tips

Ansible tips

JavaScript basics

Demo page:
Link to demo

How to fix: chmod doesn't work in WSL

Problem:
After chmod, the permissions got lost due to being overwritten by Windows

How to install Ansible on WSL

1. Update apt

sudo apt-get update
......
Fetched 7978 kB in 1min 41s (79.3 kB/s)
Reading package lists... Done

Docker mistakes some files for folders, and folders for files.

1. Docker mistakes some files for folders, and folders for files.
my_image

Ubuntu Docker container missing Chinese

  1. Ubuntu Docker container doesn’t have Chinese by default.
    Solution:
    • Option 1: install Chinese manually
      ```bash #Check locale locale -a #Check installed packages dpkg -l | less

Docker basics

Commands

Docker version issues

  1. Failed to upgrade to 2.3.0.5
    ```bat Attempted to perform an unauthorized operation. at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str) at Microsoft.Win32.RegistryKey.SetValue(String name, Object value, RegistryValueKind valueKind) at CommunityInstaller.AutoStartAction.DoAsync(CancellationToken cancelToken) at CommunityInstaller.InstallWorkflow.d__34.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CommunityInstaller.InstallWorkflow.d__29.MoveNext()

GitHub connection issue

  1. GitHub may have connection error like this:
    git push -u origin master
    fatal: unable to access 'https://github.com/jasonmccb/myWSLSync.git/': Could not resolve host: github.com
    

A few tips of using WSL

Please reference the bash code example of syncing folders from one drive to another under WSL here:
https://github.com/jasonmccb/myWSLSync.git


  1. USB disk needs to be mounted MANUALLY from time to time
    sudo mkdir /mnt/e
    sudo mount -t drvfs E: /mnt/e
    sudo umount /mnt/e
    

rsync usage

  1. rsync Linux man page:
    https://linux.die.net/man/1/rsync

Setting up Qt, CMake with Visual Studio

https://blog.csdn.net/Bruce_0712/article/details/53574170

Common programming characteristics

  1. Please see the table below.

AWS cheat sheet

  1. AWS cheat sheet is a good reference for basic AWS concepts. It also has a site search function.
    https://digitalcloud.training/certification-training/aws-certified-cloud-practitioner/

GitHub tips on changing commit history

Tips

  1. Use git help <verb> to learn the Git commands.

C# Dependency Injection and Singleton

  1. Why Singleton class needs to be sealed?
    https://dotnettutorials.net/lesson/singleton-class-sealed/
    In short, internal derived class will be able to create instances.

Algolia implementation

How to install Algolia and push content?
https://community.algolia.com/jekyll-algolia/getting-started.html

Ruby on rails basics

  1. How to run Ruby program:
    ruby test.rb
    or
    irb

Replace Carriage Return and Line Feed in Notepad++

In the Notepad++ menubar click Edit -> EOL Conversion to format carriage return in entire file.
A link to guide

Review of the GitHub procedure

Summary:

Pandoc

Install Ubuntu on Windows 10

Windows 10 does support Linux subsystem.(A link to guide)
Here’s a summary of how to install Ubuntu on Win 10.

Review and clean up for the whole internship

What have been done:

Presentation has been done

What have been done:

Working on the presentation and report

What have been done:

Working on the presentation and report

What have been done:

Email confirmation is working on database

What have been done:

Company holiday

Company holiday

Public holiday

Public holiday

Confirmation link handling

What have been done:

Email ID generation and usage

What have been done:

Fixed a Thymeleaf error in getting template

What have been done:

(Shifted from Jan.31) Email file names are generated from special data

What have been done:

Fixed the null properties issues for Special import

What have been done:

Fixed Thymeleaf parsing error on single quotation mark

What have been done:

Updated email template and fixed a bug causing error to save special to DB

What have been done:

Annual leave

What have been done:

Fixed a Thymeleaf parsing exception

What have been done:

Product branding

What have been done:

Created email template using Thymeleaf

What have been done:

Added Thymeleaf in Java

What have been done:

Fixed the defects on transitioning method found by 7 test cases

What have been done:

Company holiday

Comany holiday.

Company holiday

Comany holiday.

Added more test cases for the special and email transition funtion

What have been done:

Company holiday

Comany holiday.

Corrected the workflow for emails and special transitioning

What have been done:

JUnit test for state transitioning method

What have been done:

Company holiday

Comany holiday.

Added email state transitioning method

What have been done:

Added 3 more headers in Excel spreadsheet and corresponding reading logic

What have been done:

Implemented the logic to get date cell from Excel

What have been done:

Public holiday

Public holiday.

Public holiday

Public holiday. Went tramping at Orongorongo Track, having a good time.

Public holiday

Public holiday. Happy 2020.

Annual leave

Annual leave. Happy new year.

Corrected the filtering logic

What have been done:

Added email module and related DB query methods

What have been done:

Public holiday

Public holiday. Merry Christmas.

Public holiday

Public holiday. Merry Christmas.

Public holiday

Public holiday. Merry Christmas.

Discussed and confirmed the email system logic

What have been done:

Annual leave

Annual leave.

Fixed the duplicate record bug while importing from Excel to DB

What have been done:

Fixed the bug in Excel writing

What have been done:

Studied about Mongo DB

What have been done:

Fixed MongoDB related issues

What have been done:

Annual leave

Annual leave.

UI improvements

What have been done:

Merged MongoDB branch into master

What have been done:

Fixed logging issues

What have been done:

Sick leave

Nothing has been today as I am on sick leave.

Discussion on the new architecture of the application

What have been done:

Added logger to the program

What have been done:

Reprioritization on business requirements

What have been done:

Production release, using jar instead of GitHub

What have been done:

Fixed issues related to data and format

What have been done:

Misc enhancements

What have been done:

Reading new columns for validation

What have been done:

Improved exception handling

What have been done:

Production release, excel reader enhancement

What have been done:

Enhancement, java script (continued)

What have been done:

Collect data from bars and restaurants

What have been done:

Enhancement - java script

What have been done:

enhancement, webpage and GUI

What have been done:

Tue release, fixed issues caused by configuration and input spreadsheet

What have been done:

Implemented functionalities with top priority listed in issue 14

What have been done:

Review of the week

What have been done:

Define product backlogs and priorities

What have been done:

The beer web is live in production

What have been done:

Diagnose existing problems

What have been done:

Beer web day 1

Day 1 is about setting up the environment and the tools, and also the introduction of the beer web architecture. What have been done: