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

星期日, 十月 20, 2019

[Youtube][跟峰哥学Node.js编程系列教程] 制作简单的URL转码在线工具 [第九期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap, Url Encoder


本集是节实验课, 演示一下使用之前学习的内容, 如何做出一个在线URL转码的小工具! 



之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

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

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用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, 2019

[Youtube][跟峰哥学Node.js编程系列教程]使用Bootstrap 美化表单和表单的客户端验证 [第七期]

Tags: Javascript, nodejs, 峰哥, yufeng deng, expressjs, jade, pug, handlebars, bootstrap


本集主要讲如何使用 Bootstrap 来美化和验证表单,  并用 bootstrap 在客户端显示错误提示信息.

看完本集你将学会:

如何使用bootstrap 样式美化网页
如何使用浏览器内建的表单验证
如何使用bootstrap 显示漂亮的表单和错误提示



之前的教程可以在这个播放列表找到
https://www.youtube.com/playlist?list=PL3dZh-p-vVofgTEnJ_SL1LM9jxmQp19E2


视频里用到的代码请到

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

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用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

星期三, 十月 09, 2019

[网络技术]Pandoc Undefined control sequence error

When I used pandoc to one of my files, it produced the following error.

Error producing PDF.
! Undefined control sequence.
l.256 \tightlist



I don't know which part of the markdown cause this. Search on google and find this solution:


Simply adding a empty tightlist to the template file fixed the issue.


--
Feng

How to increase docker toolbox disk size

Today, when I tried to pull a pandoc docker image, I got the following error. Simply, I ran out of the disk.

image.png

But my harddrive still have more than 100G space left. So what's the problem.

The reason is that docker toolbox is actually running in a linux VM hosted by virtual box. The default disk size of the VM is 20G.

Increase Virtualbox vdisk

So things become clear, I need to increase the VM disk size. So that I stopped my VM and run the following command to get a bigger VM disk.

cd C:\Users\dengy\.docker\machine\machines\default\  set path=C:\Program Files\Oracle\VirtualBox;%path%  vboxmanage clonehd "disk.vmdk" "virtualdisk.vdi" --format vdi  vboxmanage modifyhd "virtualdisk.vdi" --resize 65536  

Then replace the old disk with the new one.

image.png

image.png

image.png

Re-partition the disk in linux

So far so good, but it didn't work. I restarted the machine, still lack of space.

Now, the "physical" disk has been increased, but the partition in linux system is still the old size. Follow this blog to re-partition the disk.

https://www.dengnz.com/2019/03/25/increase-azure-linux-vm-disk-size/ 

You will get permission denied, that's ok, restart the vm and run sudo resize2fs /dev/sda1

then you will get your disk size correct.

image.png

You are done!

星期一, 十月 07, 2019

[Youtube]Telegram Bot 使用Cloudflare CF worker 制作回声机器人 [第二集番外]

Tags: Telegram, 机器人, 聊天机器人,机器人编程,机器人代码, Telegram代码,Telegram Bot, Telegram编程

https://youtu.be/-_fcxPsCVYs



第二集的视频在这里
https://youtu.be/SxwsGWlMfP4

整个系列的视频请点视频右上角的感叹号.


哈喽, 大家好, 欢迎来到峰哥分享, 我是峰哥.

最近咳嗽的老毛病又犯了, 基本没办法讲话.

所以今天这个视频就打字好了.

今天我来介绍一下怎么样在Cloudflare 上用worker 来创建一个Telegram bot 的聊天机器人.

当然是最简单的机器人, 只能简单的回复文字, 而且还是同样的汤姆猫机器人, 就是你说什么, 它就说什么.

之前出的教程是在谷歌的 app script 上面的, 其实代码都是JS, 所以把我的GAS (google app script)
的教程拿在 cf worker 上面, 也是差不了多少.

所以, 今天就来教大家做一个最基础的机器人, 剩下的, 小伙伴们再看我的telegram bot的教程, 应该就能看明白了.

好吧, 开始教程!

首先, 我们需要创建一个机器人, 这个就直接看我的TG教程系列的第一集就可以了.

机器人申请好了, 我们来加一下 cf worker 的代码

还没有cloudflare 帐号的小伙伴自己注册一下, 这个很简单,我就不多介绍了.

自己到以下网址注册

https://dash.cloudflare.com/sign-up

然后登录

新建一个 worker 脚本

新建完脚本以后, 是一个简单的hello world 网页, 直接就是工作的.

通过 save and deploy 发布这个网站

到以下这个网址去抄网方的示例POST代码
https://developers.cloudflare.com/workers/templates/snippets/post_data/

抄来的代码最后那段HTML不要, 然后 save and deploy 就可以开作了

只是简单的显示了 The request was a GET

现在我来加入机器人的代码, 只有简单的几行, 非常容易!

粘贴完这段代码

let bodyString = await readRequestBody(request)

try {

let body = JSON.parse(bodyString);

const init = {
headers: { 'content-type': 'application/json' },
}

if (body.message) {
let payload = {
"method": "sendMessage",
"chat_id": body.message.chat.id,
"text": "Only echo back text",
"parse_mode": "markdown",
"disable_web_page_preview": true,
};
if (body.message.text) {
payload.text = body.message.text;

const myInit = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
};

let myRequest = new
Request("https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/",
myInit)

//let myRequest = new Request("https://eaa874bb.ngrok.io", myInit)
fetch(myRequest).then(x=> {
console.log(x);

});


return new Response("OK")
} else {
return new Response("OK")
}

} else {
return new Response(JSON.stringify(body), init)
}

}catch(e){
return new Response(e)
}

注册刚才高亮的那段代码, 其中的网址是以下这段, 这里面从bot 开始, 就是机器人的token
https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/

注意后面那个 / 非常重要, 不能省略

好了, 现在发布改过的代码

发布完成后, 我们需要绑定机器人, 机器人的网址在这里

https://raspy-sun-ed74.fennng.workers.dev/

为了预防成一, 我们把这个网址做一下 urlencode

网上随便找一个在线的 url encoder , encoder 完是以下的样子

https%3A%2F%2Fraspy-sun-ed74.fennng.workers.dev%2F

现在找到绑定机器人的链接,以下这段是设置机器人的链接, 前面 https://api.telegram.org/bot 这段是固定的,

中间这段 682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA 是机器人的 token

后面这段是设置机器人链接的方法 /setWebhook?url=

所以我们要把机器人后台链接放在这个链接的最后面

https://api.telegram.org/bot682267360:AAHmjSil8oylavD2pENLLpcMU1svaD7mVeA/setWebhook?url=https%3A%2F%2Fraspy-sun-ed74.fennng.workers.dev%2F

粘贴完后是上面这个样子

现在把这个链接放在浏览器的地址栏打开, 看到以下这个就是绑定成功

{"ok":true,"result":true,"description":"Webhook was set"}

现在我们去试下机器人

工作, 发布成功.

现在来随便改点东西, 简单的加了个签名, 现在再去看看

成功的改了....

很简单吧, 机器人的创建看第一集. 然后, 其它机器人的功能看我关于 谷歌app script 的教程就行了, 差不了多少.

注意的是, cf worker 的 fetch 是 promise, 这点和gas 有很大不同...做简单的机器人可以先不理会. 跟着我的代码写就行了.

好了, 今天的教程就到这里, 喜欢这个视频的话, 不要忘了点赞,订阅还有转发!

谢谢大家. 我们下载再见!


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

本频道旨在分享生活中各种小技巧, 如用小米盒子看国内视频, 如何使用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
-~-~~-~~~-~~-~-

其它博客地址

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