Skip to content

Instantly share code, notes, and snippets.

View duongphuhiep's full-sized avatar

DUONG Phu-Hiep duongphuhiep

  • lemonway.fr
  • Paris, France
View GitHub Profile
@duongphuhiep
duongphuhiep / Ky thuat HyDE.md
Last active June 22, 2026 07:33
Cách dùng AI tra cứu tài liệu

Vấn đề

Nhiều người dùng đưa cho AI 1 mớ tài liệu PDF vài trăm trang, đặt 1 câu hỏi và hi vọng nó tìm ra câu trả lời trong sách. Trừ khi gặp "phép lạ" nhờ may mắn, khả năng cao là AI làm không được, rồi bị User chửi "AI ngu thế".

Nguyên nhân

  • Vấn đề 1: Định dạng PDF dùng trong in ấn, chứa rất nhiều thông tin nhiễu loạn (Font chữ, dòng, cột hình ảnh) AI khó có thể tìm được ra nội dung cần thiết trong mớ nhiễu loạn đó. Để kiểm chứng xem AI có đọc được nội dung cuốn sách không: Hãy copy dán 1 đoạn trong sách, hỏi nó câu tiếp theo là gì?

  • Vấn đề 2: Không đủ thông tin đầu vào:

    • Câu hỏi của người dùng thường ngắn gọn chứa đựng logic hàm ý, nhưng lại thiếu "từ khoá" (keywords).
  • Người dùng thiếu kiến thức không có khả năng đặt được câu hỏi đúng, cũng không biết có từ khoá nào liên quan, chỉ biết "đại khái" thứ mình đang hỏi đâu đó trong cuốn sách này thôi.
@duongphuhiep
duongphuhiep / Claude Cowork learning session 1.md
Last active June 20, 2026 20:21
Claude Cowork learning session 1

1 - Claude Setting

Chị vào setting của Claude, copy cái instruction vào đó y như chị làm với ChatGPT. Cái instruction này sẽ được claude ghi nhớ, mỗi khi chị "Chat", hay "Cowork" với nó. (Trong App Claude có mục "Chat" và mục "CoWork" chị nhớ không?)

2 - Markdown

  • AI làm việc với file markdown giỏi hơn rất nhiều so với Word, Excel, PDF. Rất nhiều tài liệu của chị đôi khi cũng phải được convert sang Markdown để AI có thể đọc được tốt.
  • Chị cài phần mềm https://zed.dev/ là phần mềm chỉnh sửa markdown rất tốt, file markdown có đuôi là .md nhé. Tài liệu này em viết cho chị cũng dùng markdown đây.
  • Em sẽ thử convert các tài liệu sách luật của chị sang Markdown, để AI có thể khai thác được tối đa các kiến thức trong đó. (nhiều khi AI nó không đọc rõ ràng được chữ trong PDF và dễ hiểu lầm)
@duongphuhiep
duongphuhiep / Sociable Unit Test.md
Last active May 20, 2026 21:57
Solitary vs Sociable Unit Test

PART 1 - Solitary vs Sociable Unit Test (The "London School" vs. "Detroit School")

Term Scope Mocks
Unit Test (Solitary) One method / one class All direct dependencies.
Unit Test (Sociable) One feature / multiple classes Only external systems (DB/API).
Integration Test System + external No mocks (or very few).

Example: we want to unit test the PaymentService class which depends on IPaymentExecutor and IPaymentRecorder

  • IPaymentExecutor calls external PaypalApi
@duongphuhiep
duongphuhiep / 2 "tech" which might help C# dev @Lemonway.md
Last active February 10, 2026 22:09
2 "tech" which might help C# dev @lemonway
@duongphuhiep
duongphuhiep / CSharp Best Practices.md
Last active May 4, 2026 12:02
My personal experiences collected on Codes Review

0. Treat warning as error

in your .csproj

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

Do it each time you create new project before it is too late.

1. try/catch the right way

a) Don’t try/catch whenever you feel like it

@duongphuhiep
duongphuhiep / radzen-material.css
Created July 18, 2025 23:24
Radzen's Material theme complementary: supporting dark, light variant, react to prefers-color-scheme and data-theme attributes
/* Default value */
:root {
color-scheme: light;
--rz-alert-message-margin: 0.125rem 0;
--rz-alert-icon-margin: 0.125rem 0;
--rz-base: #eeeeee;
--rz-base-50: #fafafa;
--rz-base-100: #f5f5f5;
--rz-base-200: #eeeeee;
--rz-base-300: #e0e0e0;
@duongphuhiep
duongphuhiep / Registered Services in a blank .NET 9 Web API application.htm
Last active October 22, 2024 08:15
Registered Services in a blank .NET 9 Web API application
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></head><body><h1>Registered Services in a blank .NET 9 Web API application</h1><table border="1"><thead><tr><th>Counter</th><th>Abstraction Type</th><th>Lifetime</th><th>Concrete Implementation</th></tr></thead><tbody><tr><td>1</td><td>Microsoft.Extensions.Hosting.IHostingEnvironment</td><td>Singleton</td><td>Microsoft.Extensions.Hosting.Internal.HostingEnvironment</td></tr><tr><td>2</td><td>Microsoft.Extensions.Hosting.IHostEnvironment</td><td>Singleton</td><td>Microsoft.Extensions.Hosting.Internal.HostingEnvironment</td></tr><tr><td>3</td><td>Microsoft.Extensions.Hosting.HostBuilderContext</td><td>Singleton</td><td>Microsoft.Extensions.Hosting.HostBuilderContext</td></tr><tr><td>4</td><td>Microsoft.Extensions.Configuration.IConfiguration</td><td>Singleton</td><td>System.Func`2[[System.IServiceProvider, System.ComponentModel, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[Microsoft.Extensions.Configurat
@duongphuhiep
duongphuhiep / C# Codes Review.md
Last active September 22, 2025 14:39
How to Review PRs / MRs of unfamiliar C# codes base?

How to Review PRs (or MRs) of unfamiliar C# codes base?

If you have to review a Pull Request (or Merge Request) in an unfamiliar C# codebase, what should you check? Here is my checklist for reviewing a C# codebase without fully knowing what it does:

Since we don’t know much about what the code is doing, the review should focus on best practices:

  • Are there tests that cover all the changes? If not, is there a justified reason why the changes are not unit-testable? (Yes, that can happen.)
  • Challenge any unjustified try/catch blocks.
  • Challenge the use of Generics or Reflection (often a sign of over-engineering).
  • Challenge the use of Inheritance (may indicate poor design or over-engineering).
@duongphuhiep
duongphuhiep / Logging best practices.md
Last active May 15, 2026 14:08
Logging best practices

Logging best practices

When generate a log message

  • Major branching points in your code
  • When errors or unexpected values are encountered
  • Any IO operations: calling database / stored proc or make http request
  • Significant domain events
  • Request failures and retries
  • Beginning and end of time-consuming operations
@duongphuhiep
duongphuhiep / AesEncryptionHelper.cs
Created July 10, 2023 14:37
AesEncryptionHelper
using System.Security.Cryptography;
using System.Text;
namespace Lemonway.TransactionService.Application
{
public static class AesEncryptionHelper
{
public static string Encrypt(string payload, string secret)
{
byte[] iv = new byte[16];