276篇 Default中的文章

git reset password

git pull 时提示Authentication failed ,需要重置密码,执行这个即可

git config --system --unset credential.helper
More ~

macbook扩展坞连上后为什么wifi断开了

买来扩展坞连接上后,我的WiFi连接不上了!
家里的WiFI是用一台带有WiFi功能的电信光猫作为路由,发射的2.4G信号,没有5G。

折腾一番后找了些资料了解到是USB3.0发射的无线信号在2.4G HZ左右,会干扰无线路由的2.4G。

20210110115424.jpg

More ~

SSE (Server-sent events) 技术详解

SSE ( Server-sent Events )是 WebSocket 的一种轻量代替方案,使用 HTTP 协议。

严格地说,HTTP 协议是没有办法做服务器推送的,但是当服务器向客户端声明接下来要发送流信息时,客户端就会保持连接打开,SSE 使用的就是这种原理。

More ~

git记住密码

是不是每次git pull时都要输入密码?就让它记住密码吧

git config --global credential.helper store
More ~

for a-z in bash shell

for x in {a..z}
do
    echo "$x"
    mkdir -p path2/${x}
    mv path1/${x}*.ext path2/${x}
done

One line with upper case example:

for letter in {A..Z} ; do wget http://www.abc.com/Letter_${letter}_Cap.gif;done;
More ~

flask-babel 的中文翻译存放目录

有的文章里会讲中文翻译存放目录为 zh,实际上中文也分为简体和繁体,简体又分为大陆、香港、澳门,新加波。
具体可以通过 pybabel --list-locales 查到。如

b'zh              Chinese'
b'zh_Hans         Chinese (Simplified)'
b'zh_Hans_CN      Chinese (Simplified, China)'
b'zh_Hans_HK      Chinese (Simplified, Hong Kong SAR China)'
b'zh_Hans_MO      Chinese (Simplified, Macao SAR China)'
b'zh_Hans_SG      Chinese (Simplified, Singapore)'
b'zh_Hant         Chinese (Traditional)'
b'zh_Hant_HK      Chinese (Traditional, Hong Kong SAR China)'
b'zh_Hant_MO      Chinese (Traditional, Macao SAR China)'
b'zh_Hant_TW      Chinese (Traditional, Taiwan)'

所以在生成翻译 目录时,尽量使用具体的目录。如需要简体中文可以是

pybabel init -i messages.pot -d translations -l zh_Hans_CN
More ~

python利用多进制转换生成唯一ID

为了简化URL路径或是生成唯一的文章ID,在不考虑分布式情况下,想到这个思路:将时间以毫秒 转换成多进制,缩短位数。
其中可以加入随机数来减少或避免重复。多进制可以用到0-9,a-z, A-Z 这些数字,小写字母,大写字母,共计62个字符。

More ~