Skip to content

Instantly share code, notes, and snippets.

View daubac402's full-sized avatar
πŸ‡»πŸ‡³
πŸŽ„

NguyenTheAnh daubac402

πŸ‡»πŸ‡³
πŸŽ„
View GitHub Profile
@daubac402
daubac402 / [Vietnamese] 0.1 + 0.2 == 0.3 return FALSE.md
Last active August 28, 2025 00:23
[Vietnamese] 0.1 + 0.2 == 0.3 return FALSE?

TαΊ‘i sao 0.1 + 0.2 khΓ΄ng bαΊ±ng 0.3?

Ngắn gọn

VαΊ₯n đề nΓ y liΓͺn quan Δ‘αΊΏn cΓ‘ch mΓ  mΓ‘y tΓ­nh lΖ°u trα»― vΓ  xα»­ lΓ½ sα»‘ thα»±c (floating-point numbers). Trong nhiều ngΓ΄n ngα»― lαΊ­p trΓ¬nh, sα»‘ thα»±c được lΖ°u trα»― theo chuαΊ©n IEEE 754, vΓ  khΓ΄ng phαΊ£i tαΊ₯t cαΊ£ cΓ‘c sα»‘ thα»±c đều cΓ³ thể được biểu diα»…n chΓ­nh xΓ‘c trong hệ nhα»‹ phΓ’n. Do Δ‘Γ³, khi thα»±c hiện cΓ‘c phΓ©p toΓ‘n nhΖ° 0.1 + 0.2, kαΊΏt quαΊ£ cΓ³ thể khΓ΄ng chΓ­nh xΓ‘c nhΖ° mong đợi.

Khi nΓ o thΓ¬ mα»™t sα»‘ thα»±c khΓ΄ng được biểu diα»…n chΓ­nh xΓ‘c?

Mα»™t sα»‘ chỉ cΓ³ thể biểu diα»…n chΓ­nh xΓ‘c trong IEEE-754 nαΊΏu vΓ  chỉ nαΊΏu nΓ³ cΓ³ thể viαΊΏt dΖ°α»›i dαΊ‘ng: x = k / (2^n) vα»›i k vΓ  n lΓ  sα»‘ nguyΓͺn. NΓ³i cΓ‘ch khΓ‘c, mαΊ«u sα»‘ cα»§a sα»‘ Δ‘Γ³ chỉ cΓ³ thể chα»©a cΓ‘c thα»«a sα»‘ nguyΓͺn tα»‘ 2 (khΓ΄ng cΓ³ 3, 5, 7, ...).

@daubac402
daubac402 / Create a self-issued HTTPS certificate for your site for testing (for eg: localhost).md
Last active July 16, 2025 23:52
Create a self-issued HTTPS certificate for your site for testing (for eg: localhost)

Create a self-issued HTTPS certificate for your site for testing (for eg: localhost)

Create the certificate (Output: public key cert + private key)

brew install mkcert
 
# First time
# If you want to add to Java as well, need to go to IntelliJ > Choose your project on the left side > F4 to open Project Structure > Project > SDK > Edit > Get the PATH to setup JAVA_HOME
# Eg: Mine is: /Users/your_name/Library/Java/JavaVirtualMachines/corretto-19.0.2/Contents/Home
@daubac402
daubac402 / How to fix podman machine stuck on "Currently starting".md
Last active July 16, 2025 23:40
How to fix podman machine stuck on "Currently starting"

How to fix podman machine stuck on "Currently starting"

Credit to https://camillehdl.dev/podman-machine-stuck-currently-starting/

If podman machine list (or Podman Desktop) shows your machine β€œCurrently starting” but it never actually starts, this might help you.

Steps

Find the file ~/.config/containers/podman/machine/applehv/<your podman machine name>.json (in my case, ~/.config/containers/podman/machine/applehv/podman-machine-default.json) and edit it.

@daubac402
daubac402 / JavaPassByValueTest.java
Created May 23, 2025 03:01
Java Pass By Value Test
import java.util.*;
public class MyClass {
public static void main(String args[]) {
ArrayList<String> a = new ArrayList<>();
add1(a,"1");
System.out.println("a:" + a); // Guess the output
add2(a,"2");
@daubac402
daubac402 / Setup WDS on TpLink Archer C6.md
Last active May 22, 2025 23:44
Setup WDS on TpLink Archer C6
@daubac402
daubac402 / NextCloud in Snap in Raspberry Pi tips.md
Last active March 15, 2024 01:23
NextCloud in Snap in Raspberry Pi tips

NextCloud in Snap in Raspberry Pi tips

Installation

sudo apt-get update
sudo apt-get upgrade

sudo apt install snapd

Liquibase CLI notes

Installation

https://www.liquibase.com/download

Preparation

Download database driver (.jar file) then put it in /your_liquibase_installation_path/lib

Make Java project works with Self-signed certificate in IntelliJ

Problem

Your company is using a proxy to decrypt the HTTPS in between. It has a self-signed certificate. You will get this kind of Exception when sending a HTTPS request if your Java project doesn't have that self-signed certificate in its CaCerts

detailed message sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
@daubac402
daubac402 / make-github-copilot-works-with-self-certificate-in-IntelliJ-Windows.md
Last active September 14, 2023 07:29
Make Github copilot works with self-certificate in IntelliJ (Windows)

Make Github copilot works with self-certificate in IntelliJ (Windows)

Problem

You can't login to Github to use Github Colpilot in your IntelliJ due to you are using self-certificate.
And you got this error message

Sign in failed. Reason: Request signInInitiate failed with message: self signed certificate in certificate chain, request id: 3, error code: -32603
@daubac402
daubac402 / Git revert to a previous tag then push to origin-master.md
Created December 7, 2022 08:31
Git revert to a previous tag then push to origin:master

Git revert to a previous tag then push to origin:master

There are 2 ways to do that

Reset the HEAD then force push to remote

$ git checkout master
$ git pull
$ git reset --hard tag_ABC