MoreRSS

site iconsugar | 粥里有勺糖修改

99年,西南石油大学,热爱开源。前端,美团,阿里。运营视野修炼周刊。
请复制 RSS 到你的阅读器,或快速订阅到 :

Inoreader Feedly Follow Feedbin Local Reader

sugar | 粥里有勺糖的 RSS 预览

离开上海回家啦

2025-09-30 19:10:28

离开上海回家啦

9-25日出院啦!第一时间就买了夕发朝至的卧票回成都了。

术后身体还没恢复,不方便四处走动,不然就在上海逛逛啦😄

正好趁这段时间 + 上国庆中秋小长假养养身体 🥳。

本次待的时间比上次短,比上次术后状态好不少。


上海这边天气很好呀,待了小半个月,只遇到过几次雨。

↑ 病房窗外一直都这样 ↑

回家就连着下了几天雨 🌧,就连着家里躺了好几天。

飘窗外的树 🌳,都挂满了皂荚。

在飘窗上靠着 “冲浪” 活动活动脑子(紧邻 🛏 方便随时躺下休息休息 😋)

第三次到上海

2025-09-16 16:51:45

第三次到上海

又要待一段时间咯。

09-13 来上海复查病情又有点“新进展”,医生建议尽早入院治疗。

早治疗早康复,回家拖着也提心吊胆的,这次如果处理完,以后又是健康人了。


不过这次带了电脑💻,多个消遣方式。美中不足就是没有流畅的 WiFi(流量又要起飞了)。

没手术前,空闲时间多,能多产出一点哈哈😄(在医院里还是比较安心)

希望一切顺利吧。

大家都健健康康的!

视野修炼第125期 | nano-banana

2025-08-31 11:34:06

视野修炼第125期 | nano-banana

欢迎来到第 125 期的【视野修炼 - 技术周刊】,下面是本期的精选内容简介

近期因为身体原因,上机时间较少,码内容断断续续😋,断更了一段时间。

🔥强烈推荐

1. nano-banana

这周超火的图片编辑模型,谷歌出品的 Gemini Flash,"直接替代 PS"。

可直接上 Google Gemini Web 段体验。

下面给2个案例和提示词(来源于 X 上大佬 @ZHO_ZHO_ZHO 分享)

  1. 桌面 3D 手办
md
Use the nano-banana model to create a 1/7 scale commercialized figure of thecharacter in the illustration, in a realistic style and environment. Place the figure on a computer desk, using a circular transparent acrylic base without any text.On the computer screen, display the ZBrush modeling process of the figure. Next to the computer screen, place a BANDAI-style toy packaging box printed with the original artwork.

  1. Cos 生成
md
Generate a highly detailed photo of a girl cosplaying this illustration, at Comiket. Exactly replicate the same pose, body posture, hand gestures, facial expression, and camera framing as in the original illustration. Keep the same angle, perspective, and composition, without any deviation

大家也可以参考文章 实测谷歌Nano Banana,探索更多玩法!

2. 现代 Nodejs 开发姿势

挑一些实用的点:

  1. 使用 ESM 替代CJS

  2. 导入内置模块使用 node: 前缀以区分第三方模块 ,如 node:fs

js
import { readFile } from 'node:fs/promises';
  1. 顶层 await
js
import { readFile } from 'node:fs/promises';
const config = JSON.parse(await readFile('config.json', 'utf8'));
  1. 使用内置 fetch 替代第三方外部 HTTP 请求库
js
const response = await fetch('https://api.example.com/data');
const data = await response.json();
  1. 使用 AbortController 终止请求
js
const controller = new AbortController();

setTimeout(() => controller.abort(), 10000);

try {
  const data = await fetch('https://slow-api.com/data', {
    signal: controller.signal
  });
  console.log('Data received:', data);
} catch (error) {
  if (error.name === 'AbortError') {
    console.log('Request was cancelled');
  } else {
    console.error('Unexpected error:', error);
  }
}
  1. 内置测试模块node:test
js
// test/math.test.js
import { test, describe } from 'node:test';
import assert from 'node:assert';
import { add, multiply } from '../math.js';

describe('Math functions', () => {
  test('adds numbers correctly', () => {
    assert.strictEqual(add(2, 3), 5);
  });
});
sh
# Run all tests with built-in runner
node --test

# Watch mode for development
node --test --watch

# Coverage reporting (Node.js 20+)
node --test --experimental-test-coverage
  1. 监听自动重启和环境管理
js
{
  "name": "modern-node-app",
  "type": "module",
  "engines": {
    "node": ">=20.0.0"
  },
  "scripts": {
    "dev": "node --watch --env-file=.env app.js",
    "test": "node --test --watch",
    "start": "node app.js"
  }
}
  1. 导入映射

这个吊,之前都没了解到👍🏻,完美替代 alias

package.json 中添加 imports 字段

json
{
  "imports": {
    "#config": "./src/config/index.js",
    "#utils/*": "./src/utils/*.js",
    "#db": "./src/database/connection.js"
  }
}
js
import config from '#config';
import { logger, validator } from '#utils/common';
import db from '#db';

3. PongHub - 开源服务监控平台

基于 GitHub Action 基础能力,自动部署GitHub Pages和定时数据更新。

下面是笔者部署的自己的!

https://health.sugarat.top/

🔧开源工具&技术资讯

4. SSR 渲染 Check工具

一个简单的工具,可帮助检查目标 URL 页面,哪部分内容是服务端渲染哪部分是CSR渲染。

5. difit - Diff CLI

GitHub风格本地 Diff 工具

sh
npx difit

6. image-js - 图像处理库

支持在 Node.js 和浏览器中运行,用于调整大小、裁剪、过滤、颜色调整以及许多其他高级操作的库。

👍🏻比较高级

7. 免费HTTPS证书申请 - 90天

收藏!

8. 图片转成像素画

9. 国内SVG Logo资源

10. 各种定价页的设计参考

收藏!迟早有一天会用上。

⭐️强力推荐关注

周刊部分内容来源如下渠道,推荐大家关注。

又生病住院了

2025-07-31 11:21:21

又生病住院了

2月份夹层导致的并发症,6月复查严重了,需要手术治疗

捋一下时间线

6月29日 入院(泌尿外科)

7月14日 感染新冠(天天都呆在医院里也染上了,离大谱),到现在咳嗽没好

7月17日 手术(住进去还给我拖了半个月,手术耗材要层层审批,审批了7个工作日实在离谱,人都拖死了)

7月18日 出院(做完手术第二天就赶出院了,也没出院带药,也没输液消炎)

7月21日 开始发高烧

7月22日 感染科门诊,开了一堆检查,结果是尿路感染,急性肾损伤(当天白天几乎无尿,无尿就惨了-喝了几瓶水,报告出来立马就跑急诊安排输液消炎,打利尿剂了

7月23日 通过急诊又入院(感染科,一天输 3 次抗生素)

7月29日 出院(出院带药需要自费去外面购买,医院没有)

病情

2月夹层之后,报告就提示有左肾积水,但当时策略以保命为主,住院华西的医生说不用管这些,后面就没特别关注这个。

肾也是个 BUG 器官,当发现有相关症状的时候问题都是比较严重了

6月复查的时候发现 左肾积水(尿积肾里无法正常排出) 比较严重了(夜尿多,泡泡多),到手术指标了,就立马住院了。

入院后排查是腹部残余夹层导致血管比较粗压迫到左侧输尿管,导致输尿管狭窄

治疗

手术

治标就是放置一个输尿管支架,给撑起来,向下图这样,一年一换。

抗感染治疗

二次入院就是针对性的输抗生素,1天3瓶输了7天,就出院改口服药了。

药是真贵,自费外部购买,线下还非常难买到。

现状

身上 DeBuff 叠满了,出院诊断还有不少小毛病,需要慢慢调养(比如贫血,营养不良啥的)。

费用

连着 2 次住院自费差不多1个w。

药不能停

开了一堆药和营养品,一天药钱得花个小200¥。

后续

多休息休息调养身体,补充点营养,长点肉(本来就瘦,这次住院又瘦了7-8斤)。

视野修炼第124期 | 终端艺术字

2025-06-22 19:51:15

视野修炼第124期 | 终端艺术字

欢迎来到第 124 期的【视野修炼 - 技术周刊】,下面是本期的精选内容简介

下面开始本期内容的介绍ღ( ´・ᴗ・` )比心

🔥强烈推荐

1. figlet.js - 终端生成 ASCII 艺术字体

js
var figlet = require("figlet");

figlet("Hello World!!", function (err, data) {
  console.log(data);
});
md
  _   _      _ _        __        __         _     _ _ _
 | | | | ___| | | ___   \ \      / /__  _ __| | __| | | |
 | |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | | |
 |  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|_|
 |_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_(_|_)

还有 CLI 版本支持

收藏起来,写CLI能用上!

2. state-in-url

将状态信息存储在URL中,便于持久化当下的用户操作后的页面数据,也便于分享复现。

目前支持Next,React Router,Remix。

3. 语法高亮组件

原生的 web component,用于代码高亮。

js
import 'syntax-highlight-element';
html
<syntax-highlight lang="js">
const a = 1;
</syntax-highlight>

使用非常简单!基于 CSS 自定义高亮API实现。

🔧开源工具&技术资讯

4. log-vwer - 轻量的日志监控面板

用于监控 Node.js 应用程序日志的仪表板,实现应用自托管。

使用也比较简单,支持多种日志存储方式!(数据库,文件,内存)

js
// Import the necessary tools
const express = require('express');
const { setupLogger, viewerMiddleware } = require('log-vwer');

// Create your Express app
const app = express();
const PORT = process.env.PORT || 3000;

// This is an async function to make sure we connect to the database *before* starting the server.
async function startServer() {
    // === Part 1: Set up the logger ===
    const logger = await setupLogger({
      serviceName: 'My Awesome E-Commerce App',
      store: 'mongodb',
      mongoUrl: 'mongodb://localhost:27017/my_app_logs',
    });

    // === Part 2: Activate the dashboard ===
    // This tells your app: "When someone goes to /_logs, first check the password, then show the log dashboard."
    app.use('/_logs', myAuthMiddleware, viewerMiddleware(logger));

    // Start your server only after everything is ready
    app.listen(PORT, () => {
      logger.warn(`Server is alive on port ${PORT}. Ready to rock!`);
      console.log(`Log dashboard is live at: http://localhost:${PORT}/_logs`);
    });
}

// Run the function to start the server!
startServer();

5. 网站链接检测

可以检测网页中的外链,死链等情况。

6. 小恐龙二维码生成

Chrome 同款风格

7. 3D 拟物图标资源

8. Biome V2

宣称是首个无需依赖 TypeScript 编译器(tsc)、却仍能提供类型感知规则的 JavaScript 和 TypeScript 代码检查工具。

😛趣图

⭐️强力推荐关注

周刊部分内容来源如下渠道,推荐大家关注。

视野修炼第123期 | 你在用Node几?

2025-06-15 16:45:19

视野修炼第123期 | 你在用Node几?

欢迎来到第 123 期的【视野修炼 - 技术周刊】,下面是本期的精选内容简介

下面开始本期内容的介绍ღ( ´・ᴗ・` )比心

🔥强烈推荐

1. Node 18 早已停止支持,官方建议直接上v22

还没有升级的官方建议跳过 v20 直接使用 v22,剩余更长的生命周期,更多的新特性支持!

🤡 公司里主流还在用 Node 16,基建拉胯,XS!

2. Oxlint 1.0 发布

Oxlint 的第一个稳定版本已经发布!它的性能比 ESLint 提升了 50 到 100 倍 ,支持超过 500 条 ESLint 规则。

支持 0 配置直接启动使用。

sh
npx oxlint@latest

提供更清晰的诊断信息

尝鲜,笔者项目也准备迁一下试试

🔧开源工具&技术资讯

3. 🍊 Orange ORM

简洁的 ORM 库,支持 TypeScript 和 JavaScript,以及 CommonJS 和 ESM。

4. darkmodejs - 深色模式工具库

利用 matchMedia API 及其监听器,结合 prefers-color-scheme 媒体查询实现。

使用也超简单!

js
import darkmodejs from '@assortment/darkmodejs'

function onChange(activeTheme, themes) {
  switch (activeTheme) {
    case themes.DARK:
      console.log('darkmode enabled')
      break
    case themes.LIGHT:
      console.log('lightmode enabled')
      break
    case themes.NO_PREF:
      console.log('no preference enabled')
      break
    case themes.NO_SUPP:
      console.log('no support sorry')
      break
  }
}

darkmodejs({ onChange })

5. 逼真的颜色混合工具

6. 依赖可视化分析工具

antfu 大神的又一力作。

sh
npx node-modules-inspector

多种视图下查看依赖的情况。

📚 教程&文章

7. 速率限制交互式指南

文章介绍了 4 种常用的限流算法:令牌桶、漏水桶、固定窗口、滑动窗口。

每种算法都提供了可交互的 Demo 方便理解。

令牌桶 漏水桶

⭐️强力推荐关注