Create a New Blog Post

Create a new blog post in HUGO Create a new file hugo new posts/create-a-new-blog-post.md Add Tag and Category to the header --- date: '2025-02-25T22:21:46+11:00' draft: false title: 'Create a New Blog Post' tags: ["Hugo", "Blog","Homepage"] categories: ["Technology"] --- Edit the blog page Check the page in debugging mode hugo server hugo serve Open the page from the browser http://localhost:1313/

February 25, 2025

Terraform Link to "tfvars" File

Terraform tfvars file When a tfvars file is in a different location, you must specify it using the “-var-file” option. However, creating a symbolic link can simplify the command operation. Create a symbolic link ln -s ../common.tfvars terraform.tfvars Run a simple terraform command without option terraform plan Screenshot of the process

February 18, 2025

How to Disable Sounds in vs Code

How to disable sounds in VS Code. Open the Command Palette (Ctrl + Shift + P). Search for “Preferences: Open Settings (JSON)” and select it. Add the following line inside the JSON file: "editor.accessibilitySupport": "off",

February 18, 2025

Create ICO File From SVG File

Using GIMP Open your SVG file in “GIMP” Resize to “256x256” pixels Click “File” → “Export As”, choose “.ico” format Save the file

February 10, 2025

Setup Fleet Manager

How to Enable GUI Access via Fleet Manager Ensure SSM Agent is Installed and Running Windows EC2 instances must have the “SSM Agent” installed and running. Check the status by the powershell command Get-Service AmazonSSMAgent Attach a Role with the following policies AmazonSSMManagedInstanceCore AmazonSSMFullAccess (This is required for GUI access via Fleet Manager) How to access to EC2 via Fleet Manager Go to “Systems Manager” → “Fleet Manager” ...

February 9, 2025

Download From CloudShell

Copy certificate CloudShell Copy directory cp -r wildcard-v6 wildcard-v7 ZIP the directory zip -r wildcard-v7.zip wildcard-v7 Download from CloudShell See also: OpenSSL Server Certificate

February 9, 2025

OpenSSL (3) - Wildcard Server Certificate

Create a Wildcard Server Certificate Generate a key file (It can be one-off operation) openssl genrsa -out server/private/server.key 2048 Generate a Certificate Signing Request (CSR) openssl req -config mid-ca/mid-ca.conf -key server/private/server.key -new -sha256 -out server/csr/server.csr Sign the request (CSR) by Sub-CA openssl ca -config mid-ca/mid-ca.conf -extensions server_cert -days 3650 -notext -in server/csr/server.csr -out server/certs/server.crt Generate PFX with NO password openssl pkcs12 -inkey server/private/server.key -in server/certs/server.crt -export -out server/certs/server.pfx -passout pass: Result ...

February 9, 2025

OpenSSL (2) - Intermediate CA

Create a “Intermediate CA” certificate Generate a key file for “Intermediate CA” openssl genrsa -aes256 -out mid-ca/private/mid-ca.key 4096 Change the permission of mid-ca.key chmod 400 mid-ca/private/mid-ca.key Generate a Certificate Signing Request (CSR) openssl req -config ca/ca.conf -new -key mid-ca/private/mid-ca.key -sha256 -out mid-ca/csr/mid-ca.csr Sign the request file by Root-CA openssl ca -config ca/ca.conf -extensions v3_mid_ca -days 3650 -notext -in mid-ca/csr/mid-ca.csr -out mid-ca/certs/mid-ca.crt Change the permission of mid-ca.crt chmod 444 mid-ca/certs/mid-ca.crt Check a backup file created in newcerts dirctory ...

February 9, 2025

OpenSSL (1) - Root CA

Create a “Root CA” certificate Generate a key file for “Root CA” openssl genrsa –aes256 -out ca/private/ca.key 4096 Change the permission of ca.key chmod 400 ca/private/ca.key Check the content of ca.key openssl rsa -noout -text -in ca/private/ca.key Generate a certificate file for “Root CA” openssl req -config ca/ca.conf -key ca/private/ca.key -new -x509 -days 3650 -sha256 -extensions v3_ca -out ca/certs/ca.crt Change the permission of ca.crt chmod 444 ca/certs/ca.crt Check the contents of ca.crt openssl x509 -noout -text -in ca/certs/ca.crt

February 9, 2025

Deadlock Issue in SQL Serever

What is a Deadlock? A deadlock in SQL Server occurs when two or more processes hold locks on resources and each process is waiting for the other to release its lock, causing a cycle where none can proceed. Why Does It Occur? Deadlocks typically hapen due to: Concurrent Transactions: Multiple transactions access the same resources in a conflicting order. Locking Order: Processes acquire locks in different sequences, leading to circular wait conditions. Long-Running Transactions: Holding locks for an extended period increases the chance of conflicts. Insufficient Indexing: Poor indexing leads to table scans, increasing lock contention. Blocking Issues: Heavy blocking can escalate to deadlocks if multiple processes wait indefinitely. How Poor Maintenance Can Lead to Deadlocks Fragmented Indexes & Performance Degradation If the database has grown significantly and indexes haven’t been maintained (i.e., no reindexing or rebuilding), queries will take longer to execute. Longer query execution times mean locks are held for extended periods, increasing the chances of deadlocks. Full Logging & Large Transaction Logs If transaction logs are continuously growing without proper backups or truncation, SQL Server might struggle with log management, leading to slower transaction processing. Slow transactions hold locks for longer, making deadlocks more likely. Mass Deletes Without Reindexing Deleting a large number of records without reindexing can leave fragmented pages and inefficient query plans. The database engine might perform table scans instead of index seeks, leading to increased lock contention. Query Plan Changes (Due to Increased Data Size) As the database grows, SQL Server might generate different execution plans that were not optimized for the current data size. This can lead to more locking and blocking, increasing the chance of deadlocks. Demo - Create a test table 1. Create a Large Table & Insert Sample Data USE master; GO CREATE DATABASE ConflictTestDB; GO USE ConflictTestDB; GO CREATE TABLE Orders ( OrderID INT IDENTITY(1,1) PRIMARY KEY, CustomerID INT, OrderDate DATETIME DEFAULT GETDATE(), OrderAmount DECIMAL(10,2), Status VARCHAR(20) ); GO -- Insert ~1 Million Rows SET NOCOUNT ON; DECLARE @i INT = 1; BEGIN TRAN WHILE @i <= 1000000 BEGIN INSERT INTO Orders (CustomerID, OrderAmount, Status) VALUES (ABS(CHECKSUM(NEWID())) % 1000, RAND() * 1000, 'Pending'); SET @i = @i + 1; END COMMIT TRAN; GO 2. Create Index Fragmentation (Without Reindexing) -- Delete a large number of records randomly to cause index fragmentation DELETE FROM Orders WHERE OrderID % 10 = 0; GO -- Fill gaps with new inserts (in random order) SET NOCOUNT ON; DECLARE @i INT = 1; BEGIN TRAN WHILE @i <= 100000 BEGIN INSERT INTO Orders (CustomerID, OrderAmount, Status) VALUES (ABS(CHECKSUM(NEWID())) % 1000, RAND() * 1000, 'Pending'); SET @i = @i + 1; END COMMIT TRAN; GO 3. Check Fragmentation for All Indexes on [Orders] Table SELECT index_id, index_type_desc, avg_fragmentation_in_percent, avg_page_space_used_in_percent, page_count FROM sys.dm_db_index_physical_stats(DB_ID(), OBJECT_ID('Orders'), NULL, NULL, 'LIMITED'); avg_fragmentation_in_percent → Shows fragmentation level: ...

February 9, 2025