Skip to main content

· 3 min read
Xiaohai Huang
  1. How do you decide when to run useLayoutEffect?

    Ans: useLayoutEffect is a version of useEffect that fires before the browser repaints the screen.

    • Measuring layout before the browser repaints the screen.
    • Blocks the browser from repainting.
  2. The execution order of useEffect and useLayoutEffect.

    FeatureuseEffectuseLayoutEffect
    Execution TimingRuns after the render is committed to the screen. This means it runs after the browser has painted changes to the screen.Runs synchronously after all DOM mutations. This means it runs before the browser has a chance to paint, making it suitable for reading layout from the DOM and synchronously re-rendering.
    Use CasesMost side effects (data fetching, subscriptions)DOM manipulation, measuring elements, critical layout updates
    PerformanceGenerally better performance due to async natureCan impact performance if used excessively, as it blocks the browser from repainting

· 12 min read
Xiaohai Huang

Imagine you are playing your favorite game on your phone. You are enjoying the graphics, the gameplay, and the story. Suddenly, you encounter a bug that crashes the game. You check the app store for an update, but there is none. You are frustrated and disappointed.

Now imagine you are developing a game with Unity. You want to deliver the best experience to your players, but you also want to save time and money. You don't want to recompile and resubmit your entire project every time you need to fix a bug or add a feature. You want to update your game without requiring users to download a new version of the app.

How can you achieve this?

The answer is hot updating.

Hot updating is a technique that allows you to update both code and resources of your game at runtime. This means that you can fix bugs, add features, and optimize performance without affecting the user experience.

But how can you implement hot updating in Unity?

In this blog post, I will introduce you a solution that can help you perform in-game updates in Unity with minimal effort and maximum flexibility. It is based on two open source projects: HybridCLR and Addressables.

HybridCLR is a framework that allows you to write C# code that can be compiled into IL2CPP or Mono assemblies at runtime. This means that you can update your game logic without recompiling your entire project.

Addressables is a Unity package that provides an easy way to load assets by key from local or remote locations.

By combining these two tools, you can perform in-game updates in Unity with minimal effort and maximum flexibility.

In this blog post, I will show you how to use HybridCLR and Addressables to perform in-game updates in Unity, and demonstrate how this solution can improve your game development workflow and user experience.

· 2 min read
Xiaohai Huang

This documentation covers the minimum settings required to configure NGINX to proxy requests to MinIO.

Given domain storage.xiaohai-huang.net

  • Proxy requests to https://storage.xiaohai-huang.net to the MinIO S3 API server listening on http://my-minio-server:9000
  • Proxy requests to the subpath (/minio-console) of the domain https://storage.xiaohai-huang.net/minio-console to the MinIO Web Console listening on http://my-minio-server:9001
HostContainer
https://storage.xiaohai-huang.nethttp://my-minio-server:9000
https://storage.xiaohai-huang.net/minio-consolehttp://my-minio-server:9001

· 14 min read
Xiaohai Huang

This study plan is for those who want to prepare for technical interviews but are uncertain which problems they should focus on. The problems have been carefully curated so that levels 1 and 2 will guide beginner and intermediate users through problems that cover the data structures and algorithms necessary to succeed in interviews with most mid-tier companies. While level 3 provides material to help users whose targets are top-tier companies. -- LeetCode