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

星期五, 四月 19, 2019

[youtube]谈谈996和我在新西兰的加班史

tags: 新西兰,996, 峰哥


996 

我以前没有这个概念
听人说国内IT业经常加班
但不知道居然是这样一种强制性的,无谓的加班

有的有加班费,有的没有
不管有没有,强制是不对的, 应该是可选的

让员工自愿放弃年假,自愿放弃加班工资,太可恶了
有的没事做,就是不让人走
八仙过海, 各显神通磨时间
这个到底是奋斗还是剥削? 都不是,就是浪费时间

马云说是一种福报,我觉得是狗屁
不是所有的996都能助人成长,有时候做已经滚瓜烂熟的事情只是让你疲惫
有些做完996成长迅速自己当老板的不是没有, 但是不要这是个例, 用这些人当榜样还鼓励人我觉得就是一种诈骗, 比耸踊人买彩票还可恶


新西兰有没有996, 不敢肯定的说没有,不过我是没见过,连听都没听过
我听过的是:
灵活时间
在家上班
晚来早退
加班工资1.5 倍
上班真正有效率不超过4小时
其它时间,看youtube , 打台球,打乒乓球,玩console game。。。有人中午出去键身,游泳,蒸桑拿,下午2,3点才回来,而且这些东西都是公司提供的
周五下午三点后, 基本没人在上班, 公认社交时间, 公司一般提供饮料,啤酒, 大家开始吹水

大公司养闲人,没项目的时候也不敢放人, 空养  

我不是说这些就是好的文化,只是陈述一下事实, 让大家了解一下。

我有没有加过班?  


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

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

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

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

星期六, 四月 13, 2019

[Youtube]【新西兰留学系列】【第三集】落地以后要做的事和会碰到的困难

tags: New Zealand,oversea study,新西兰,留学,移民,峰哥  


本视频 是峰哥《新西兰留学系列》的第二集, 本集主要讲了在异国落地后会碰到的困难,主要讲了峰哥本人的一些经历。

系列由在新西兰留学生活了16年的峰哥出品。 峰哥在新西兰留学到工作的签证都由自己操办。后来还办过亲友旅游,父母移民,配偶团聚等签证。 峰哥还办过美国,加拿大,马来西兰等地的旅游签。 对新西兰留学,生活,签证都有丰富的经验。 在此峰哥把自己宝贵的经验分享给大家, 希望对有兴趣留学移民的朋友能有所启发。  



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

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

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

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

星期四, 四月 11, 2019

[Youtube]【新西兰留学系列】【第二集】如何办理学生签证 - 新西兰学生签证难不难办?

tags: New Zealand,oversea study,新西兰,留学,移民,峰哥  


本视频 是峰哥《新西兰留学系列》的第二集, 本集主要介绍了办理新西兰学生签证要注意的地方, 解析了为什么会被 拒签, 还有如果拿到录取通知书的办法

系列由在新西兰留学生活了16年的峰哥出品。 峰哥在新西兰留学到工作的签证都由自己操办。后来还办过亲友旅游,父母移民,配偶团聚等签证。 峰哥还办过美国,加拿大,马来西兰等地的旅游签。 对新西兰留学,生活,签证都有丰富的经验。 在此峰哥把自己宝贵的经验分享给大家, 希望对有兴趣留学移民的朋友能有所启发。  

为什么选择新西兰

费用较低
移民容易 
福利好,医疗,ACC, 教育
父母移民容易 (以前, 也许以后)
华人多,华人社区多,华人超市 也多生活交友容易 
环境好,空气好,地面干净,车不用常洗, 风景好
没有蛇,驴友首选
唯一有永久回头签的国家


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

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

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

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


星期二, 四月 09, 2019

BYO Bring your own router, can I use the router from previous ISP In New Zealand?

Short answer: Yes

Long answer:

In most of the case, you can.  

I recently moved from Spark to Stuff-Fibre and I kept use the router from Spark. It worked. The only thing that I need to do is restarting the router. Nothing else. 

I was worried about this as I asked Stuff-fibre not to send me the router and I didn't know whether the privious one would work. Because the Spark router may be restricted to only work for Spark.



For the exactly same service, Spark charged me for $105, with the new company, on average, I pay $64 a month. I regret that I didn't do this earlier.  I couldn't remember the previous speed. But the following speed is more than enough for me.



The router came with Spark is HG659b. It supports ADSL, VDSL and fibre.  My previous plan with Spark was Fibre, I switch to Stuff-Fibre with the same level Fibre plan.

Note that I have to write to Stuff-fibre by email to cancel the route delivery, otherwise, I have to pay for the delivery fee. And the router is rent from them, I have to give it back after the 12 month contract. It seems there were some communication issue on their end. I still received a router, and they said that they will send me a prepaid post bag to ship it back. And my account is not charged for the delivery fee.

One problem with Stuff-Fibre is that I cannot find my home address in their system. Although I can manually enter my home address from they main page, but I prefer to use broadbandcompare website to buy the service, as I can get 3 months free rather than 2 months free.  But this cannot be done as I cannot find my home address. I had to write to them before go further.  Eventually, I did the process from their website with a wrong address (oh, I forgot to manually enter). Then they correct the promo code and address from their side.

It's a great buy so far.





星期一, 四月 08, 2019

Text Editor anywhere - Edit any text field in a browser from any external editor

I found a quite interesting software.

This is a stand-along software rather than a browser extension.

You can download it here.

Once install and run, you can set a hotkey for it and add your own editor.



Then within a text field in browser, press the hotkey. 

A dropdown will be shown, you can select the editors from here by pressing the hotkey again.


Then, you can edit your text in your favorite editor. Once you save the text in your editor, it will be synced to the browser.

Quite a useful feature for me, as I do frequently copy text from browser to VIM and paste it back after editing.



星期日, 四月 07, 2019

SBT dependency download problem

When run SBT, none of the dependencies can be downloaded.

I got this error:

Server access Error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target url=  




The reason is that the HTTP client used by JAVA doesn't trust any HTTPS certificate. You have to add all the certificates to the trustStore. 

Solution:

Instead of adding many certificates. I only added fiddler's certificate. This is a easier way to do it. I enable SSL decryption on my Fiddler (windows). This will make fiddler to resign all the packets. Then I export fiddler's root certificate to the desktop.

Use the following command to generate a keystore file.

keytool -import -file %userprofile%\Desktop\FiddlerRoot.cer -keystore FiddlerKeystore -alias Fiddler

I then copy this keystore file to the project folder.

Set the SBT_OPTS environment as below.

export SBT_OPTS="$SBT_OPTS -Dhttps.proxyHost=192.168.1.69 -Dhttps.proxyPort=8888 -Djavax.net.ssl.trustStore=/Users/fengnz/FiddlerKeystore -Djavax.net.ssl.trustStorePassword=Youpassword"  

Then run sbt command again, the problem resolved. 

And I can see all the downloading from Fiddler too.








星期六, 三月 30, 2019

[Youtube]【新西兰留学系列】【第一集】为什么要留学 - 学渣变学霸, 为什么选择新西兰留学

tags: New Zealand,oversea study,新西兰,留学,移民,峰哥

第一集, 留学到底是为了什么, 你也许没有好好想过这个问题就决定要留学了。 看完这集也许会改变你的想法。

本系列由在新西兰留学生活了16年的峰哥出品。 峰哥在新西兰从留学到工作的签证都由自己操办。后来还办过亲友旅游,父母移民,配偶团聚等签证。 峰哥还办过美国,加拿大,马来西兰等地的旅游签。 对新西兰的留学,生活,签证都有丰富的经验。 在此峰哥把自己宝贵的经验分享给大家, 希望对有兴趣留学移民的朋友能有所启发。

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

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

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

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

星期三, 三月 27, 2019

[网络技术]Internet Download Manager (IDM) interrupt Adobe Create Cloud Download

Tags: IDM, Adobe

When I tried to install Adobe XD from XD_Set-Up.exe. It quit in the middle of downloading. I then used the Adobe Create Cloud from My already installed Adobe CC to download XD. 

Adobe Create Cloud will do a self upgrade then start downloading XD. In the middle of downloading, IDM popup and interrupt the download process. I disabled the "Use advanced browser integration" feature in IDM then tried again. Then all good.





星期一, 三月 25, 2019

Increase Azure Linux VM Disk Size

After:



Before:


When I created my Linux on Azure, I used the default 30G size. I used it up after 1 year. Then I had to increased the disk size. I decided to increase the disk size to 60G. I did this on Azure portal, it's pretty straightforward.

I stopped my VM and increased the disk size then restarted my VM. But nothing has changed. 

I then found this link, then I realized that Azure portal didn't do all the magics for me, I had to increase the partition manually. 


But the way shown on this page didn't help me, I got the following error on the first step. I couldn't continue.

fennng@fengUbuntu3:~$ sudo umount /dev/sda1
umount: /: target is busy.

Then I found this page. 

Above page shows the right way to do it, but when I first time tried it, I got the following error.

Command (m for help): w
GPT PMBR size mismatch (62914559 != 125829119) will be corrected by w(rite).
fdisk: failed to write disklabel: Invalid argument

Then I found another link for the solution



To Summarize, I needed to run parted to fix the GPT  then run the fdisk command to rewrite the partition table. Then use resize2fs command to make it take affect. Restarting the VM is not necessary. I can do this online, even it's a system partition.


The following are the full steps:

fennng@fengUbuntu3:~$ sudo parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 62914560 blocks) or continue with the current
setting?
Fix/Ignore? Fix
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
14      1049kB  5243kB  4194kB                     bios_grub
15      5243kB  116MB   111MB   fat32              boot, esp
 1      116MB   32.2GB  32.1GB  ext4

(parted)

fennng@fengUbuntu3:~$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table



Command (m for help): p
Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 86027915-3219-49D0-BD7B-9D73DBA28691

Device      Start      End  Sectors  Size Type
/dev/sda1  227328 62914526 62687199 29.9G Linux filesystem
/dev/sda14   2048    10239     8192    4M BIOS boot
/dev/sda15  10240   227327   217088  106M EFI System

Partition table entries are not in disk order.

Command (m for help): d
Partition number (1,14,15, default 15): 1

Partition 1 has been deleted.

Command (m for help): n
Partition number (1-13,16-128, default 1): 1
First sector (34-125829086, default 227328):
Last sector, +sectors or +size{K,M,G,T,P} (227328-125829086, default 125829086):

Created a new partition 1 of type 'Linux filesystem' and of size 59.9 GiB.
Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Syncing disks.


fennng@fengUbuntu3:~$ sudo resize2fs /dev/sda1
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/sda1 is now 15700219 (4k) blocks long.

fennng@fengUbuntu3:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.7G     0  1.7G   0% /dev
tmpfs           344M  1.8M  343M   1% /run
/dev/sda1        58G   27G   32G  46% /
tmpfs           1.7G     0  1.7G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           1.7G     0  1.7G   0% /sys/fs/cgroup
/dev/sda15      105M  3.4M  102M   4% /boot/efi
tmpfs           344M     0  344M   0% /run/user/1000


星期六, 三月 23, 2019

[Youtube] Telegram Bot 电报聊天机器人连接 RestHeart MongoDB 数据库

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


本视频是Telegram Bot 机器人编程系列的第十三集。 本集介绍如何使用机器人来连接 RestHeart Mongo DB.

相关的代码请到翻到下面


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

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

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

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

本集只提供新的 Restheart.gs 文件, 其它文件请看之前的视频, 跳着看是不行地
[javascript] 
var mongo;
var restheart = {};

restheart.insert = function(collection, data) {
  var db = restheartUrl + collection;
  var option = getInsertOption(data);
  var response = UrlFetchApp.fetch(db, option);
};

function testRestHeart(){
//  restheart.replace("to-telegram", null, {desc: "record all message send to telegram chat"});
//  restheart.replace("telegram-response", null, {desc: "record all message return from telegram"});
//  restheart.replace("logs", null, {desc: "record some other logs"});
 var data = {test: 'test2'};
 restheart.insert("logs", data);

//  var data = {test: 'test replace'};
//  restheart.replace("testColl/5c75be5e294610d3cbaa39f9", null, data);

//  var data = {test: 'test get'};
//  restheart.get("testColl/5c75be5e294610d3cbaa39f9", null, data);
//
//  var data = {test: 'test set'};
//  restheart.set("testColl/5c75be5e294610d3cbaa39f9", null, data);


//  var data = {"$addToSet":{"array" : "bar2"}};
//  restheart.setOne("testColl/5c75be5e294610d3cbaa39f9", data);
}

restheart.replace = function(collection, query, data) {
  var db = restheartUrl + collection;
  if (query){
    db += "?" + query;
  }
  var option = getPutOption(data);
  var url = encodeURI(db);
  UrlFetchApp.fetch(url, option);
};

restheart.setOne = function(urlWithId, data) {
  var db = restheartUrl + urlWithId;
  var option = getPatchOption(data);
  option.muteHttpExceptions = true;
  var url = encodeURI(db);
  var response = UrlFetchApp.fetch(encodeURI(db), option);
}

restheart.setMany = function(collection, query, data) {
  var db = restheartUrl + collection;
  if (query){
    db += "/*?" + query;
  }
  var option = getPatchOption(data);
  var url = encodeURI(db);
  UrlFetchApp.fetch(url, option);
}

restheart.set = restheart.setMany;
restheart.remove = function(collection, query) {
  var db = restheartUrl + collection;
  if (query){
    db += "/*?" + query;
  }
  var option = getDeleteOption();
  var url = encodeURI(db);
  UrlFetchApp.fetch(url, option);
}

restheart.get = function(collection, query) {
  var db = restheartUrl + collection;

  if (query){
    db += "?" + query;
  }

  var option = getGetOption();
  var response = UrlFetchApp.fetch(encodeURI(db), option);

  var contentText = response.getContentText();
  var responseString = JSON.stringify(response);

  var  object = JSON.parse(response);
  return  object;
}

mongo = restheart;



function getInsertOption(data){
  var option = {
    "method": "post",
    'contentType': 'application/json',
    'headers': {"Authorization": "Basic " + Utilities.base64Encode('user2' + ":" + 'changeit')},
    "muteHttpExceptions": true, 
    "payload": JSON.stringify(data)
  };
  return option;
}
function getDeleteOption(){
  var option = {
    "method": "delete",
    'contentType': 'application/json',
    'headers': {"Authorization": "Basic " + Utilities.base64Encode('user2' + ":" + 'changeit')},
  };
  return option;
}
function getPutOption(data){
  var option = {
    "method": "put",
    'contentType': 'application/json',
    'headers': {"Authorization": "Basic " + Utilities.base64Encode('user2' + ":" + 'changeit')},
    "payload": JSON.stringify(data)
  };
  return option;
}
function getPatchOption(data){
  var option = {
    "method": "patch",
    'contentType': 'application/json',
    'headers': {"Authorization": "Basic " + Utilities.base64Encode('user2' + ":" + 'changeit')},
    "payload": JSON.stringify(data)
  };
  return option;
}
function getGetOption(){
  var option = {
    "method": "get",
    'headers': {"Authorization": "Basic " + Utilities.base64Encode('user2' + ":" + 'changeit')},
  };
  return option;
}


[/javascript] 



星期四, 三月 21, 2019

nginx-proxy companion SSL generating issue.

The following message has bothered me for quite a while. One think I didn't realize is that I have to run companion after nginx-proxy. 

If I recreated nginx-proxy, I have too recreate companion too. 

The reason is that when companion is created, it will mount the columns created by nginx-proxy. Because I recreated nginx-proxy without recreating the companion. I see the following message quite a lot. 

Although I recreated companion after nginx-proxy, I still see the following message for some of my sub domains.  Why not work? Still a myth.



Creating/renewal www.dengnz.com certificates... (www.dengnz.com blog.dengnz.com)
2019-03-21 06:57:34,726:INFO:simp_le:1479: Generating new certificate private key
2019-03-21 06:57:37,845:ERROR:simp_le:1446: CA marked some of the authorizations as invalid, which likely means it could not access http://example.com/.well-known/acme-challenge/X. Did you set correct path in -d example.com:path or --default_root? Are all your domains accessible from the internet? Please check your domains' DNS entries, your host's network/firewall setup and your webserver config. If a domain's DNS entry has both A and AAAA fields set up, some CAs such as Let's Encrypt will perform the challenge validation over IPv6. If your DNS provider does not answer correctly to CAA records request, Let's Encrypt won't issue a certificate for your domain (see https://letsencrypt.org/docs/caa/). Failing authorizations: https://acme-v01.api.letsencrypt.org/acme/authz/uoqWjCqWisFVQLcZCYhCJufl0k-qGst-sDqwR3_vUaA
Traceback (most recent call last):

[wordpress] Wordpress 无法升级到新版,要求FTP的问题

昨天我把wordpress里面的更新都更新了, 更新插件的时候没有问题, 我设置了正确的文件权限。 

可是要把wordpress 本身升级到 5.11 的时候, 却总是要我登录FTP。 我的文件夹的权限都是对的呀, 怎么回事呢。

最后通过搜索,我才知道, 要在 wp-config.php 里面加入

define('FS_METHOD', 'direct');

才能够直接升级wordpress 本身, 加入这行后, 问题解决。




[网络技术] 使用Google App Script 发送文件并支持中文名 - Telegram 机器人示例

Tags: Telegram Bot, Google App Script, multipart/form-data, 中文名

我在使用 Google App Script 给我的机器人发送文档的时候,发现发不了中文名, 使用UrlEncoded 过的中文名的话, 显示的是Encoded 后的字串, 而使用中文名的话, 中文名就完全不见了。 

给Telegram 机器人发送文件和网页上传文件用的是一模一样的原理, 所以这篇文章也适用于任何使用 multipart/form-data 上传文件的情况。

首先, 要使用Google App script 上传一个文档很容易, 以下代码会下载一个电子书, 然后改名, 再上传给Telegram 机器人。

[javascript]



function quickTest(){
    var blob = response.getBlob();


    blob.setName("峰哥牛逼.azw3");

    var payload = {
        "method": "sendDocument",
        "chat_id": "@fengdrawbottest",
        "document": blob,
    };


    var options = {
        "method": "post",
        "payload": payload
    }

    UrlFetchApp.fetch("https://api.telegram.org/bot717031367:xxx", options);

}



[/javascript]

以上代码可以工作, 但是中文名会不见, 最后Telegram 端收到的文件名是 azw3, 前面的 中文和那个点都不见了。 如何使用英文名就不会有问题。

通过技术手段拿到Google App script 发送出来的 Request 是这样的


中文名的地方变成了问号。

从上图可以看到, UrlFetchApp.fetch 命令自动生成的 multipart/form-data request body 没有办法支持中文。 所以解决方案就是不要使用它的自动生成。而是手动的生成multipart/form-data , 这样我们就可以完全控制我们的文件名。


以下是手动生成 multipart/form-data  的代码


[javascript]


function quickTest(){

    var blob = response.getBlob();
    var filename = "峰哥牛逼.azw3";


    var metadata = {
        "method": "sendDocument",
        "chat_id": "@fengdrawbottest",
    };

    var boundary = "-----zHW0BJecQWMezOLfDmhujjAovfkaD22DJyepDlfCrqSw3aqPZH";
    var data = "";
    for (var i in metadata) {
        data += "--" + boundary + "\r\n";
        data += "Content-Disposition: form-data; name=\"" + i + "\"; \r\n\r\n" + metadata[i] + "\r\n";
    }
    data += "--" + boundary + "\r\n";
    data += "Content-Disposition: form-data; name=\"document\"; filename=\"" + filename + "\"\r\n";
    data += "Content-Type:" + "application/octet-stream" + "\r\n\r\n";
    var payload = Utilities.newBlob(data).getBytes()
        .concat(blob.getBytes())
        .concat(Utilities.newBlob("\r\n--" + boundary + "--\r\n").getBytes());
    var options = {
method : "post",
         contentType : "multipart/form-data; boundary=" + boundary,
         payload : payload,
         muteHttpExceptions: false,
    };


    UrlFetchApp.fetch("https://api.telegram.org/bot717031367:xxx/", options);



}

[/javascript]  


这样, 中文名的发送就没有问题了



星期三, 三月 20, 2019

如何使用Mediainfo 拿到影音文件的信息

mediainfo 是一个用来读取影音文件信息的软件,有GUI版也有CLI版,而且支持各种操作系统

在需要列出上百个影音文件的时候非常有用, 输出的信息可以再放到Spreadsheet 里面去筛选,当然也可以直接用脚本处理。

下图演示了用mediainfo 命令输出文件的路径和基本影音信息



把逗号改成tab再粘贴进表单里就很好处理了

你们一定好奇这个 1.txt 里面是什么东西, 这么神奇

以下是 1.txt 里面的内容

General;%CompleteName%,
Video;%Width%,%Height%,
Audio;%Format%,%BitRate%\n



--
Feng

其它博客地址

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