TLDR: 在多次尝试 zsh之后,2023 还是回到了bash

閱讀全文 »

问题

那么多面经在说引用计数, 循环引用会无法gc,而以我对jvm python等多个有gc语言的了解,js 再怎么也不至于就是个引用计数

否则循环引用早爆了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function foo() {
var a = {};
function bar() {
console.log(a);
};
a.fn = bar;
return bar;
};

let wm1=new WeakMap();function f(){
let b={};
let a={};
a.x = a;
wm1.set(a,1);
wm1.set(b,2);
wm1.set(foo(),3);
wm1.set(wm1,4);
console.log(wm1.has(a));
console.log(wm1.has(b));
};f();console.log(wm1);

chrome performance 点垃圾桶 进行gc, 然后再执行

1
console.log(wm1);
閱讀全文 »

https://github.com/CroMarmot/ReactDemo/commits/master

Next

工具

功能 doc
Head https://github.com/CroMarmot/ReactDemo/commit/00dc0b74d4363e3be39433647a63c3fbe8a96d66
Script https://github.com/CroMarmot/ReactDemo/commit/0cb1c2aac95b276a689bb49e31f7a147d78c159e
静态生成,Link,route,404 getStaticPaths getStaticProps
global css, module css commit
static image https://github.com/CroMarmot/ReactDemo/commit/0a826c74cef03573ced89c2eb36c70a763401fba

Vercel 部署

https://vercel.com/new

Init

https://nextjs.org/learn/foundations/

1
npx create-next-app@latest --ts

React

React use Babel to compile JSX

严格模式

https://zh-hans.reactjs.org/docs/strict-mode.html

识别不安全的生命周期

关于使用过时字符串 ref API 的警告

关于使用废弃的 findDOMNode 方法的警告

检测意外的副作用

检测过时的 context API

确保可复用的状态

1
2
3
4
5
6
7
8
9
10
import React, { StrictMode } from 'react';

import ReactDOM from 'react-dom';

ReactDOM.render(
<StrictMode>
<App />
</StrictMode>,
document.getElementById('root')
);
閱讀全文 »

CORS

The server is responsible for reporting the allowed origins. The web browser is responsible for enforcing that requests are only sent from allowed domains.

Capture

1
tcpdump -i lo 'port 5000' -vv -x -X
閱讀全文 »

历史

我也是用了 spf13-vim + vundle 有七八年了, 之中还用过Pathogen 之类的

这次随着ubuntu $20\to 22$的升级, 有不少之前的插件不支持vim8,不能用了, 虽然根据官网消息,似乎vim9已经出来了

vim8 也有自带的package管理方案:h packages, 看起来需要自己用git维护, 而用vim-plug只需要维护vimrc, 而在8之上还有dein,minpac的插件管理工具

而且还有nvim和vscode+vim键位的一些解决方案

但我有点懒 宁愿多配配 也暂时没想着改习惯

本机是ubuntu, 就没管win和mac的, 其它的看各种工具的官方文档吧

閱讀全文 »

第一次被pip搞了几个小时

壮着胆子,在Ubuntu 22.10还没发布前,把系统从20.04.5升级到了22.04.1, 以我从12->14,14->16,16->18,18->20多年的经验来看, 这次竟然没问题! 厉害了, 以前每次升级都会炸点东西, 然后最终还是重装式升级, 这次竟然没啥严重的炸掉

然后pip3 install -e .出问题了

先是报没权限,但看报的路径,没往用户目录下写,在写root, 作为一个胆小的人, 向来杜绝777的

翻了半天google和github

看到一个方案:setup.py中加上

1
2
3
import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]

加完以后, 恩 是没有问题了

然后报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
running develop
/usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/home/cromarmot/Documents/computer/oiTerminalv2dev/setup.py", line 6, in <module>
setup()
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
cmd_obj.ensure_finalized()
File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
easy_install.finalize_options(self)
File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
self._fix_install_dir_for_user_site()
File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
self.select_scheme(scheme_name)
File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
scheme = INSTALL_SCHEMES[name]
KeyError: 'unix_user'
[end of output]

又搜,发现的确是setuptools有bug,然后60.0.2修复了

閱讀全文 »

写在 2022 年的 静态博客选择

调研

用了Hexo很久了,期间也有不少其它产品, 也试了试这些框架

对于我, 核心需求是markdown + code高亮 + tex + rss + 二进制分页+tags+category 支持, 操作期望是0代码, 可以简单yaml/toml配置,和复制配置的配置行为, 然后有个基本不错的theme

毕竟主要产出在markdown而不是搭建

本地方案是 obsidian/vscode/vim 就可以了

閱讀全文 »

TLDR: setuptools在2023的体验的确比不上新工具hatching

Step by Step

install build

1
pip install --upgrade build

基础使用

提供pyproject.toml文件, 包含build-system section

1
2
3
4
5
6
7
8
9
10
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "yourname-packagename"
version = "0.0.1"
dependencies = [
"requests",
]
閱讀全文 »

TS Cheat Sheet

为什么写这篇

antfu的题目 大多就是基础方法+递归, issues充斥着重复内容, 最开始还有点TS的味道, 后面完全变成了只有基础方法, 组合出一个东西, 感觉这个更适合作为递归练习题, 而不是TS练习题 (没有数值强行用数组拼接+length, 等等

TS有文档,是英文的,难以用中文检索

本篇呢,是cheatsheet,不是document,把实际会用到常用的一些列出来+一些场景描述

閱讀全文 »

带sudo的一定小心, 别选错盘了

工具推荐

bcompare

gparted

常用命令

io测试

https://linuxreviews.org/HOWTO_Test_Disk_I/O_Performance#Testing_random_4K_reads

大块读

1
fio --name TEST --eta-newline=5s --filename=temp.file --rw=read --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting

大块写

1
fio --name TEST --eta-newline=5s --filename=temp.file --rw=write --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting

随机4K读

1
fio --name TEST --eta-newline=5s --filename=temp.file --rw=randread --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=32 --runtime=60 --group_reporting
閱讀全文 »
0%