feat: fix code highlighting and upgrade dependencies

- Fix markdown-it-highlightjs configuration for Hexo 7.0+
- Create custom highlight.js instance to handle unknown languages gracefully
- Eliminate 'Could not find language' warning messages
- Upgrade ESLint to v9 with flat config format
- Update Fuse.js from 6.4.6 to 7.1.0
- Update multiple dependencies to latest versions

Technical changes:
- Set syntax_highlighter to empty in _config.yml
- Add langPrefix: 'hljs language-' configuration
- Migrate ESLint to eslint.config.js (flat config)
- Update Service Worker for new Fuse.js version
This commit is contained in:
Fechin committed 2025-06-18 22:47:16 +08:00
1 parent 3b60a4c9fa
commit 8fd81decca
18 files changed
+756 -769

No files matched your search

+27 -3
View File
@@ -137,12 +137,15 @@ Roleplay
[verb] [task] [specifics]
#### 5W1H Questions
Who
- Who is X?
- Who is [involved | affected | responsible] for X?
- Who should I contact for help with X?
What
- [What is | define | explain | describe] X?
- What does X do?
- What did [entity | text] mean by [quote]?
@@ -154,15 +157,18 @@ What
- What are the top 5 X?
When
- When [did | will] [entity | event] occur?
- When is X due?
- When is the best time to initiate X?
Where
- Where did [entity | event] happen?
- [Where to find X? | where to find resources about X? | suggest websites about X]
Why
- Why did [entity] choose [approach]?
- Why [did | will] [event] occur?
- Why is [approach] being implemented?
@@ -171,30 +177,36 @@ Why
- Why is it important?
How
- How to do X?
- How does X work?
- How does X do Y?
- How to measure [metric] accurately?
#### Utility
Generate And Expand Content
- Write [content type] to [entity] about [topic] should cover [aspects] ***(Content type examples: article, description, documentation, dummy data, email, resume, essay, guide, outline, program, recipe, SEO keywords, story, social media post, study plan, title, video script)***
- Write [content type] to [entity] about [topic] should cover [aspects] **_(Content type examples: article, description, documentation, dummy data, email, resume, essay, guide, outline, program, recipe, SEO keywords, story, social media post, study plan, title, video script)_**
- Generate random [names | numbers | words | ideas | X] matching [criteria]
- [Continue | expand]
- Create image of X
Summarize And Outline
- [Summarise | write key takeaways | write main points | write main lesson | highlight important info]
- [Shorten | write concise]
- Create outline
Modify And Refine Text
- [Write better | improve]
- Paraphrase
- Correct spelling, grammar, punctuation errors
- Change [narrative voice A] to [narrative voice B]
Explain And Teach
- [Explain | elaborate]
- Explain [how to do | each step of] X
- Explain what X does
@@ -203,14 +215,17 @@ Explain And Teach
- Provide [example | analogy]
Organize And Structure
- Sort X by [key] in [order] ***(Sort order examples: alphabetical, chronological, ascending, descending, lexicographical, custom)***
- Sort X by [key] in [order] **_(Sort order examples: alphabetical, chronological, ascending, descending, lexicographical, custom)_**
- Categorize
Plan And Strategize
- Plan [strategy for | goals and steps to achieve | milestones for | roadmap for] X
- Create [schedule | timeline] for X
Recommend And Advise
- Recommend [media type] [on | similar to] [topic]
- Recommend [gift ideas | thing] for [entity | occasion]
- Recommend improvements
@@ -218,15 +233,17 @@ Recommend And Advise
- Give feedback on idea for X
Analyze And Compare
- Extract [themes | keywords | info] about X
- Identify [similarities | differences] between X and Y
- Analyse the [sentiment | tone] of X
- Identify gaps in X
- Evaluate [strengths and weaknesses | pros and cons] of X
- Is X [comparison operator] Y? ***(Can be abstractly expressed as a sentence like "is an apple bigger than a walnut"?)***
- Is X [comparison operator] Y? **_(Can be abstractly expressed as a sentence like "is an apple bigger than a walnut"?)_**
- Reverse engineer X
Translate And Convert
- Translate [human language A] into [human language B]
- Translate [programming language A] into [programming language B]
- Translate into emojis
@@ -234,25 +251,30 @@ Translate And Convert
- Reformat as [output format]
Filter And Choose
- Filter X where [condition]
- Exclude X where [condition]
- Choose best from [options]
- Choose [top | lowest | first | last | random] [quantity] from [options]
Real-Time Lookup And Verify
- Get up-to-date [facts | news | data] on X
- Is this true?
- Find [sources | references | citations] for X
Engagement And Trivia
- Give questions about X
Chat Memory
- What did you mean by X?
- What was said earlier about X?
- Use earlier context to do X
#### Conditional Clauses
- [Verb] [item number]
- [Verb] the [first | last | random] [quantity] of X
- [Verb] the [first | last | random] [quantity] of X where [condition]
@@ -260,6 +282,7 @@ Chat Memory
- [Verb] X where not [condition]
#### Database CRUD Operations
Create
- [Write content about X|suggest ideas about X|suggest titles about X]
@@ -375,6 +398,7 @@ Presentation
- Check list
Code
- Code
Process
+5 -22
View File
@@ -1,7 +1,7 @@
---
title: FastAPI
date: 2025-06-07 18:40:00
background: bg-[#059669]
title: FastAPI
date: 2025-06-07 18:40:00
background: bg-[#059669]
tags:
- web
- python
@@ -40,8 +40,6 @@ def root():
uvicorn main:app --reload
```
## Routing & Parameters {.cols-3}
### Path Parameter
@@ -68,8 +66,6 @@ def filter_data(limit: int = 10, active: bool = True):
return {"limit": limit, "active": active}
```
## Request Body & Validation {.cols-3}
### Using Pydantic
@@ -98,8 +94,6 @@ def create(item: Item):
return item
```
## Forms, Files, Headers {.cols-3}
### Form Input
@@ -132,8 +126,6 @@ def info(ua: str = Header(None)):
return {"UA": ua}
```
## Middleware & Dependency {.cols-2}
### Middleware
@@ -159,8 +151,6 @@ def secure(_: bool = Depends(auth)):
return {"secure": True}
```
## Errors & JSON API {.cols-2}
### HTTP Error
@@ -183,8 +173,6 @@ def get_data():
return {"status": "ok"}
```
## Templates & Static {.cols-2}
### Mount Static
@@ -201,8 +189,6 @@ from fastapi.templating import Jinja2Templates
templates = Jinja2Templates("templates")
```
## Routers & Structure {.cols-2}
### Routers (Blueprints)
@@ -230,14 +216,12 @@ project/
└── models/
```
## Docs & Status {.cols-2}
### Built-in Docs
* Swagger: `/docs`
* ReDoc: `/redoc`
- Swagger: `/docs`
- ReDoc: `/redoc`
### Custom Status Code
@@ -248,4 +232,3 @@ from fastapi import status
def create():
return {"msg": "Created"}
```
+14 -28
View File
@@ -1,7 +1,7 @@
---
title: Flask
date: 2025-06-07 19:05:00
background: bg-[#3598db]
title: Flask
date: 2025-06-07 19:05:00
background: bg-[#3598db]
tags:
- web
- python
@@ -42,8 +42,6 @@ export FLASK_APP=app.py
flask run
```
## App Config & Environment {.cols-3}
### App Object
@@ -62,13 +60,11 @@ app.config.from_pyfile("config.py")
### Common Config Keys
| Key | Description |
| | -- |
| `DEBUG` | Enable debug mode |
| Key | Description |
| | -- |
| `DEBUG` | Enable debug mode |
| `SECRET_KEY` | For sessions/cookies |
| `ENV` | Set to 'development' |
| `ENV` | Set to 'development' |
## Routing & Methods {.cols-3}
@@ -96,8 +92,6 @@ def user(name):
return f"User: {name}"
```
## Request & Response {.cols-3}
### Request Object
@@ -112,9 +106,9 @@ def data():
### Request Attributes
* `request.args`: Query params
* `request.form`: Form data
* `request.json`: JSON body
- `request.args`: Query params
- `request.form`: Form data
- `request.json`: JSON body
### Custom Response
@@ -128,8 +122,6 @@ def custom():
return res
```
## Templates & Static {.cols-3}
### Render Template
@@ -146,17 +138,17 @@ def page():
```html
<h1>Hello {{ name }}</h1>
{% if name %}<p>Hi!</p>{% endif %}
{% if name %}
<p>Hi!</p>
{% endif %}
```
### Static Files
```html
<link href="{{ url_for('static', filename='style.css') }}">
<link href="{{ url_for('static', filename='style.css') }}" />
```
## Sessions & Cookies {.cols-2}
### Using Sessions
@@ -183,8 +175,6 @@ def cookie():
return resp
```
## JSON API & Middleware {.cols-2}
### JSON Response
@@ -210,8 +200,6 @@ def after(res):
return res
```
## Error Handling & Blueprints {.cols-2}
### Error Handling
@@ -236,8 +224,6 @@ def dash():
app.register_blueprint(admin)
```
## Project Structure {.cols-2}
### File Structure
+22 -59
View File
@@ -1,7 +1,7 @@
---
title: HTMX
date: 2025-06-07 19:30:00
background: bg-[#ff5f4d]
title: HTMX
date: 2025-06-07 19:30:00
background: bg-[#ff5f4d]
tags:
- frontend
- javascript
@@ -14,8 +14,6 @@ plugins:
- copyCode
---
## Getting Started {.cols-3}
### CDN Import
@@ -27,11 +25,7 @@ plugins:
### Basic Usage
```html
<button
hx-get="/hello"
hx-target="#result">
Say Hi
</button>
<button hx-get="/hello" hx-target="#result">Say Hi</button>
<div id="result"></div>
```
@@ -42,8 +36,6 @@ plugins:
<p>Hello from server</p>
```
## Core Attributes {.cols-3}
### `hx-get`, `hx-post`, etc.
@@ -63,28 +55,24 @@ plugins:
### `hx-trigger`
```html
<input
hx-get="/search"
<input
hx-get="/search"
hx-trigger="keyup changed delay:300ms"
hx-target="#results" />
hx-target="#results"
/>
```
## Swap & Out of Band {.cols-3}
### `hx-swap`
```html
<div
hx-get="/frag"
hx-swap="innerHTML">
</div>
<div hx-get="/frag" hx-swap="innerHTML"></div>
```
* `outerHTML`
* `innerHTML`
* `beforebegin`, `afterbegin`, etc.
- `outerHTML`
- `innerHTML`
- `beforebegin`, `afterbegin`, etc.
### `hx-swap-oob`
@@ -92,7 +80,7 @@ plugins:
<div hx-swap-oob="true" id="msg"></div>
```
*Useful for global updates from partials.*
_Useful for global updates from partials._
### Swap Modifiers
@@ -100,8 +88,6 @@ plugins:
hx-swap="outerHTML transition:true swap:1s"
```
## Forms & Events {.cols-3}
### Auto POST on Submit
@@ -118,35 +104,21 @@ hx-swap="outerHTML transition:true swap:1s"
```html
<input id="user-id" name="id" />
<button
hx-post="/update"
hx-include="#user-id">
Update
</button>
<button hx-post="/update" hx-include="#user-id">Update</button>
```
### `hx-vals`
```html
<button
hx-post="/save"
hx-vals='{"id": 42, "active": true}'>
Save
</button>
<button hx-post="/save" hx-vals='{"id": 42, "active": true}'>Save</button>
```
## Advanced Features {.cols-3}
### Loading Indicator
```html
<button
hx-get="/load"
hx-indicator="#spinner">
Load
</button>
<button hx-get="/load" hx-indicator="#spinner">Load</button>
<div id="spinner" class="htmx-indicator">Loading...</div>
```
@@ -162,23 +134,21 @@ hx-swap="outerHTML transition:true swap:1s"
<div hx-get="/time" hx-trigger="every 5s"></div>
```
## Events & Extensions {.cols-3}
### Listen to Events
```js
document.body.addEventListener('htmx:afterSwap', e => {
console.log("Swap complete");
document.body.addEventListener('htmx:afterSwap', (e) => {
console.log('Swap complete');
});
```
### Event Hooks
* `htmx:beforeRequest`
* `htmx:afterSwap`
* `htmx:responseError`
- `htmx:beforeRequest`
- `htmx:afterSwap`
- `htmx:responseError`
### Extensions
@@ -187,8 +157,6 @@ document.body.addEventListener('htmx:afterSwap', e => {
<form hx-post="/api" hx-ext="json-enc"></form>
```
## Example Use Case {.cols-2}
### Python Backend (Flask)
@@ -202,11 +170,6 @@ def hello():
### HTML Client
```html
<button
hx-get="/hello"
hx-target="#msg">
Click
</button>
<button hx-get="/hello" hx-target="#msg">Click</button>
<div id="msg"></div>
```
+14 -16
View File
@@ -1,13 +1,13 @@
---
title: "Matplotlib"
title: 'Matplotlib'
date: 06-06-2025
background: bg-[#1a073e]
tags:
- "data visualization"
- "matplotlib"
- "plotting"
- 'data visualization'
- 'matplotlib'
- 'plotting'
categories:
- "Python"
- 'Python'
intro: |
[Matplotlib](https://matplotlib.org/) is a comprehensive library for creating static, animated, and interactive plots in Python.
This cheat sheet provides a quick reference from basic to advanced usage, covering essential features for data science, machine learning, and scientific computing.
@@ -15,10 +15,9 @@ plugins:
- copyCode
---
---
## Getting Started {.cols-2}
## Getting Started {.cols-2}
### Importing
@@ -38,7 +37,7 @@ plt.show() # Display the plot
---
## Plot Types {.cols-2}
## Plot Types {.cols-2}
### Line Plot
@@ -98,7 +97,7 @@ plt.show()
---
## Customization {.row-span-2}
## Customization {.row-span-2}
| Feature | Code Example | Description |
| --------------- | ------------------------------------------------------------------------------------ | ------------------------------------------- |
@@ -117,7 +116,7 @@ plt.show()
---
## Subplots & Layouts
## Subplots & Layouts
### Multiple Subplots
@@ -139,7 +138,7 @@ plt.figure(figsize=(10, 5)) # Set figure size (width, height in inches)
---
## Advanced Visualizations {.cols-2}
## Advanced Visualizations {.cols-2}
### Heatmap
@@ -174,7 +173,7 @@ plt.show()
---
## Working with Images
## Working with Images
```python
import matplotlib.image as mpimg
@@ -233,7 +232,7 @@ plt.show()
---
## Saving Plots
## Saving Plots
```python
plt.savefig("figure.png", dpi=300, bbox_inches='tight') # Save plot to file
@@ -241,7 +240,7 @@ plt.savefig("figure.png", dpi=300, bbox_inches='tight') # Save plot to file
---
## Show & Clear
## Show & Clear
```python
plt.show() # Show plot window
@@ -251,7 +250,7 @@ plt.close() # Close figure window (useful in scripts or GUI apps)
---
## More Useful Functions
## More Useful Functions
| Function | Use Case |
| ------------------------------ | ------------------------------- |
@@ -265,4 +264,3 @@ plt.close() # Close figure window (useful in scripts or GUI apps)
| `plt.gcf()` | Get current figure |
---
+20 -29
View File
@@ -957,8 +957,9 @@ else:
Also see: [Python Tips](https://book.pythontips.com/en/latest/for_-_else.html)
### Over Dictionary
````python
### Over Dictionary
```python
johndict = {
"firstname": "John",
"lastname": "Doe",
@@ -968,18 +969,17 @@ johndict = {
x = johndict.items()
print(x)
# Output: dict_items([('firstname', 'John'),
# Output: dict_items([('firstname', 'John'),
# ('lastname', 'Doe'),
# ('age', 30)])
for key, value in johndict.items():
print(f"{key} : : {value}")
print(f"{key} : : {value}")
# Output: firstname : : John
# Output: lastname : : Doe
# Output: age : : 30
````
```
## Python Comprehensions
@@ -993,7 +993,7 @@ newlist = [x for x in languages if "l" not in x]
print(newlist) #Output : [ 'go', 'rust', 'javascript', 'python']
# List comprehension avoid this :
# List comprehension avoid this :
oldlist = []
for x in languages:
if "l" not in x:
@@ -1016,10 +1016,10 @@ print(language_dict)
# 'javascript': True, 'python': True}
# Dictionary comprehension avoid this :
# Dictionary comprehension avoid this :
language_dict2 = {}
for e in languages:
if "l" not in e:
language_dict2[e] = True
@@ -1031,8 +1031,6 @@ print(language_dict2)
# 'javascript': True, 'python': True}
```
## Python Functions
### Basic
@@ -1105,6 +1103,7 @@ add(5, 20) # => 25
# => 5
(lambda x, y: x ** 2 + y ** 2)(2, 1)
```
### @decorator {.col-span-2}
```python
@@ -1120,13 +1119,14 @@ def handle_errors(func):
return print(f"Error : {e}")
return wrapper
# Decorate function or method
# Decorate function or method
@handle_errors
def divide(a, b):
return a / b
divide(10, 0) # Output : Error : division by zero
```
## Python Modules
### Import modules
@@ -1395,8 +1395,7 @@ print(Yoki.legs) # => 4
Yoki.sound() # => Woof!
```
### @staticmethod {.col-span-2}
### @staticmethod {.col-span-2}
```python
class MyClass:
@@ -1640,24 +1639,20 @@ while (data := values[i]):
# Expected result: 1, "text", True
```
## Date & Time Handling
## Date & Time Handling
### Current date and time
```python
import datetime
now = datetime.datetime.now()
print(now) # e.g., 2024-04-27 14:35:22.123456
```
### Creating specific date/time objects
### Creating specific date/time objects
```python
import datetime
@@ -1673,11 +1668,9 @@ print(t) # 15:30:45
dt = datetime.datetime(2024, 4, 27, 15, 30, 45)
print(dt) # 2024-04-27 15:30:45
```
### Converting between date formats
### Converting between date formats
```python
import datetime
@@ -1690,11 +1683,10 @@ print(dt_obj) # 2024-04-27 14:00:00
formatted_str = dt_obj.strftime("%d/%m/%Y %H:%M")
print(formatted_str) # 27/04/2024 14:00
```
### Timestamps and Unix time
```python
```python
import datetime
# Get current timestamp
@@ -1704,11 +1696,11 @@ print(timestamp) # e.g., 1714188922.123456
# Convert timestamp back to datetime
dt_from_timestamp = datetime.datetime.fromtimestamp(timestamp)
print(dt_from_timestamp)
```
```
### Date difference and timedelta {.col-span-2}
```python
```python
import datetime
date1 = datetime.date(2024, 4, 27)
@@ -1722,7 +1714,6 @@ new_date = date1 + datetime.timedelta(days=10)
print(new_date) # 2024-05-07
```
## Miscellaneous
### Comments
@@ -1781,7 +1772,7 @@ finally: # Execute under all circumstances
print("We can clean up resources here")
```
### Dispatcher Pattern {.col-span-3}
### Dispatcher Pattern {.col-span-3}
```python
# Dispatcher allows dynamic selection and execution of functions based on user input or other runtime conditions
+13 -14
View File
@@ -249,26 +249,25 @@ $ ssh-keygen -R <ip/hostname>
- PEM
- PKCS8
## SSH Tunneling
## SSH Tunneling
### SSH Tunnel Options {.row-span-2}
| Option | Description |
|--------|:--------------------------------------------------------|
| `-L` | Local port forwarding |
| `-R` | Remote port forwarding |
| `-D` | Dynamic port forwarding |
| `-f` | Run in background |
| `-N` | Do not execute a remote command |
| `-g` | Allow remote hosts to connect to local forwarded ports |
| Option | Description |
| ------ | :----------------------------------------------------- |
| `-L` | Local port forwarding |
| `-R` | Remote port forwarding |
| `-D` | Dynamic port forwarding |
| `-f` | Run in background |
| `-N` | Do not execute a remote command |
| `-g` | Allow remote hosts to connect to local forwarded ports |
{.left-text}
more details on flag above with `man ssh`
### Local Port Forwarding {.col-span-2}
### Local Port Forwarding {.col-span-2}
```bash
# Forward a local port to a remote server
ssh -L local_port:remote_host:remote_port user@ssh_server
@@ -288,6 +287,7 @@ ssh -f -N -D 1080 user@ssh_server
```
### Background Tunnel {.col-span-3}
```bash
# Create a local port forwarding tunnel in the background
ssh -f -N -L local_port:remote_host:remote_port user@ssh_server
@@ -305,8 +305,7 @@ ssh -L 8080:example.com:80 -L 3306:db.example.com:3306 user@ssh_server
```bash
# In background, no command, allow remote host, local port forward, identity_file
ssh -f -N -g -L 8080:example.com:80 -i ~/.ssh/custom_key user@ssh_server
```
```
## Also see
+2 -14
View File
@@ -7,7 +7,7 @@ const STATIC_ASSETS = [
'/',
'/css/style.css',
'/js/main.js',
'/js/fuse_6.4.6.js',
'/js/fuse_7.1.0.js',
'/manifest.json',
'/search.json'
];
@@ -24,24 +24,20 @@ const CACHE_PATTERNS = [
// Service Worker installevent
self.addEventListener('install', (event) => {
// eslint-disable-next-line no-console
console.log('Service Worker: Installing...');
event.waitUntil(
caches
.open(STATIC_CACHE)
.then((cache) => {
// eslint-disable-next-line no-console
console.log('Service Worker: Caching static assets');
return cache.addAll(STATIC_ASSETS);
})
.then(() => {
// eslint-disable-next-line no-console
console.log('Service Worker: Static assets cached');
return self.skipWaiting();
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error('Service Worker: Cache failed', error);
})
);
@@ -49,7 +45,6 @@ self.addEventListener('install', (event) => {
// Service Worker activate event
self.addEventListener('activate', (event) => {
// eslint-disable-next-line no-console
console.log('Service Worker: Activating...');
event.waitUntil(
@@ -60,7 +55,6 @@ self.addEventListener('activate', (event) => {
cacheNames.map((cacheName) => {
// Delete old cache versions
if (cacheName !== STATIC_CACHE && cacheName !== DYNAMIC_CACHE) {
// eslint-disable-next-line no-console
console.log('Service Worker: Deleting old cache', cacheName);
return caches.delete(cacheName);
}
@@ -68,7 +62,6 @@ self.addEventListener('activate', (event) => {
);
})
.then(() => {
// eslint-disable-next-line no-console
console.log('Service Worker: Activated');
return self.clients.claim();
})
@@ -124,7 +117,6 @@ async function handleCacheRequest(request) {
// 6. Nothing available, return offline page
return createOfflineResponse(url.pathname);
} catch (error) {
// eslint-disable-next-line no-console
console.error('Service Worker: Fetch failed', error);
// Network error, try to return cache
@@ -250,7 +242,6 @@ async function doBackgroundSync() {
cache.put('/search.json', response);
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Background sync failed:', error);
}
}
@@ -291,9 +282,6 @@ self.addEventListener('notificationclick', (event) => {
event.notification.close();
if (event.action === 'explore') {
event.waitUntil(
// eslint-disable-next-line no-undef
clients.openWindow('/')
);
event.waitUntil(clients.openWindow('/'));
}
});