众所周知, 常用的输出有print,而调bug有logging, 用起来就是 info/debug/warning/error

但还有一些常见的问题

  • 在命令行输出一些,在日志文件输出一些,两边等级和格式不同
  • 希望日至记录 时间/文件/输出的行数/上下文
  • 直接使用的软件的logging 和 库的logging有什么不同
  • 想重定向所用的库的logging, 调整库的logging的等级是否可行
閱讀全文 »

TLDR: 实践起来能获取和播放不少的歌,但还是有大量的歌在匹配和下载中有问题,所以还是不是一个”完美”的解决方案

众所周知 服务器只是别人的电脑, 在经历,小说/电影/音乐/文字 多次不同应用里不可靠时,最终回到原点还是本地离线方案

总览

工作流: 电脑负责下载, 使用电脑-手机同步,手机离线播放

  • 安装F-Droid
  • 安装Linux/Windows/Android同步软件, 例如Syncthing, 解决 电脑和手机之间的同步
  • 通过F-Droid安装音乐播放器Retro(支持动态lrc) (有的手机系统自带的音乐播放器也能播放本地的)
閱讀全文 »

https://cppquiz.org/quiz/question/1

辅助 https://godbolt.org/ https://cppinsights.io/

C++17 标准

Undefined: 一般是不可预期的行为,可能编译器在特定的时候特定处理了, 在使用不可移植的或错误的程序结构或错误的数据时的行为,而本国际标准对此没有规定要求。编译器可以 完全无视情况,产生不可预测(运行时)的结果;在翻译或程序执行过程中,以环境所特有的记录方式行事(无论是否发出诊断信息);终止翻译或执行(发出诊断信息)。如 integeer overflow

Implementation-defined: 标准未定义,编译器需要在编译器文档中 说明如何实现的

Unspecified: 使用一个未指定的值,或其他行为,本国际标准提供了两种或更多的可能性,并对在任何情况下选择哪一种没有进一步的要求。 未指定的行为的一个例子是函数的参数被评估的顺序。

閱讀全文 »

TLDR: 有可实施性,但是作为更简单的方案是像我现在这样直接用Ubuntu

背景

众所周知,在以前,通过vim+ssh可以容易的远端开发, 并且当我的主系统一直是Ubuntu时,连vmware里,连windows的wsl2里的linux都十分容易

但现实是很多win下的程序员,和不会vim的程序员, 以及大的项目需要用一下vscode

以及手上项目各种各样,不同语言的,同语言不同版本的,不同工具依赖同样三方库的不同版本的(虽然现在不少语言的隔离有了各自的方案,而且五花八门的,这个直接从上层解决了,甚至同时帮助了系统更换)

解决了什么问题

  • 远离了windows的ntfs,使用了Unix file permissions防止777
  • 统一了环境,即使linux也是一堆环境,解决了下游环境安装难的问题,现在只需要安装docker
  • 使用了现代化vscode(可以vim插件支持vim快捷键)
  • 性能不差
閱讀全文 »

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修复了

閱讀全文 »
0%