All Posts

Hide Anchor Ads When Scrolling To The Bottom
Adam C. |
Google Adsense's new Anchor Ads are getting better, for it no longer shifts the layout i.e., no more Cumulative Layout Shift(CLS.) But at the same time, it removes the dismissal button, so the Ads stay on the page bottom and overlay the footer beneath. I don't find the option to turn on the dismissal (close) button, but figured out the way to fix this by using some custom Javascript.
Key is Matter in ReactJS
Adam C. |
React's key point is 'state', and 'key' attribute is special and powerful. When a key changes, React will create a new component instance rather than update the current one, so the useSate will be called in the component.
Issue of Using  router as a Dependency in  useEffect
Adam C. |
Using "router" as a Dependency is useEffect is dangerous because it could cause an infinite page re-rendering. The better to fix this is using "Router" directly imported from "next/router"
Add Last Updated Date to the NextJS website Automatically
Adam C. |
For a constantly changing information site, it's better to display the last updated date on the website so that the visitors can have a better sense of the age of the data. Here are two ways to do it with NextJS.
Use SSM to Retrieve Both Parameter Store Parameters and Secrets Manager Secrets
Adam C. |
Today, I learned that we could use @aws-sdk/client-ssm to retrieve Secrets from the secret manager as well. That is called Referencing AWS Secrets Manager secrets from Parameter Store parameters.
Fixed the VIM Background Color on Mac
Adam C. |
I set the VIM background as dark color on Mac since I set it up, but recently it's changed to white. After some investigation, I found that the color files are missing.
Enable Security on Mongo DB With Remote Access
Adam C. |
By default, MongoDB has no enabled access control, so there is no default user or password. But you can only access it via Localhost. Here is my default setup after installation.
Notes of LAMP Setup on MacOS Monterey
Adam C. |
You probably don't need another tutorial about installing LAMP on MacOS, because there are tons when you Google. This post is pretty much the notes for me, but I am happy to know if find it helpful.
Issue When Upgrading aws-amplify/ui from 2.03 to 3.10.1
Adam C. |
My client's website is using AWS Amplify to handle the user log-in via AWS Cognito. As of aws-amplify-react@4.x.x, the Authenticator is not styled, so we had installed the aws-amplify/ui 2.0.3, and then imported the style from '@aws-amplify/ui/dist/style.css'. But it stopped working after updating to V3. Here is the solution.
NextJS in Maintenance Mode
Adam C. |
Everyone hates the server is down, but it happens sometimes. It's better you have a backup plan, that you can quickly switch to, but if not, at least you need to put the site in the maintenance mode, so your visitors won't be surprised by seeing the 404 or 500 error. In this article, I would like to show you how to put on a maintenance page quickly in the NextJs application.
Disable MongoDB Fulltext Stop Words
Adam C. |
If you don't want to use Stop Words in Mongodb's Fulltext search, you need to set the default language to "none" in the index. If you already created the index, you have to drop it, and then make the new one with "default language" to be "none".
Fix Node.js Port In Use Error
Adam C. |
Sometimes the Node.js application does not close itself when you close the IDE, then when you try to start the application later, it will not start because the port is in use. It's easy to fix, but you need to remember the command to find the process and then kill it. Why not add the "kill-port" to the script in the package.json?
Responsive Semantic UI Table
Adam C. |
Semantic UI's table component is not quite mobile-friendly even with the stackable option. Actually, there is no standard way to make a stable responsive. A horizontal scrollable table is often being used, but if you like a stackable way, and with a table header as a label on each row, then in this article, I will show you how to do it using existing Semantic UI's table component with some small changes.
Some fixes of Webpack errors
Adam C. |
Webpack setup is a nightmare, at least for me. In this article, I am going to show you some webpack errors I got when I upgraded the webpack from 4 to 5, and the possible solutions to fix them.
Catch Errors in Nested Awaits
Adam C. |
TryCatch is very useful in JavaScript code to handle errors/exceptions. Without that, our code will die in the middle when there is an exception. Adding TryCatch at the top level of Await/Async may meet our need to prevent the code from interrupting in the middle, but in order for debugging the cause of the error, we would need to add the TryCatch to the nested Await/Async functions.
How to Get IANA Timezone Name from Local Datetime
Adam C. |
Surprisingly there is not a function to get a top-level US timezone. We can get a valid timezone from Intl object, but it is not a top-level, i.e., US/New-York vs US/Easten. Get a top group of US timezone is usually, for it will simplify the timezone selection dropdown. In this article, I will show how to create custom functions using raw IANA data to achieve this goal.
Semantic UI Dropdown with Remote Data
Adam C. |
In this article, I show you how I implemented the tags function using remote data. The frontend is done by the Semantic UI Dropdown component and the backend is implemented using FeathersJS with Mongodb.
CKEditor5 Classic Build DNA Updated
Adam C. |
It has been a while since I last updated my first ever NPM package: ckeditor5-build-classic-dna. Since the office CKEditor5 has been updated to version 30.0.0, I think it's good to keep ckeditor5-build-classic-dna up to date.
Create Upload API with FeathersJS
Adam C. |
"File" is a special type of data submitting to the server. It's encoded as multipart/form-data (i.e., binary data.) It does not like simple key/value pairs from text fields, which could be captured in params or data context of FeathersJS, we would need middleware to covert this to either params or data, and then be saved to the server.
Install MongoDB PHP8 Library On Ubuntu 20.08
Adam C. |
PHP's naming convention is horribly inconsistent! In this article, we learn how to install MongoDB PHP8 Library On Ubuntu 20.08.