style: format the repository with prettier
These files were already out of step with the project's Prettier config before this branch of work; running `pnpm format` finally swept them up. No semantic changes. Kept separate from the functional commits so the reformatting does not bury them in diff noise.
This commit is contained in:
50 files changed
+643
-678
No files matched your search
@@ -11,7 +11,7 @@ author:
|
||||
## When to Add Seasonings
|
||||
|
||||
| Seasoning Type | Timing | Suitable Dishes | Effect |
|
||||
|----------------------------------------|----------------------------------------|------------------------------------------------------|-------------------------------------------------------------------------------|
|
||||
| -------------------------------------- | -------------------------------------- | ---------------------------------------------------- | ----------------------------------------------------------------------------- |
|
||||
| **Salt** | Last | Leafy greens | Prevents leaves from wilting and releasing water, keeps them crisp and tender |
|
||||
| | Mid-way | Shredded potatoes, green beans, garlic shoots | Better flavour absorption |
|
||||
| **MSG, Light Soy Sauce, Oyster Sauce** | Towards the end | Dishes needing umami and aroma enhancement | Adds umami and aroma; high heat destroys freshness and fragrance |
|
||||
@@ -24,7 +24,7 @@ author:
|
||||
## Quick Reference
|
||||
|
||||
| Seasoning | Timing | Effect | Example |
|
||||
|-----------------------------------------------|------------------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------|
|
||||
| --------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------- |
|
||||
| **Salt** | 10–15 seconds before serving | Prevents premature water loss and wilting of leafy greens; keeps them crisp | Sprinkle salt and toss before turning off the heat for lettuce or spinach |
|
||||
| **Minced Garlic / Ginger** | First, after oil is hot | Releases fragrance and enhances flavour | Sauté minced garlic in hot oil, then add greens |
|
||||
| **Light Soy Sauce / Oyster Sauce** (optional) | After salt | Adds umami; use sparingly to avoid overpowering the vegetables | Add 1–2 drops of light soy sauce after salting Shanghai greens |
|
||||
|
||||
@@ -17,13 +17,13 @@ author:
|
||||
```javascript
|
||||
function processResponse(response) {
|
||||
if (response.status === 200 && response.data) {
|
||||
return { success: true, data: response.data };
|
||||
return { success: true, data: response.data }
|
||||
} else if (response.status === 404) {
|
||||
return { success: false, error: 'Not found' };
|
||||
return { success: false, error: "Not found" }
|
||||
} else if (response.status >= 500) {
|
||||
return { success: false, error: 'Server error' };
|
||||
return { success: false, error: "Server error" }
|
||||
} else {
|
||||
return { success: false, error: 'Unknown error' };
|
||||
return { success: false, error: "Unknown error" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -19,11 +19,11 @@ sound more confident and professional.
|
||||
|
||||
## Scenario Cheatsheet
|
||||
|
||||
| Scenario | ❌ Don't Use (sounds…) | ✅ Use Instead (sounds…) | Why It Works |
|
||||
|----------------------------|----------------------------------------------|-----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Scenario | ❌ Don't Use (sounds…) | ✅ Use Instead (sounds…) | Why It Works |
|
||||
| -------------------------- | -------------------------------------------- | --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Late reply | **Sorry for the delay** | **Thanks for your patience** | Swaps an apology for gratitude — the focus shifts from "I was wrong" to "you were generous," acknowledging the delay while making the recipient feel respected |
|
||||
| Scheduling | **What works best for you?** | **Could you do …?** | The former throws the decision entirely back to the other person; the latter offers a concrete option, cutting down on back-and-forth |
|
||||
| After helping someone | **No problem / No worries** | **Always happy to help** | The former implies the task *could* have been a problem; the latter signals you enjoyed it and would happily do it again |
|
||||
| After helping someone | **No problem / No worries** | **Always happy to help** | The former implies the task _could_ have been a problem; the latter signals you enjoyed it and would happily do it again |
|
||||
| Making a suggestion | **I think maybe we should …** | **It'd be best if we …** | The former oozes hesitation and self-doubt; the latter delivers a clear judgment — like someone with experience making a decision |
|
||||
| Text isn't working | **_Spending 30 minutes rewriting an email_** | **It'd be easier to discuss in person** | Recognising the medium itself is the bottleneck and switching channels can be the most efficient move |
|
||||
| Checking for understanding | **Hopefully that makes sense?** | **Let me know if you have questions** | The former betrays doubt about your own clarity; the latter calmly shares responsibility — the reader now has an action item too |
|
||||
|
||||
@@ -8,7 +8,7 @@ tags:
|
||||
---
|
||||
|
||||
> This article was originally written by **落格博客
|
||||
**: [落格博客](https://www.logcg.com/) » [Frequent Wake-from-Sleep Issues After Upgrading to macOS Monterey](https://www.logcg.com/archives/3528.html)
|
||||
> **: [落格博客](https://www.logcg.com/) » [Frequent Wake-from-Sleep Issues After Upgrading to macOS Monterey](https://www.logcg.com/archives/3528.html)
|
||||
|
||||
After upgrading to macOS Monterey, my screen kept lighting up in the middle of the night for no apparent reason. It had
|
||||
happened before, but only when notifications came in. Now the screen lights up on its own with no trigger — same
|
||||
@@ -33,8 +33,8 @@ So for Power Nap, we have to go through the command line. First, check the curre
|
||||
|
||||
Also check **`tcpkeepalive`** — it likely isn't 0 either and should also be turned off. It controls whether your Mac
|
||||
maintains TCP connections while sleeping. Run **`sudo pmset -a tcpkeepalive 0`** — you'll see a terminal warning:
|
||||
***Warning: This option disables TCP Keep Alive mechanism when system is sleeping. This will result in some critical
|
||||
features like 'Find My Mac' not to function properly.***
|
||||
**_Warning: This option disables TCP Keep Alive mechanism when system is sleeping. This will result in some critical
|
||||
features like 'Find My Mac' not to function properly._**
|
||||
|
||||
Essentially, turning it off limits some features — the system simply won't connect to the network while asleep. I'm
|
||||
fairly confident that if someone actually steals your Mac, they won't be getting it online anyway.
|
||||
@@ -10,8 +10,8 @@ author:
|
||||
email: real@zihluwang.me
|
||||
---
|
||||
|
||||
| Chinese Size Name | English Point Size (pt) | mm | px |
|
||||
|--------------------|-------------------------|-------|------|
|
||||
| Chinese Size Name | English Point Size (pt) | mm | px |
|
||||
| -------------------- | ----------------------- | ----- | ---- |
|
||||
| 初号 (Primary) | 42 | 14.82 | 56 |
|
||||
| 小初 (Small Primary) | 36 | 12.7 | 48 |
|
||||
| 一号 (No. 1) | 26 | 9.17 | 34.7 |
|
||||
|
||||
@@ -23,9 +23,9 @@ author:
|
||||
- **Axios Instance**: Create a centralised Axios instance for API calls to apply common configuration (base URL,
|
||||
headers, interceptors).
|
||||
- **Interceptors**: Use Axios interceptors to:
|
||||
- Add authentication tokens to outgoing requests.
|
||||
- Handle global error responses (e.g., display a notification for `401 Unauthorized`).
|
||||
- Log requests/responses in development environments.
|
||||
- Add authentication tokens to outgoing requests.
|
||||
- Handle global error responses (e.g., display a notification for `401 Unauthorized`).
|
||||
- Log requests/responses in development environments.
|
||||
- **Error Handling**: Centralise API error handling in Axios interceptors or custom utility functions to provide
|
||||
consistent user feedback.
|
||||
|
||||
@@ -34,14 +34,14 @@ author:
|
||||
- **Function Components & Hooks**: Prefer function components with React Hooks over class components for new
|
||||
development.
|
||||
- **Props**:
|
||||
- Define `interface` or `type` for component props to ensure type safety.
|
||||
- Destructure props at the component entry point for clarity.
|
||||
- Define `interface` or `type` for component props to ensure type safety.
|
||||
- Destructure props at the component entry point for clarity.
|
||||
- **State Management (Redux)**:
|
||||
- Use Redux Toolkit for efficient, boilerplate-reduced Redux development.
|
||||
- Use `createSlice` to organise Redux logic into "slices" (feature-specific reducers, actions, and selectors).
|
||||
- Follow the "ducks" pattern or "slices" approach to co-locate Redux logic.
|
||||
- Use Redux Toolkit for efficient, boilerplate-reduced Redux development.
|
||||
- Use `createSlice` to organise Redux logic into "slices" (feature-specific reducers, actions, and selectors).
|
||||
- Follow the "ducks" pattern or "slices" approach to co-locate Redux logic.
|
||||
- **Component Composition**: Break down complex UIs into smaller, reusable, single-responsibility components.
|
||||
- **Ant Design**:
|
||||
- Leverage Ant Design components for consistent UI/UX.
|
||||
- Use CSS-in-JS solutions to consistently customise Ant Design themes and styles across the application if needed.
|
||||
- Leverage Ant Design components for consistent UI/UX.
|
||||
- Use CSS-in-JS solutions to consistently customise Ant Design themes and styles across the application if needed.
|
||||
- **Accessibility**: Design and implement components with web accessibility (a11y) in mind from the start.
|
||||
@@ -16,7 +16,7 @@ variable in the code. Simplified Chinese sits at 84% and Traditional Chinese at
|
||||
Navigate to `/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb` and modify
|
||||
the code as follows:
|
||||
|
||||
```diff title="/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb"
|
||||
```diff title="/path/to/gitlab/embedded/service/gitlab-rails/app/helpers/preferred_language_switcher_helper.rb"
|
||||
- SWITCHER_MINIMUM_TRANSLATION_LEVEL = 90
|
||||
+ SWITCHER_MINIMUM_TRANSLATION_LEVEL = 80
|
||||
```
|
||||
|
||||
@@ -105,7 +105,7 @@ The N+1 problem occurs when JPA executes one query for the parent entity, then N
|
||||
**Fixes:**
|
||||
|
||||
| Approach | When to use |
|
||||
|--------------------------|---------------------------------------------------|
|
||||
| ------------------------ | ------------------------------------------------- |
|
||||
| `@EntityGraph` | Declarative, good for entity-specific fetch plans |
|
||||
| `JOIN FETCH` in `@Query` | Fine-grained control per query |
|
||||
| `@BatchSize` | Reduces N+1 to N/k+1 by batching |
|
||||
@@ -144,6 +144,7 @@ This happens when you access a lazily-loaded association outside the persistence
|
||||
@Query("SELECT new com.example.UserDto(u.id, u.name) FROM User u WHERE u.id = :id")
|
||||
UserDto findUserDtoById(@Param("id") long id);
|
||||
```
|
||||
|
||||
3. **`@Transactional(readOnly = true)`** on the service method — keep the session open for the entire method scope.
|
||||
|
||||
### When should I use `@Transactional(readOnly = true)`?
|
||||
@@ -275,7 +276,7 @@ Note that `@JsonAnyGetter` must be placed on the **getter method**, not the fiel
|
||||
|
||||
### How to choose
|
||||
|
||||
| Scenario | Annotation |
|
||||
|-------------------------------------------------------|--------------------|
|
||||
| Flatten nested objects with fixed fields (e.g. address, config) | `@JsonUnwrapped` |
|
||||
| Flatten dynamic key-value pairs with unknown keys | `@JsonAnyGetter` |
|
||||
| Scenario | Annotation |
|
||||
| --------------------------------------------------------------- | ---------------- |
|
||||
| Flatten nested objects with fixed fields (e.g. address, config) | `@JsonUnwrapped` |
|
||||
| Flatten dynamic key-value pairs with unknown keys | `@JsonAnyGetter` |
|
||||
@@ -98,7 +98,6 @@ author:
|
||||
## Spring Boot Best Practices & Layered Architecture
|
||||
|
||||
- **Layered Architecture (MVC with Manager Layer)**: Our backend applications follow a strict multi-layered architecture, ensuring clear separation of responsibilities and improving maintainability and testability. The layers and their responsibilities are:
|
||||
|
||||
- **Controller Layer**: Located in the `controller` package. Responsible for exposing RESTful APIs, handling HTTP requests, and mapping request parameters/bodies to service layer calls. Controllers should remain lightweight, focusing primarily on input validation (using DTOs) and coordinating calls to the `Service` layer.
|
||||
- **Service Layer**: Located in the `service` package. This layer encapsulates core business logic. Services expose a directly consumable API to the `Controller` layer, abstracting business processes and transaction management. Services coordinate calls to the `Manager` layer to execute business operations.
|
||||
- **Manager Layer**: Located in the `manager` package. This layer provides atomic business operations that can be composed by the `Service` layer. Managers typically handle more complex business logic and may involve interacting with multiple repositories or other external systems at a finer granularity.
|
||||
@@ -120,7 +119,7 @@ author:
|
||||
- Data operation conventions:
|
||||
- Use JPA for simple database operations.
|
||||
- Use MyBatis for complex database operations.
|
||||
- When performing paginated queries, page numbers should start from 0 (*compatible with Spring Data JPA*).
|
||||
- When performing paginated queries, page numbers should start from 0 (_compatible with Spring Data JPA_).
|
||||
- **Data Access Method Naming Conventions**:
|
||||
- For **querying data lists**: methods **must** start with `selectListBy`, followed by the filter criteria (e.g., `selectListByUserId`, `selectListByDepartmentIdAndStatus`). These methods must also include a `PageRequest` parameter for pagination.
|
||||
- For querying **single data records**: methods **must** start with `selectOne` (e.g., `selectOneById`, `selectOneByUsername`).
|
||||
|
||||
@@ -5,8 +5,8 @@ tags:
|
||||
- json
|
||||
- database
|
||||
author:
|
||||
name: Zihlu Wang
|
||||
email: real@zihluwang.me
|
||||
name: Zihlu Wang
|
||||
email: real@zihluwang.me
|
||||
---
|
||||
|
||||
MySQL (since version 5.7) **does not directly support a data type called `jsonb`**. `jsonb` is a data type specific to PostgreSQL, which stores JSON data in a binary format with pre-parsing for faster access and manipulation during queries.
|
||||
|
||||
@@ -26,11 +26,11 @@ https://gravatar.com/avatar/<hash>
|
||||
### Node.js
|
||||
|
||||
```js
|
||||
import { createHash } from "node:crypto";
|
||||
import { createHash } from "node:crypto"
|
||||
|
||||
const email = "user@example.com".trim().toLowerCase();
|
||||
const hash = createHash("sha256").update(email).digest("hex");
|
||||
const url = `https://gravatar.com/avatar/${hash}`;
|
||||
const email = "user@example.com".trim().toLowerCase()
|
||||
const hash = createHash("sha256").update(email).digest("hex")
|
||||
const url = `https://gravatar.com/avatar/${hash}`
|
||||
```
|
||||
|
||||
### Python
|
||||
@@ -54,7 +54,7 @@ echo -n "user@example.com" | tr '[:upper:]' '[:lower:]' | sha256sum | cut -d ' '
|
||||
The `/avatar/` endpoint accepts several query parameters to customise the result:
|
||||
|
||||
| Parameter | Description | Example |
|
||||
|-----------|-----------------------------------------|----------------|
|
||||
| --------- | --------------------------------------- | -------------- |
|
||||
| `s` | Size in pixels (default: 80) | `?s=200` |
|
||||
| `d` | Default image when no Gravatar is found | `?d=identicon` |
|
||||
| `r` | Content rating (`g`, `pg`, `r`, `x`) | `?r=g` |
|
||||
@@ -77,8 +77,7 @@ The `/avatar/` endpoint accepts several query parameters to customise the result
|
||||
src="https://gravatar.com/avatar/a3b4c5d6e7f8?s=160&d=robohash&r=g"
|
||||
alt="User avatar"
|
||||
width="160"
|
||||
height="160"
|
||||
/>
|
||||
height="160" />
|
||||
```
|
||||
|
||||
Always pass the `d` parameter to avoid broken images for users who have not set up a Gravatar. `identicon` and
|
||||
|
||||
Reference in new issue
Block a user