日常记录

SEO 确保 url 唯一,避免出现重复网页问题。Microsoft Remote Desktop 登录使用的账号密码问题。

SEO 相关

重复网页,用户未选定规范网页

控制台出现:此类网页未编入索引或不会显示在 Google 搜索结果中。可以通过 rel="canonical" 指明首选链接, 将属性为 rel="canonical" 的 <link> 元素添加到这些网页的 <head> 部分,要使用绝对路径,如:

html
1<link rel="canonical" href="http://www.example.com/a.html" />

Remote Desktop

远程桌面回家一直登录不上,最后发现 Username 要用 HOSTNAME\username 的形式才能登录上去。

stop connections from closing when idle

node-postgres: set idleTimeoutMillis to 0 to disable auto-disconnection of idle clients.

next.js with jotai, SSR 中使用 jotai 需要注意的东西

By default, Jotai uses an implicit global store to keep track of atom values. This is what is referred to as "provider-less" mode. This becomes an issue in SSR scenario because this global store is kept alive and is shared between multiple requests, which can lead to bugs and security risks.

To limit the lifetime of the store to the scope of one request, you need to use a Provider at the root of your app (or a subtree if you're using Jotai only for a part of your application).

jsx
1import { Provider } from 'jotai';
2
3function App({ Component, pageProps }: AppProps)  {
4  return (
5    <Provider>
6      <Component {...pageProps} />
7    </Provider>
8  )
9}

In this case:

  1. Provider will hold the state of the atoms used in its subtree instead of the global store.
  2. Provider's lifetime will be the same as the app itself, and since the app is recreated on each SSR request we essentially limit the lifetime of the store to a single request as well.

PostgreSQL 重置主键自增

sql
1--- 清空表数据,重置主键自增
2truncate table_name restart identity;

PostgreSQL 关于时间/日期的操作符

https://www.postgresql.org/docs/current/functions-datetime.html

操作符例子结果
+date '2001-09-28' + integer '7'date '2001-10-05'
+date '2001-09-28' + interval '1 hour'timestamp '2001-09-28 01:00:00'
+date '2001-09-28' + time '03:00'timestamp '2001-09-28 03:00:00'
+interval '1 day' + interval '1 hour'interval '1 day 01:00:00'
+timestamp '2001-09-28 01:00' + interval '23 hours'timestamp '2001-09-29 00:00:00'
+time '01:00' + interval '3 hours'time '04:00:00'
-- interval '23 hours'interval '-23:00:00'
-date '2001-10-01' - date '2001-09-28'integer '3' (days)
-date '2001-10-01' - integer '7'date '2001-09-24'
-date '2001-09-28' - interval '1 hour'timestamp '2001-09-27 23:00:00'
-time '05:00' - time '03:00'interval '02:00:00'
-time '05:00' - interval '2 hours'time '03:00:00'
-timestamp '2001-09-28 23:00' - interval '23 hours'timestamp '2001-09-28 00:00:00'
-interval '1 day' - interval '1 hour'interval '1 day -01:00:00'
-timestamp '2001-09-29 03:00' - timestamp '2001-09-27 12:00'interval '1 day 15:00:00'
*900 * interval '1 second'interval '00:15:00'
*21 * interval '1 day'interval '21 days'
*double precision '3.5' * interval '1 hour'interval '03:30:00'
/interval '1 hour' / double precision '1.5'interval '00:40:00'

关于安装 Xcode 卡的事情

虽然做不了什么,看看情况也好

jotai 的状态值能在 React 组件外进行设置和更新 ?

可以使用如下代码来脱离 React Hook 来更新值

js
1getDefaultStore().set(XXXAtom, xxx);