🌐 Website Building

Problem 1 — Token expired, cannot git push

Click to reveal solution

Flush stale credential with:
git credential-osxkeychain erase
protocol=https
host=github.com

…then run hexo d and paste the new PAT.

0

Problem 2 — Search pop-up unstyled & duplicate buttons

Click to reveal solution

Root cause A (duplicate icons)
• Butterfly already injects #search-button on the right.
• A second custom <li> a#search-toggle was added in the menu.
→ Remove either trigger (keep stock one for simplicity).

Root cause B (CSS not loading)
custom-search.css rendered to public/css/ but wasn’t linked.
• The YAML key was mis-typed (inject. / smart quotes).

Fix
1. Move stylesheet to source/css/custom-search.css.
2. In themes/butterfly/_config.yml add:
inject:
  head:
    - <link rel="stylesheet" href="/css/custom-search.css">

3. hexo clean && hexo g<link> now appears in <head> → styles apply.

0

Problem 3 — Which way to load extra CSS / JS?

Click to reveal solution

Two paths in Butterfly / Hexo

  • themes/butterfly/_config.yml ► inject:
    Site-wide. Use when every page must see the file.
      • head: — CSS or critical JS (loads before paint)
      • bottom: — Non-blocking JS (loads just before </body>)
  • css: / js: lists in a page’s front-matter
    Local. Only that post/page gets the links. Ideal for page-specific widgets, diagrams, slide decks, etc.

Applied fix (Search modal skin)

# themes/butterfly/_config.yml
inject:
  head:
    - <link rel="stylesheet" href="/css/custom-search.css">

That stylesheet now loads on every page, before the modal HTML is rendered, so the search dialog inherits the new glass-morphism look.

0

Problem 4 — Give one page its own banner image

Click to reveal solution

In the markdown front-matter add:
top_img: /img/my_banner.jpg
 • Works for posts and pages.
 • Use top_img: false to hide the banner entirely.
 • Global fallbacks stay in _config.butterfly.yml.

0

Problem 5 — Re-skin the white “middle card” on one page

Click to reveal solution

Load a page-specific style-sheet (either via css: front-matter or a raw <link> tag) and paint #content-inner:

/* /css/about-bg.css — linked on /about/ only */
#content-inner{
  background:linear-gradient(135deg,#ffecd2 0%, #fcb69f 100%) !important;
}
#page{ background:transparent !important; }


Because the CSS file is loaded only here, the rule never touches other pages.

0

Problem 6 — 控制全局背景Replace the global purple backdrop only on About

Click to reveal solution

The colour comes from #body-wrap{background:#2E294E;}. Override it in the About-only CSS file:

/* in /css/about-bg.css */
#body-wrap{
  background:linear-gradient(135deg,#ffecd2 0%, #fcb69f 100%) !important;
}
#body-wrap::before{ background:none !important; } /* removes mask */


Key point: !important and equal/higher specificity are required to beat the theme’s global rule.

0

Problem 7 — 创建page子页面指令 Create /album/2025/05/ with one Hexo command

Click to reveal solution

Hexo treated every string after hexo new page as a single slug. That turned album/2025/05 into album-2025-05 and dropped the file in source/album-2025-05/index.md. Two quick ways to place the file exactly where we want are:

A. Slug + custom path
hexo new page 05 --path album/2025/05/index.md
Same result, but lets you pick a friendlier title for the page front-matter.

Key point: Hexo escapes slashes in the slug unless you explicitly tell it that “index” is part of the path or supply --path. After generating, run hexo clean && hexo g so the new page appears at /album/2025/05/.

0

🧠 Deep Learning

Problem 1 — CUDA out-of-memory during model training

GPU memory usage graph
Fig. 2 GPU utilisation spike causing OOM.
Click to reveal solution

1️⃣ Add torch.cuda.empty_cache() between epochs.
2️⃣ Use gradient accumulation (smaller mini-batches).
3️⃣ Check pin_memory ≠ True on dataloader when unnecessary.

0