昨天,今天,明天,每天的每天,你是否都多懂得一点点...

星期二, 七月 23, 2019

Jupyter Notebook 里面奇怪的符号 !, % 还有*都是啥意思?

! 和 %号是 IPython 的 magic commands. 其实就是在python 里面命令 shell 命令. 比如 cd, wget 这种本来应该在 bash shell 里面跑的命令, 加个 ! 就可以直接在 python 环境里面运行了.



以下这种情况里的*号是python3 里面的unpacking operator, 以下的错误是因为用了 python2 的环境. 换成 python3 来运行就正常了.

 File "go.py", line 149
    weight = tf.Variable(tf.truncated_normal([*conv_ksize, x_tensor.shape.as_list()[3], conv_num_outputs],stddev=5e-2))
                                              ^
SyntaxError: invalid syntax

错误命令 python go.py

正确命令 python3 go.py

--
Feng

星期日, 七月 14, 2019

你的LINUX VPS 虚拟机超载了吗? 全面了解Linux 的 Load Average 指标

tags: linux, load average


在Linux 下如何查看机器的负载情况呢? 除了CPU, 内存, 磁盘读写还有哪个关键指标非常值得关注呢? 跟着我来了解 Linux 负载最关键的指标  Load Average

-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-

--
Feng

星期一, 七月 08, 2019

[youtube]比上海垃圾分类还麻烦? 世界上最后一片净士 - 新西兰是如何做垃圾分类的?

tags: rubbish classification, new zealand, 上海, 垃圾分类


新西兰是个很干净的国家, 出门走一圈回来不胶鞋, 家里的地毯也不会被踩脏的. 这样一个国家的垃圾分类是怎么样的呢?  他们的垃圾又是怎么处理的?

本视频包含以下内容.

垃圾分类的好处
公用垃圾筒
家庭垃圾投放与回收
大型垃圾
如果不分类呢?
垃圾出国
禁塑令

-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



--
Feng

星期六, 七月 06, 2019

[网络技术]Mac os 使用nmap 和 arp 快速找到局域网其它设备的IP地址

因为换了路由器, 所以家里面所有设备的IP都变了。 当我要用这台MAC RDP ( 远程协助)到我的Surface book2 的时候, 发现IP设备不对了。 那要怎么快速的找到那台电脑的IP呢?

首先, 马上想到我以前发过的一篇文章里讲到的 nmap, 于是我输入了以下命令 (你需要使用 ifconfig 命令先找出ip 段, 一般是 eth1 网卡)。

[bash]
YuFengs-Mini:~ fennng$ nmap -sn 192.168.1.0/24
Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-06 12:08 NZST
Nmap scan report for router.asus.com (192.168.1.1)
Host is up (0.0069s latency).
Nmap scan report for 192.168.1.11
Host is up (0.038s latency).
Nmap scan report for android-2978145522146f5e (192.168.1.74)
Host is up (0.045s latency).
Nmap scan report for YuFengs-Mini (192.168.1.91)
Host is up (0.0013s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 3.32 seconds
[/bash]

可是结果令我惊讶, 那台PC的IP地址并没有列出来, 不知道 什么原因。但是我想到扫描过的地址都会缓存在 arp 表里, 所以,我马上又运行了 arp 命令, 果然, 找到了我要的主机 CL221 的IP, 192.168.1.204.

技多不压身呀, 多学几个命令准没错!



[bash]
YuFengs-Mini:~ fennng$ arp -a
? (169.254.8.61) at c4:9d:ed:2c:45:f on en1 [ethernet]
? (192.168.1.0) at ff:ff:ff:ff:ff:ff on en1 ifscope [ethernet]
router.asus.com (192.168.1.1) at 40:b0:76:5a:4d:4c on en1 ifscope [ethernet]
? (192.168.1.2) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.3) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.4) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.5) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.6) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.7) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.8) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.9) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.10) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.11) at 28:56:5a:2d:70:c4 on en1 ifscope [ethernet]
? (192.168.1.12) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.13) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.14) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.15) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.16) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.17) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.18) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.19) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.20) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.21) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.22) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.23) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.24) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.25) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.26) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.27) at (incomplete) on en1 ifscope [ethernet]
minde-iphone (192.168.1.28) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.29) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.30) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.31) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.32) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.33) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.34) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.35) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.36) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.37) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.38) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.39) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.40) at (incomplete) on en1 ifscope [ethernet]
galaxy-s6-edge (192.168.1.41) at ec:1f:72:21:d0:1c on en1 ifscope [ethernet]
? (192.168.1.42) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.43) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.44) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.45) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.46) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.47) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.48) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.49) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.50) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.51) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.52) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.53) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.54) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.55) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.56) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.57) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.58) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.59) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.60) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.61) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.62) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.63) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.64) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.65) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.66) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.67) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.68) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.69) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.70) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.71) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.72) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.73) at (incomplete) on en1 ifscope [ethernet]
android-2978145522146f5e (192.168.1.74) at 3c:bd:3e:28:55:88 on en1 ifscope [ethernet]
? (192.168.1.75) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.76) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.77) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.78) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.79) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.80) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.81) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.82) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.83) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.84) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.85) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.86) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.87) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.88) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.89) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.90) at (incomplete) on en1 ifscope [ethernet]
yufengs-mini (192.168.1.91) at 70:73:cb:be:55:ad on en1 ifscope permanent [ethernet]
? (192.168.1.92) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.93) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.94) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.95) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.96) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.97) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.98) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.99) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.100) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.101) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.102) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.103) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.104) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.105) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.106) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.107) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.108) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.109) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.110) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.111) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.112) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.113) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.114) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.115) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.116) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.117) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.118) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.119) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.120) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.121) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.122) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.123) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.124) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.125) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.126) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.127) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.128) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.129) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.130) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.131) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.132) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.133) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.134) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.135) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.136) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.137) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.138) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.139) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.140) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.141) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.142) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.143) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.144) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.145) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.146) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.147) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.148) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.149) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.150) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.151) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.152) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.153) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.154) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.155) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.156) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.157) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.158) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.159) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.160) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.161) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.162) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.163) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.164) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.165) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.166) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.167) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.168) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.169) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.170) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.171) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.172) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.173) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.174) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.175) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.176) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.177) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.178) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.179) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.180) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.181) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.182) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.183) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.184) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.185) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.186) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.187) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.188) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.189) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.190) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.191) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.192) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.193) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.194) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.195) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.196) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.197) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.198) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.199) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.200) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.201) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.202) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.203) at (incomplete) on en1 ifscope [ethernet]
cl221 (192.168.1.204) at c4:9d:ed:2c:45:f on en1 ifscope [ethernet]
? (192.168.1.205) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.206) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.207) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.208) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.209) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.210) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.211) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.212) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.213) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.214) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.215) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.216) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.217) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.218) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.219) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.220) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.221) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.222) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.223) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.224) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.225) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.226) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.227) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.228) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.229) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.230) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.231) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.232) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.233) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.234) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.235) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.236) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.237) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.238) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.239) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.240) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.241) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.242) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.243) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.244) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.245) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.246) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.247) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.248) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.249) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.250) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.251) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.252) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.253) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.254) at (incomplete) on en1 ifscope [ethernet]
? (192.168.1.255) at ff:ff:ff:ff:ff:ff on en1 ifscope [ethernet]
? (224.0.0.251) at 1:0:5e:0:0:fb on en1 ifscope permanent [ethernet]
? (239.255.255.250) at 1:0:5e:7f:ff:fa on en1 ifscope permanent [ethernet]
YuFengs-Mini:~ fennng$
[/bash]




--
Feng

星期四, 七月 04, 2019

在 Windows Server 上使用Powershell 一键安装 Chrome

把 Windows 2012 服务器当客户机用是非常难用的,因为安全上的设置, IE浏览器超难用。一直弹窗不说, 还不让你下载。



但是, 解决方法也是超级简单, 点开Powershell, 粘贴以下命令。

[bash]
$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$Installer
[/bash]

等两分钟, Chome 就会出现在你的任务栏上, 全自动静默安装。




--
Feng

微软 Azure 学生机 b1s 要跑 windows server 2012, 别跑2019

昨天用我的Azure 学生帐号开了一台 Windows Server 2019 Data center, 超慢。 因为只有1G内存。 因为只有b1s 是免费的, 所以不能升级内存。

于是我删了重新开了一台 2012 的 window server, 明显快多了。RDP不会无缘无故的退出。 程序响应速度也快得多。 内存占用75%。 2019的内存占用是90%. 



--
Feng

星期二, 七月 02, 2019

在 nodejs expressjs 中使用 async-lock 模块实现多线程安全代码

模块链接



昨天正式发布了用nodejs 重写的 Telegram抽奖机器人 @fengdrawbot 后, 马上在第一次被使用中就发现了一超级大BUG。

由于机器人有人数到了就会自动开奖的机制, 所以在每次有人加入抽奖的时候就会判断是否达到人数, 达到人数后就会开奖。 

当即将开奖的时候, 如果有几人同时参加抽奖, 由于是几乎同时参加的, 所以有机率同时触发抽奖代码使机器人开奖多次。

原来机器人是在Google App Script (GAS) 上运行,使用的也是GAS上面的锁 (LockService),除了慢点并没有什么问题。当我改用nodejs 后, 我使用了 async-lock 这个模块。 但是其实我在使用的过程中,代码没有使用正确,而我也没有模拟多人同时参与的情况进行测试,所以出现了一个大BUG。

上一篇博客我写了如何使用fiddler 进行BUG的复原。这一篇博客我想讲讲 async-lock 的具体用法, 官方的说明文档太简短,我当时没有完全看懂, 所以才会犯错。


async-lock 的安装和导入请直接看官方文档。 我这里给出示例代码来讲讲它的用法。

[javascript]
        // 设置一个用来锁的对像,我这里使用抽奖码来锁
        // 用抽奖码的好处是,每个抽奖都有独立的锁
        // 当有好几个抽奖同时开奖的时候,它们互不干涉
        let key = draw.joinCode;

        // 这个只是我用来测试的,标记当前的线程
        let uuid = uuidv4();
       
        // 拿锁, 只有拿到锁才能执行里面的代码
        // 没拿到锁的线程会在这里卡住,直到拿到锁为止
        lock.acquire(key, function(done) {
          // async work
          // 拿到锁后, 这个匿名函数里面的代码才会被执行
          console.log("got lock" + uuid);
          // Draw the result and modify payloads array
          let task = DrawCommon.drawResult(draw, payloads, payload5, uuid);
          task.then(r => {
            // I previous used done in a wrong place, so the lock didn't work
            console.log("release lock" + uuid);
            // 这里使用 done 这个 callback 来释放锁, 释放后,别的线程才能进来
            // 这个时候,之前的线程已经开奖完毕, 新进来的进程会重新查数据库,如果
            // 发现开奖完毕则不会做任何事, 避免了多次开奖
            // 如果没有锁的话, 所以进程一起进到这里面, 当它们查询数据库的时候发现还没有开奖,
            // 就会一起执行开奖的代码
            done("no error", "ok");
          });
          tasks.push(task);
        }, function(err, ret) {
            // lock released
        }, null);
[/javascript]


上面的这个例子是使用了传进来的done 这个callback函数来释放锁的, 如果我的开奖函数不需要返回值则使用这面的方法就可以。 但是我的 drawResult 这个函数会返回一个  promise, 而且我要反这个promise 再返回到上一级函数, 所以我需要 lock.acquire 能够返回 promise. 幸运的是  async-lock 也有 promise 模式, 看下面的例子。


[javascript]  
        // promise 模式会返回一个 promise, 在 promise 模式中, 不需要传入
        // done 这个 callback 去释放锁, 锁会自动被释放
        return lock.acquire(key, function () {
          // return value or promise
          // async work
          console.log("got lock" + uuid);
          // Draw the result and modify payloads array
          // 调用 drawResult 函数, 这个函数返回一个 promise
          // 这样 promise 里面的 payloads 可以被传到上一级函数
          return DrawCommon.drawResult(draw, payloads, payload5, uuid);
          //这里timeout 设定了多久超时, 如果5秒内拿不到锁就超时
        }, {timeout: 5000}).catch(function(err) {
          // 超时后会跑这里面的代码
            console.log(err.message); // output: error
        });


[/javascript]  


--
Feng

Use fiddler to do quick load testing

I rewrote my Telegram draw bot @fengdrawbot using nodejs express recently. Although I  used async-lock in the critical piece of code.  It didn't work well. The code draw multiple times if many people join the draw at the same time and reach the threshold number.

To debug this, I need a tool to simulate the heavy load in a short period of time. I tried Postman's runner,  it only runs the requests sequentially, which doesn't meet my purpose.

As I only need to simulate around 10 requests sent simultaneously, Fiddler fit this role very well. I used its composer to generate the request, then sent it.  The response came back correctly. I then selected the request and pressed "R" on the keyboard to resend it a few more times. Now I have around 10 same request in fiddler's history. I then selected all these 10 requests with "Shift" key + mouse. Then I pressed R to rerun all these requests simultaneously, issue reproduced.

Ok, now I have to debug and find out the problem then fix it.













--
Feng

星期六, 六月 29, 2019

[Youtube] 常用外用消炎药全解析,了解外用药的主要成分,别在乱用药啦

tags: 消炎药,外用,类固醇,甾类,氢华可的松, 氢羟肾上腺皮质素,激素皮质醇,hydrocortisone,neomycin,natamycin,Miconazole Nitrate,crotamiton,Choline salicylate,Sodium Fusidate,Fusidic acid

市 面上外用消炎药很多, 很多不同品牌的的药其实里面的主要成分是一样的,你可能换来换去,其实都是在用一样的药。这个视频教你认识几种常用的外用消炎药的主要成分,以后看到不同品牌的外用消炎药也不会晕啦,一看主要成分就了然了。


-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-

星期一, 六月 24, 2019

【一分钟进化系列】巧用Google Chrome 对PDF文件进行解密,分割, 无需任何插件

Tags: PDF分割, PDF解密


Hello 大家好, 欢迎来到峰哥分享,我是峰哥

有时候我们的PDF文件太大,我们会想把它分割成几个小的PDF文件,有的PDF文件进行了加密处理,让你无法复制甚至搜索里面的文字内容。

使用Google Chrome 的打印功能我们就能很容易的对PDF文件进行分割,分割出来的文件也是没有加密的。幸运的是, 大部分加密的PDF文件都没有禁止打印。

把PDF文件拖到Google Chrome 浏览器, 然后点打印, 选择要打印的页面, 再点 Save as PDF, 随便启个名字保存,保存下来的文件就是没有加密的PDF文件啦!如果是要分割文件的话, 只要多打印几次就好啦。

 -~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-



--
Feng

星期一, 六月 17, 2019

[Youtube]峰享列编辑神器官方使用说明 - 强大的列提取和编辑功能

taqgs: 在线编辑,列编辑,column editing, online column editing, online column editor 

这个工具写了有一年多了, 功能其实是相当的强大,可以很快的操作。 它可以把有规律的文本非常快的分割成列, 再针对列进行编辑。 也可以用它来提取文本里面的内容。 还有自动填充数字, 字母, 字符转换等功能, 是一款不可多得的列编辑神器。这个视频是它的官方说明文档。


-~-~~-~~~-~~-~-

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用KODI看电影等等. 同时我也会分享一些编程的教程, 如编写Telegram机器人, 建站等。 点击进入我的频道: goo.gl/5tyxcf

🔷 订阅我的频道: goo.gl/KuF3bY
🔷 telegram电报群: t.me/fengsharegroup
🔷 我的博客: www.dengnz.com/blog
🔷 Facebook: www.facebook.com/fengnz

觉得我的视频对你帮助很大的话, 请我喝杯咖啡吧
微信赞赏码: goo.gl/uKoE8w
-~-~~-~~~-~~-~-


--
Feng

星期六, 六月 15, 2019

[网络技术]Use mongo shell to batch update mongo db

Updated 9000 records in a few seconds.

By mistake, I log message.chat.id as LongNumber in mongodb. I need to convert them string. With mongo shell, this can be done quite easily.

First, Login to my mongo shell

[bash]
sudo docker exec -it mongo-fengdrawbot mongo --username restheart
#Enter password to login
#switch to db collection
use messages
[/bash]

Then I used this script to save the data needs to be converted in to another collection
[javascript]
db.messages.find({"message.chat.id": {"$lt": 0}}).forEach( function (x) {
    x.message.chat.id = x.message.chat.id + "";
    db.messages_bk.save(x);
});
[/javascript]

I verified the converted data with mongo express, everything looks good. then I run the following script to update the original records.

[javascript]  

db.messages.find({"message.chat.id": {"$lt": 0}}).forEach( function (x) {
    x.message.chat.id = x.message.chat.id + "";
    db.messages.save(x);
});
[/javascript]





--
Feng

星期二, 六月 11, 2019

[网络技术]Node ExpressJS - Becareful! A global variable will be shared between requests

tags: nodejs, expressjs, singleton, global variable

We all know that HTTP server is stateless, every time a request is processed, new instance of server handler will be created to serve the request. Each request is served by different handler instance, they don't share context.

This is kind of true in C#.net, JAVA and other compile language unless static class and/or variable are used.  You can create session to share the user context, that's a different thing.

But in javascript, you have to pay extra attention.

I have a telegram bot called @fengfaqbot, which is used to auto reply/handle messages matched by rules. It sometimes will send auto response to another group which doesn't have the rule setup. After tons of effort of investigation, I found that the problem is just caused by a missing let.   



This lead to the payload variable become a global variable. And in some other place, this variable is modified, so something funny can just happened.

To prove that the global variable is shared between requests.  I defined a global variable  and increased it's number every time a new request is received by expressjs. 




Then I proved it. The count doesn't get reset for each request, it keeps increasing. It tell us that node expressjs use the same V8 JavaScript runtime engine instance (thing carefully, it should). 

You have to be very careful when a new variable is introduced, don't forget to declaration word. You may use let, var or const. This article will not discuss the difference between them.

Can you use a global variable as a singleton?




--
Feng

星期一, 六月 10, 2019

在Squirrel 五笔输入法中默认使用半角标点符号(可选字符)

刚才把鼠须管的默认输入状态改成了英文, 觉得真不错。 所以我就想实现另一个我一直想要的输入法功能, 就是在中文输入法状态下输入半角的符号。因为在很多程序里面只认半角逗号, 比如说我在youtube 上输入标签的时候是用半角逗号来分的,如果是打了全角逗号, 就会连成一个很长的标签。所以每次一个一个的改逗号非常麻烦。

好吧,不得不承认,这个输入法的设置, 你不谷歌是找不到的。于是我又找到了这个文章。


其实设置也很简单, 如下图, 加入这两行就可以啦。我也不懂是啥意思, 依葫芦画瓢, 复制粘贴再改一下。 设置完后, 我在五笔的半角状态就能出半角逗号了, 原来默认的设置是无论全角还是半角设置, 在中文状态下就只出全角标点。 当然, 英文状态是会出半角标点的。 当然,英文状态切换到全角也可以输出全角英文和标点


half_shape:
    ",": {commit: ","}



设置完后,别忘了重新Deploy 生效



--
Feng

设置鼠须管输入法的默认输入状态为英文

我前两天介绍了鼠须管输入法。


这个输入法有个我一直在寻找的功能,就是可以设置默认的输入状态。我在Windows 下使用的手心输入法没有这个功能。所以我每次要打字之前都需要先按一下右SHIFT键切换到英文状态。 这边所说的英文状态并不是指英文输入法,因为大多数输入法都有英文状态,所以并不需要切换到专门的英语输入法。

而鼠须管可以很方便的把默认输入状态切换成英文,这样,我每次切换到新的应用程序的时候,默认打出的字就是英文了。因为我第一个字打英文的频率比较高一点,这个功能对我就非常有用。

当然,一如既往的,Squirrel 的设置界面可以说是没有, 要找到这个设置还要谷歌一翻。所以我找到了以下博文。


如果知道了在哪里设置,还是很简单的。首先你要找到你的输入法的设置文件,我这边是一个极点五笔的设置文件, 然后按下图把 Switches -name reset 改成 1 就可以了。
 







--
Feng

星期日, 六月 09, 2019

[Youtube] Telegram聊天软件 如何用机器人自动回复,回答常见问题, 删除脏话,踢人,禁言,警告用户等 (支持图片和动图)

tags: Telegram, bot, auto response, auto kick, auto delete, auto silent, 电报,机器人,自动回复,自动启动,自动删除,自动禁言




群主秘书:@FengFaqBot
统计秘书:@FengStatsBot

这个机器人其实写了很久了, 一直没空给它写一个教程。 这个机器人比它表面上看去要强大得多, 所以出个视频教程是非常有必要的。 


今天这个视频会演示以下几个功能:

  • 简单的匹配关键词
    • 单个关键字
      • /addrule 峰哥===>江湖上一直流传着峰哥的传说
    • 多个关键字(或关系)
      • /addrule 峰哥|||Feng===> 江湖上一直流传着峰哥的传说
    • 多个关键字 (与关系)
      • /addrule Feng&&&Deng===> 江湖上一直流传着峰哥的传说
    • 多个关键字  (混合或关系和与关系,与关系优先)
      • /addrule 峰哥|||Feng&&&Deng===> 江湖上一直流传着峰哥的传说
  • 复杂的匹配关键字 - 正则表达式
    • 匹配阿拉伯语 - 反清真发言
      • /addrule regex:[\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufbc1]|[\ufbd3-\ufd3f]|[\ufd50-\ufd8f]|[\ufd92-\ufdc7]|[\ufe70-\ufefc]|[\uFDF0-\uFDFD]===>看不懂,请去隔壁群!
      • العَرَبِيَّة  
    • 精确匹配,防误伤
      • /addrule 日===>请不要说脏话
      • 日本
      • /addrule regex:^日$===>请不要说脏话
    • 正则或关系
      • /addrule regex:峰哥|Feng|峰神===>  江湖上一直流传着峰哥的传说
    • 正则与关系
      • /addrule regex:(?=.*国外)(?=.*苹果)(?=.*ID)(?=.*返佣).*===>请不要发广告
    • 正则混合关系
      • /addrule regex:((?=.*国外)(?=.*苹果)(?=.*ID)(?=.*返佣).*)|暴利===>请不要发广告
      • 国外的朋友,有苹果ID的, 跟我合作, 返佣
      • 暴利
  • 回复图片
  • 删除
    • 删除消息
      • /addrule 卧槽===>delete
    • 删除消息并警告
      • /addrule 卧槽===>delete:请别说脏话
  • 踢人
    • 踢人
      • /addrule  卧槽===>kick
      • /addrule  卧槽===>kick~60
    • 踢人并警告
      • /addrule  卧槽===>kick:请别说脏话
  • 删完踢人
    • 删除消息并踢人
      • /addrule  卧槽===>kickdelete
    • 删除消息并踢人然后警告
      • /addrule  卧槽===>kickdelete:说脏话,已踢
  • 禁言
    • 禁言并回复
      • /addrule  卧槽===>ban~60:说脏话,你已经被禁言60秒
      • 不加时间就是永久禁言
    • 和踢人一样可以加delete
  • 查看规则
    • /listrule
    • /listrule 1
  • 删除规则
    • /remove rule 1
  • 规则匹配顺序说明
    • 机器人只会执行最先找到的规则,找到后执行,然后就忽略后面的规则了。 机器人检索规则是按倒序检索,也就是说,最后加的规则会最先找到。


--
Feng

[网络技术]两分钟用上鼠须管(macOS) 输入法

苹果自带的五笔输入法我实在是用不习惯。 因为我比较习惯用右SHIFT键切换中英文, 而苹果五笔用的是CAPS Lock键。当然不只这个。

所以今天我本来是想安装手心五笔的, 我在WINDOWS下用它, 但是当我下载的时候, 发现它在MAC OS 下只有一个2015年出的体验版 ,会不会太旧了点。 

所以我就稍微找了一下, 发现一个被称为神器的输入法 RIME。在MAC OS下, 它被称作鼠须管, 而在windows 下面, 大家叫它小狼毫。具说它的功能非常强大,但是配置及其麻烦。

根据我用VIM还有Proxomitron的经验,配置麻烦的东西总是有大神提供配置好的文件下载,所以自己根本不需要配置。这不,我马上就找到了一个配置好的五笔方案。


这个方案使用的是极点五笔86版 , 正好我以前也用过极点,而且我挺喜欢它的,用的时间还不短。而且我只会打86版五笔,不会98版 。

把这个站的文件下载下来,放在以下的目录就可以了



好了,零设置,直接可以用了。

当然,我是播了它的配置文件才发现切换到拼音输入法用的是CTRL+0。

如果要切换到英文则是使用右SHIFT。

这篇文章就是用Squirrel 输入的, 体验到现在来说还是很不错的。



--
Feng

星期五, 六月 07, 2019

Dymo LMPNP on Mac OS Mojave

After upgrading my mac mini to Mojave, my dymo LMPNP Label Printer stop working with the building Dymo Label Light 1.0. 

I can still launch the app and print screen captures,  but it won't accept  anything I type. I tried 2.1 2015 version, doesn't work either.

After trying quite a few different version. I finally found the following one works. This is the full version rather than the light version, which is better.




Another little trick, my LMPNP's battery is dead, it won't recharge. I connect two 3.7V laptop battery into the LMPNP machine, then it works. Don't bother buying a new battery, you  b  new machine with the same money.


--
Feng

星期三, 六月 05, 2019

如何查询域名是哪里买的

如果你买了个域名却忘了购买域名的网站,不知道去哪里管理你的域名, 那么下面这个网址可以帮助你。






--
Feng

星期六, 六月 01, 2019

[Youtube]如何批量下载Youtube 视频和MP3

tags: Youtube,mp3,download,batch,下载,批量

我之前因为需要下载一些歌曲放在U盘里,然后放在车上听, 然后就研究了一下, 发现可以很方便的在youtube 上把整个播放列表扒下来, 而且可以直接转成 mp3, 不转也可以, 需要视频文件的就可以先择不转。批量下载和mp3转换会用到两个工具,youtube-dl 和 ffmpeg, 而提取视频文件的ID则会用到两个在线工具, 一个是 Youtube  官方的  data API 页面, 另一个是我写的列编辑器 http://cc.dengnz.com


以下是下载好工具后的使用方法, 
[bash]
set path=%path%;c:\gre\youtube-dl
set path=%path%;c:\gre\ffmpeg\bin\
[/bash]

如果要转成 mp3, 这样使用
[bash]
youtube-dl --extract-audio --audio-format mp3 https://youtu.be/Y2ge3KrdeWs
[/bash]

要转mp4可以试下这个
[bash]
youtube-dl --recode-video mp4  https://youtu.be/hgIDXTmmgDg 
[/bash]

Youtube 官方 Data API V3, 这个用来提取Youtube 播放列表里面的视频 ID

Youtube-dl 下载地址

ffmpeg 下载地址



附 Linux 下载最新版 youtube-dl 的方法

sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl

sudo chmod a+rx /usr/local/bin/youtube-dl

/usr/local/bin/youtube-dl --extract-audio --audio-format mp3 https://www.youtube.com/watch?v=w0dMz8RBG7g
 

--
Feng

其它博客地址

此博客的同步博客地址: http://fengnz.wordpress.com
点这里进入我的MSN SPACE.