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

星期日, 十一月 29, 2020

[网络技术]把Mlab的数据库迁移到Mongodb Atlas

Mlab 被 mongodb 兼并已经一年多了。

现在迎来了最后期限。现在要着手把数据转移了。

我这里使用 mongodump 和 mongorestore 两个命令来进行转移。mongodump 用来从Mlab 的原数据库中把数据库保存成本地文件。 而 mongorestore 则正好相反, 把本地的文件恢复到 mongo altas 中。 

使用如下命令进行备份。

[code]
mongodump --host ds036577.mlab.com --port 36577 -u <username> -p <password> --db <dbname>
[/code]

以上的 hostname 和 port number 可以登录 Mlab 查到。

然后使用以下命令恢复备份到 mongo atlas

[code]
mongorestore --uri mongodb+srv://fennng:<PASSWORD>@cluster0.yfsui.azure.mongodb.net 
[/code]
以上的连接字串可以登录你的 mongodb atlas 查到, 如下





在使用以上命令之前, 请确保你运行命令的环境的IP地址已经被授权

如下图



还有一个非常重要的地方, 也是让我在这个备份过程中整整卡了一天的地方, 因为得到以下错语

 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AtlasError) bad auth : Authentication failed.


而我又很确定我的密码是正确的, 因为用 mongo shell 是成功的, 所以密码绝对没有错。 害我试了千万种方式, 把不同的 collection string 组合了个遍。

最后发现, 因为我的密码里面有特殊字符, 在使用 --uri 输入密码的情况,我的密码部分必须先 url encode. 否则密码不正确, 是无论如何也连不上的。

 
--
Feng

星期二, 六月 23, 2020

[网络技术]如何导入(import) golang本地文件

在golang 中, 我们要导入一个包 (package) 的时候通常是这样的

[code]
import (
"crypto/rand"
"encoding/binary"
"errors"
"fmt"
"net"
"time"

"golang.org/x/net/ipv4"
)
[/code]

这其中, 有一些是内置的包, 可以直接导入, 比如 "fmt"

而  "golang.org/x/net/ipv4" 则要临时安装, 否则会找不到, 安装的方法也很简单, 只要运行 



然后安装就会自动完成了。

那如果你本地有一个go 文件, 你想要导入这个文件的时候怎么办呢? 比如你有一个文件叫 ntp.go, 和你的 run.go 在同一个文件夹,  你如果这么导入 

import "ntp.go" 

是不工作的

import "./ntp.go" 也一样不行

这里有两件事要做, 首先, 把 GOPATH这个变量加上当前的文件夹

set GOPATH=%GOPATH%;%cd%


然后再跑 go run run.go 的话, 还是会找不着, 因为它找的时候不是直接在你的当前目录找, 而是去当前目录的子目录 src/ntp 里面去找



所以要先建一个子文件夹 src , 然后再 src 里面建一个 ntp 文件夹, 再把你的 ntp.go 文件放进去

这个时候再跑  go run run.go 就可以啦。


--
Feng

星期日, 四月 19, 2020

Youtube Google Script Bot Broken checklist

1. Check whether the mlab is exceed quota
2. Bind the bot to ngork
3. ngrok forward to fiddler
4. Fiddler to point to google app script to test
5. Point to uni account to check stackdriver log
6. delete not important data from db
7. remember to repair the db to release disk



--
Feng

星期四, 四月 16, 2020

[网络技术]安卓模拟器如何互相访问端口

在电脑上运行两个安卓模拟器,要怎么样才能让它们可以互相交流呢。其实并不难, 只需要通过 ADB 工具就能够做到。 这个方法也可以让模拟器访问主机的端口。 理论上应该在实体机上也可以工作。

用 adb devices 命令先找出模拟器的管理端口



然后用 telnet 命令连上模拟器

telnet localhost 5554

进去后, 他会提示一个文件路径, 打开文件, 复制密钥
然后输入

auth k1k9PiHALae7ISyg
再输入
redir add tcp:9002:9000

这样端口转发就完成了, 这时候任何程序访问到 主机的 9002 就相当于在访问模拟器的 9000 端口。



如果你要让模拟器之间访问, 你可以用一个神奇的主机IP, 10.0.2.2 

在模拟器中访问这个IP就等于访问主机, 所以 10.0.2.2:9001 其实就是之前模拟器的 9000 端口。

通过这个方法, 可能可以让不能上网的手机连上网



--
Feng

星期三, 四月 15, 2020

使用 Packet Sender 发送TCP包

有时候我们要测试TCP服务器, 写个客户端当然可以, 不过如果你不能改客户端又想改发送的内容, 用 Pakcet sender 就很方便。 

首先用客户端发送TCP包到 Packet Sender, 然后用 Packet Sender 保存一下, 就可以在Packet Sender 中发送这个包到别的地方了, 还可以改包的值哦。



--
Feng

星期一, 四月 13, 2020

[网络技术] 如何热清除docker 容器的日志文件, 不需要重启容器

Docker 容器默认会把所有的 console output 全都写入日志文字, 久而久之, 这些文件会占用巨大的容量。 我的256G硬盘有150G被日志填满。

Docker 容器的日志文件可以用 docker inspect 命令找到



直接用 rm 命令可以删除, 但是删除后就没有日志文件了, 如果你刚好不想要日志, 这可能是个办法。 当然, 重启容器后日志文件又会生成。

更好的方法是用 truncate 命令, 日志文件会满上被清空, 但是文件还在,  新的日志会被写进去。绝对是腾空硬盘的好方法。

sudo truncate -s 0 /var/lib/docker/containers/1dead224287c1dd5fea7ac6783aadd9cf155e13da8e5d02259a184aaca3ed5d2/1dead224287c1dd5fea7ac6783aadd9cf155e13da8e5d02259a184aaca3ed5d2-




--
Feng

星期五, 三月 27, 2020

微软五笔越来越好用了

默认为英文状态
五笔拼音混输

哈, 这两个重要的五笔输入法功能, Windows 10 自带的输入法已经有了。 现在用自带输入法也挺舒服, 不要各种 hack 了。



--
Feng

星期四, 三月 26, 2020

[Youtube]新西兰冠状病毒一发不可收适?

tags: 新西兰,封国



新西兰封国了, 人民生活怎么样了?


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

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

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

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



星期一, 三月 23, 2020

GVIM 自动切换输入法的插件

tags: vim, gvim, input method





今天在 IntelliJ Idea 上看到一个 vim 的插件可以自动切换输入法, 惊为天人呀, 解决大问题。 

VIM的 normal 模式在中文输入法不能正常工作, 所以切换 normal 和 insert 模式的时候还要切换输入法, 非常的麻烦。 

这个插件可以在进入 normal 模式的时候自动切换到英文状态。 好用!

IntelliJ 的插件是切换整个输入法, 比如从中文切换到美国英语。相当于按下 alt+shift

而 VIM本身的插件则是保留中文输入法,只是把中文输入法切换成英文状态, 相当于按下 右 shift 键




--
Feng

星期日, 三月 08, 2020

[Youtube]新西兰冠状病毒一发不可收适?



Tags: 新西兰, 冠状病毒, round the bay, 万人跑步
新西兰 2月28日出现了第一例冠状病毒, 傍晚宣布沦陷.
然后接下来的几天接二连三出现新的病例, 到3月6日已经出现了五个病例 
3月8日的万人跑步活动依然举行
新西兰何去何从?



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

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

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

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



星期一, 三月 02, 2020

[Youtube]新西兰出现第一例冠状病毒后华人和洋人截然不同的反应

Tags: 新西兰, 冠状病毒, 第一例
新西兰 2月28日出现了第一例冠状病毒, 傍晚宣布沦陷.
华人与洋人反应截然不同. 
是谁过度反应, 还是谁后知后觉?


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

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

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

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





--
Feng

星期日, 三月 01, 2020

视频不小心拍成竖屏怎么办? 旋转视频原来这么简单! 一秒搞定, 无需重新编码.

拍视频的时候, 不小心拍成了竖版的. 上传到 youtube 的时候, 视频变成竖的了. 以前的Youtube 有旋转视频的功能, 但是现在这个功能不见了. 只能重新上传. 

在重新上传之前, 我要把视频先顺时针旋转90度. 于是我用了下面这个命令

[bash]
ffmpeg -i casio.mp4 -vf "transpose=1" casio_90.mp4
[/bash]

以上命令当然是工作的, 但是它会重新编码视频, 所以速度很慢, 大概就是播放速度的两倍. 

我们知道我们上传的视频Youtube 是要重新编码过的, 所以只要Youtube 能正确识别视频的转向, Youtube 就会重新编码成正确的度数. Youtube 的编码器是可以理解视频里的 metadata 的, 所以我们只要简单的把90度旋转写入视频的 metadata 就可以了, 这样不需要重新编码. 10分钟的视频, 一秒钟就搞定了. 

其它的大多数播放器也是支持 metadata 的, 所以重新编辑简直就是浪费生命.

使用以下命令来写入 metadata

[bash]
ffmpeg -i casio.mp4 -map_metadata 0 -metadata:s:v rotate="270" -codec copy output.mp4
[/bash]


这样是不是快很多!

如果旋转的角度不对, 你自己试试90度, 或者180度吧. 反正一秒就搞定了.  

--
Feng

[Youtube]Casio Chronograph WR100M 卡西欧 艾迪菲斯 表盘解析与秒表指针校正方法


Tags: Casio, Chronograph, WR100M,  卡西欧, 艾迪菲斯  


卡西欧 艾迪菲斯 的秒表版, 表盘怎么这么复杂, 里面三个小表盘是作什么用的?
秒表指针复位不正确怎么办?
看完这个视频就全搞懂了.

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

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

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

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



星期六, 二月 29, 2020

[Youtube][跟峰哥学Node.js编程系列教程] Nodejs 如何通过HTTP代理发送HTTP/S请求 [第十三期]


Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, Telegram Bot, Http Proxy

本集介绍如何在Nodejs 通过 HTTP或 HTTPS 代理发关HTTP/S 请求。看完本集你将学会.

如何设置HTTP代理


之前的教程可以在这个播放列表找到

视频里用到的代码请到



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

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

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

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



星期四, 二月 27, 2020

How to Fix Yoasts WordPress SEO Sitemap 404 Error

Just installed Yoasts and enabled sitemap. But then encountered 404 issue.

To fix it, it's not easy, you need to have access to the php code.

edit .htaccess in your wordpress root folder, add following code

[php]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap_index.xml$ /index.php?sitemap=1 [L]
RewriteRule ^([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 [L]
</IfModule>

[/php]

reference:

--
Feng

星期日, 二月 23, 2020

[网站建设]A quick fix for WordPress Hestia theme insecure image warning

After replacing the header background image of Hestia theme. There appeared a security warning on Chrome browser. Then I noticed the background image is linked from HTTP. I believe this issue is caused by the HTTPS reserve proxy I used.  But on the other hand, the theme code should handle this case as I have set $_SERVER['HTTPS']='on';

To fix this problem, I use the following grep command to locate the file. 


[bash]
grep -r --include=*.php "header-filter" .
[/bash]

I found the code is in the following file.

./wp-content/themes/hestia/inc/views/front-page/class-hestia-big-title-section.php

Start from line 97. Update the original code as following: 

[php]
<div class="header-filter"
<?php
if ( ! empty( $big_title_background ) ) {
    $background = esc_url( $big_title_background );
    if (is_ssl()){
        $background = str_replace('http:', 'https:', $background);
    }
    echo 'style="background-image: url(' . $background . ')"';
}
?>
></div>

[/php]

Then problem solved.



--
Feng

星期六, 二月 22, 2020

Wordpress too many redirects wp_admin 和 mixed content 的问题解析

Wordpress 架设在反向代理 reserve-proxy 后面而且使用HTTPS的时候, 常常会碰到这两个问题。 一个是进入后台登录页面的时候出现 too many redirects, 造成无法登录。 而另一个则是在前台CSS也显示不正确, 因为有 mixed content. 

其实在两年前我就碰到过这样的问题, 只是当时谷歌搜索解决了一下问题, 对问题如何引起的并没有关注。 以下是两年前发的贴子。


我今天帮朋友架设一个新的wordpress 网站的时候, 又碰到了这个同样的问题, 可悲的是, 我对自己以前如何解决这个问题完全没有记忆, 甚至没有找到上面这个帖子。 又折腾了大半天。 

所以今天就来好好的分析一下问题的所在, 完全理解了就不容易忘记。 

首先这两个问题都只发生在有反向代理, 而且反向代理使用HTTPS, 而wordpress 本身不使用HTTPS的情况。 

浏览器->反向代理(HTTPS)-> WordPress (HTTP).

我使用的反向代理是 Nginx-Proxy docker 版。

由于HTTP是不安全的协议, 而 wordpress 是有后台可以登录的, 所以我们一定要给 wordpress 启用HTTPS。 而最简单的办法莫过于用反向代理。 我们在服务器上运行两个服务, 一个是反向代理, 一个是WORDPRESS。 反向代理通常监听 80 和 443 两个端口, 而 wordpress 则监听一个内部端口, 如 8080. 

我这里在后台设置的网址是HTTP的, 这里涉及到 HTTP Strict Transport Security (HSTS) 的问题, 这东西常常把问题搞得更加复杂难懂, 我呆会儿会讲到。



当我们的浏览器访问网站的时候, 其实请求是发送到反向代理上的, 这里可以使用 HTTP, 也可以使用 HTTPS. 然后, 反向代理收到请求后, 会把这个请求转发给 8080 端口, 这样, 请求就到了 Wordpress 上。 Wordpress再把内容回复给反向代理, 反向代理再回复给浏览器。 由于 wordpress 是运行在 内部的8080 端口上的是, 所以即使它用的是HTTP协议, 却也是安全的。 


以上这种设置在跑HTTP的时候不会有问题。 但是, 跑HTTPS的时候, 问题就来了。 因为虽然我们浏览器发的HTTPS的请求, 但是反向代理发到Wordpress 的请求确是一个HTTP的请求。 这个时候, Wordpress 并不知道反向代理的存在, 所以它以为有一个用户在通过HTTP请求页面, 这时候 Wordpress 生成的网页里的CSS和Javascript 文件链接就全是HTTP的,而不是HTTPS的。 这个时候, 就会有 Mixed content 的问题。 因为我们请求的主页是HTTPS的, 但主页里的链接却全是 HTTP的。 

以上就是为什么会有Mix Content 的问题。 


理解了上面的情况, 再来理解 Too many redirects 也很容易了。 因为原因是一样的。 因为HTTP是不安全的, 所以我们在登录后台的时候就需要使用HTTPS, 这里有两种方法, 第一种, 把wordpress 设置里面的网址强制成 HTTPS开头的。 第二种, 在wordpress 的配置文件 wp-config.php 中加入以下这行

define('FORCE_SSL_ADMIN', true);

这样, 再登录后面的时候, 我们就可以保证在HTTPS下运行了。 因为当你是HTTP的请求进来的时候, Wordpress 会返回一个重定向的回复, 把请求引到HTTPS上。 

但是, 如果你还记得上面我说的, 这个时候就有个大问题。 其实我们浏览器到服务器的请求本来就已经是HTTPS了, 这个时候, 是反向代理收到了请求, 然后反向代理转发请求到Wordpress 端口的时候用的却是HTTP, 于是Wordpress 返回重定向的网址, 要求浏览器重定向到HTTPS。 于是浏览器被重定向到了一个相同的地址, 可是反向代理又把HTTPS转成HTTP了, Wordpress 又要求重定向, 于是就出现了死循环。 这就是为什么会有 too many redirects 的原因。 


以上还不是最糟糕的,因为你会发现,一旦你设置的网址是HTTPS开头的, 不仅HTTPS不工作, 这时候连HTTP也不工作了。 所以你无论如何都登录不了后台, 也无法把网址改回来。因为你用HTTP访问的时候, Wordpress 会把你重定向到HTTPS.

于是你只好千方百计的去数据库把网址改成HTTP, 比如说用 phpmyadmin. 

可是你悲剧的发现,这并没有用, 你还是一直被重定向到HTTPS, 可是你明明已经改了数据库里的网址呀? 这就涉及到了 HSTS. 

默认情况下, nginx-proxy 的HSTS是开启的,所以一但你用了HTTPS登录过网站后, 你再用HTTP登录的时候, 浏览器会自动把HTTP转成HTTPS. 这个时候唯一的方法就是进入浏览器的设置把你网址的HSTS记录删除。 否则你永远也无法使用HTTP来访问网站。 当然, 有时候你可以使用一个新的没有登录过HTTPS 浏览器或隐身模式来开网站。 

使用 phpmyadmin 改为网址再清了HSTS后,你就可以用HTTP 访问网站了。 但是这绕了一圈又回到原点, 并没有解决HTTP 登录后台不安全的问题。 所以, 后面才是真正的解决方案。 


首先, 我们在后台设置的网址应该用 HTTP,而不是HTTPS。 

是否强制使用HTTPS, 我们可以通过设置反向代理来做到, 比如 Nginx-proxy 可以通过 HTTPS_METHOD 这个变量来决定是否强制HTTP或HTTPS, 或两者都可以。 而我是设置了两者都可以。 


如果设置了两者都可以, 我们如何保证用HTTPS后台登录呢? 这时候,我们可以在 wp-config.php 里加入以下这行

define('FORCE_SSL_ADMIN', true);


这样会强制在登录后台的时候会转到HTTPS, 不登录后台的话, 则HTTP或HTTPS都可以。

然后就是最重要的一步, 

你要在wp-config.php 里面加入以下代码来识别浏览器的原协议是否HTTPS。 

// If we're behind a proxy server and using HTTPS, we need to alert Wordpress of that fact
// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
        $_SERVER['HTTPS'] = 'on';
}

或者你也可以试试官方给出的代码, 效果应该一样。

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';

这段代理假设你的反向代理有插入 X_FORWARDED 头, 至少 nginx-proxy 是有的。 如果你的反向代理没有, 你应该可以将这个功能打开。 如果不行, 建议你换个反向代理工具。 

好了, 以上就是烦人的 HTTP Wordpress behind HTTPS reverse proxy 的问题的解决方案。 顺便提一下, 这种情况不要去安装 Wordpress 的HTTPS /SSL 插件, 它们并没有用。



星期四, 二月 20, 2020

[youtube]口罩用途全解析, 哪种最适合冠状病毒? 外科? 医用? N95? P2? R95?

tags: 口罩, 冠状, 病毒, n95, r95, n95, p2



由于冠状病毒的传播, 口罩变得炙手可热. 但是市面上的口罩多种多样, 到底哪一种才是最适合的呢? 如果你手上没有最适合的那种, 其它口罩可以代替吗? 

视频中介绍的都是有通过标准认证的口罩. 那些没有任何认证的绵布口罩或其它口罩通常不能有效阻止微小的病毒的载体颗粒. 把绵布口罩洗了再用这种省钱的方式是不可取的.

--
Feng

星期六, 二月 15, 2020

[Youtube]峰哥教你玩正则表达式 - 第六课 - 正则原理与前瞻后瞻

Tags: regex, regular expression, regex101, 正则, 正则表达式, 前瞻, 后瞻

本节课为正则表达式高级教程, 看完本视频你将掌握:

正则表达式的大概原理 (有限状态机)
正则表达式中的肯定前瞻
 正则表达式中的否定前瞻 
正则表达式中的肯定后瞻 
正则表达式中的否定后瞻   


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

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

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

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



星期四, 二月 13, 2020

How to batch run npm install on Windows 10

If for some reasons, npm update doesn't fit you need and you need to update some npm packages one by one.

You will want to write a batch command to do it. It seems that a simple bat or cmd file with all the npm installl command listed will work. 

But the truth on windows is, only the first command is run.  

The reason is that npm itself is not a command but a batch file too. Too make sure all the npm commands will be run, you can add a call in the front of the command. 

Check the example below:


call npm install @angular/core@latest
call npm install @angular/forms@latest
call npm install @angular/platform-browser@latest
call npm install @angular/platform-browser-dynamic@latest
call npm install @angular/platform-server@latest
call npm install @angular/router@latest
call npm install @angular/tsc-wrapped@latest
call npm install @angular/core@latest
call npm install angular2-notifications@latest
call npm install bootstrap@latest
call npm install codelyzer@latest
call npm install elements-zone-strategy@latest
call npm install extract-text-webpack-plugin@latest
call npm install html-webpack-plugin@latest
call npm install karma-webpack@latest
call npm install webpack-dev-middleware@latest
call npm install ng-pick-datetime@latest
call npm install ng2-img-max@latest
call npm install ngx-file-drop@latest
call npm install ngx-mask@latest
call npm install tsickle@latest

--
Feng

星期日, 二月 09, 2020

[Youtube]峰哥教你玩正则表达式 - 第五课 - 分组与优先级

Tags: regex, regular expression, regex101, 正则, 正则表达式, 分组, group

本节课为正则表达式入门教程, 看完本视频你将掌握:

正则表达式中如何定义匹配的优先级
如何抓取分组里的内容
如何使用抓取的内容替换


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

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

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

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




星期二, 一月 21, 2020

A strange but works connection using HG259B as a wifi repeater

The connection is a little bit wield. The other router doesn't need any config. 

HG259B is router B
The original router is router A

Router B is from previous internet company. Router A is from the new  internet company. 

The original layout is simple, router A is connected to the fibre box with the WAN port. All other devices can connect to internet through router A's WIFI.

Telephone is connected to router A and working. 

Both routers have 2 telephone ports. But only router A has correct VOIP settings. Router A's company doesn't provide password to login to router A. So there is no way to copy the VOIP settings. 

The problem is that router A's WIFI signal cannot reach as Far as router B. Router B has the same config as router A for internet connection, so use router B for internet connection is OK. but as router B doesn't have VOIP settings,  telephone is not working with router B.

As we cannot enter router A's management portal, we can only do something from router B. The bad news is that Router B doesn't support WDS, so cannot use as a standard WIFI repeater.

The solution I made here is still using router B as a wifi repeater. 


The connection is as such:

Router B's WAN port connects to Fibre box
Router A's WAN port connects to Router B's LAN 1
Router A's LAN 2 connects to Router B's LAN 2


The hardware connection is simple, but wield. As Router A and Router B is already connected using  WAN port and LAN 1, it shouldn't need LAN2 to LAN2 connection. 


The software part is more complex:

1. Router B needs to be config as bridge mode, as below



2. Router B's IP is config to match Router A's domain, in my case, Router A's IP is 192.168.20.1, so I set router B's IP to 192.168.20.254. Also DHCP should be turned off. (So that Router'A DHCP will work).




3. Telephone is still connect to Router A


With this settings, Connect to both Router A's WIFI and Router B's WIFI will work. 

Different from WDS, their WIFI name and password are different. But actually they are the same network. Devices connect to both WIFI and talk to each other.



Questions: If we don't use bridge mode, can we still make it work? I failed once with these settings. But I am not sure If I made some other mistakes. It suppose to work with the following connection:

Router A's WAN port connect to Fibre box
Router B's LAN 1 connect to Router A's LAN 1
Router B change IP to match router A
Router B disable DHCP




--
Feng

星期五, 一月 17, 2020

Re: How to use a different nodejs version on atlassian bamboo build agent

If docker is available on the build server, use docker contained nodejs to build is a good idea too.

feng <fengnz@gmail.com> 于2020年1月17日周五 上午10:40写道:
When you build a nodejs app, you may need to use a specific version of node for building.  Either you want to match the running env or your node packages require a certain nodejs version. 

On Azure DevOps, you can easily choose the node version by adding a nodejs installer step. With bamboo, there is no nodejs install, but this can be achieved easily if you have admin access to the build agent. 

In the build steps, add a script step, and add the following inline script. This script will switch the node version for you. For first time running, you need to uncomment all the lines to install nvm first. 

[bash]

node -v
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v
[/bash]

Then you can add a npm install step, it will use the new node version. Or you can simply add node install command to the script.

--
Feng


--
Feng

How to use a different nodejs version on atlassian bamboo build agent

When you build a nodejs app, you may need to use a specific version of node for building.  Either you want to match the running env or your node packages require a certain nodejs version. 

On Azure DevOps, you can easily choose the node version by adding a nodejs installer step. With bamboo, there is no nodejs install, but this can be achieved easily if you have admin access to the build agent. 

In the build steps, add a script step, and add the following inline script. This script will switch the node version for you. For first time running, you need to uncomment all the lines to install nvm first. 

[bash]

node -v
#curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#nvm install 13.6.0
nvm use 13.6.0
nvm list
node -v
[/bash]

Then you can add a npm install step, it will use the new node version. Or you can simply add node install command to the script.

--
Feng

其它博客地址

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