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

星期一, 二月 26, 2018

Download blocked attachment from Gmail

Gmail has an awesome feature of scanning attachment before downloading.  But sometimes, it gives a false negative result. 


If you have an attachment which you know that it is safe to download, but Gmail doesn't allow it, what can you do?


Go to the upright corner of Gmail body and click the triangle icon then click "Show original"



Then click "Download Original"




The file you downloaded will be a txt file

rename the downloaded file to original_msg.eml

then double click it to open with outlook (you must have outlook installed).



Now you can then download it from outlook.


If you have a small file and don't have security concern

you can open the txt file and past the base64 code to online base64 converter such as 


then download the binary from there.

This way, you don't need to have outlook.




--
Feng

星期五, 二月 23, 2018

真的搞懂安卓刷机

这篇文章说的刷机是指把第三方安卓系统刷入安卓设备。

首先回答几个问题

刷机一定要安装第三方Recover吗?
刷机一定要解锁Boot Loader吗?
刷机一定要Root吗?

回答是: 是,也不是

你说"靠, 这跟没说一样嘛!"

就像你说,明天会下雨还是会出太阳,然后我说,可能下雨,也可能出太阳。那跟没说一样。
但我加个如果, 如果今天下雨,明天就下雨,今天出太阳,明天也出太阳, 那这个答案就清晰了。


如果你答错了, 请往下看

换一下问法

刷机最好要安装第三方Recover吗?是!
刷机最好要解锁Boot Loader吗?是!
刷机最好要Root吗?是!



再换一下问法

有了第三方recover一定能刷机吗? 是
解锁了Boot Loader 一定能刷机吗? 是
ROOT了一定能刷机吗? 是,也不是



关于刷机,在回答上面三个问题之前, 也有很多的如果。

唯一确定的是, 如果你已经有了第三方Recover, 如 TWRP, 那就不要问那么多了, 直接去刷吧,刷坏了我不负责。不过刷坏的可能性很低。如果你有安装windows的经验,你可以把TWRP想成带windows安装盘的光驱,你可以随时启动它安装windows. 就算装坏了再装一次就是了。TWRP提供很多方法让你上传rom, 你可以用ADB, 也可以直接用SD卡, 没有SD卡插槽也没有关系,你可以直接mount U盘。 

你可以把TWRP想成手机里的一个光驱, 那你就可以把安卓系统想成手机里的硬盘上的windows.  那我们再聊聊Boot Loader, boot loader 就像PC机里的BIOS, 如果你用过BIOS, 你可能知道在BIOS里面设置启动顺序, 可以是光驱先启动,也可以是硬盘先启动。安卓手机也可以设置,只不过方式不同。 安卓手机如果想设备成光驱启动,哦不, Recovery启动,不是点DEL进BIOS, 而是通过电源,音量等几个组合键直接进入recovery. 要进入Boot loader 本身也是用组合键。

所以到这里Recovery 和 boot loader的区别就明显了, 手机启动的时候,先进boot loader, boot loader 决定是从光驱(RECOVERY  分区)启动,还是从硬盘(系统分区)启动。 Boot loader 是最先进的, 而recovery 和 安卓系统是同一个级别的东西,在不同的分区里。 Boot loader 其实有几个启动阶段,这里不深入。

如果电脑硬盘里的系统坏了,我们一般就是用光驱直接重装了。安卓也一样,直接从recovery 启动,然后重装就行了,只是在安卓里面叫刷机。

但是Recovery 可没有我们PC里的光驱那么友好. Recovery 系统被厂家做了限制,就是只认厂家的官方ROM。 就像你电脑的光驱只认windows 的盘, 不认linux 的盘一样, 你只能装官方的系统,不能装别人家的。所以这时,第三方recovery 出现了。

然后回到我们的第一个问题, 刷机一定要装第三方Recovery 吗?   不是的,第三个Recovery 不是刷机的唯一方式。 其实 Boot Loader 也是可以刷机的, 这点和BIOS不一样。当你的手机的Recovery 分区也损坏的时候怎么办? 这时候就轮到 Fastboot 出场了。 Fastboot 是电脑上的命令行工具,它可以在手机在boot loader 模式的时候跟手机交互。 所以fastboot 常常用来救砖。 也就是你的手机不能进系统, 也不能进recovery 了, 这时候还有得救, 用fastboot 可以把原厂的recovery 刷回去, 再用原厂的recovery 把原厂系统刷回去,也可以直接用fastboot 把原厂系统直接刷回去。 Fastboot 就像PC里的克隆工具, 可以把一个硬盘镜像直接克隆到指定分区。

那问题来了,我既然可以用fastboot 刷系统, 我要Recovery 干嘛?

这个问题不好回答。 如果你说的是刷官方升级系统, 那只是为了方便, fastboot 需要在电脑上用, 要求手机和电脑用USB连起来, 操作比较麻烦, 所以做为最后一道防线。Recovery 的话,所有东西只需要一台手机本身就能完成, 上网,下载ROM, 放在SD卡,进入Recovery 刷机, 整个过程就没电脑什么事。

如果是说刷第三方系统, 那问题又来了, 刚才说过,原厂Recover有限制,不让刷第三方系统, 那就用Boot Loader呗,反正你说也能刷。 不行,因为坑爹的Boot Loader也有限制, 也不让刷第三方镜像, 这就是大名顶顶的 Boot Loader Lock. 所以因为Boot Loader 无法 unlock, 所以还是需要第三方Recovery. 而且解锁boot loader 的时候, 手机里的东西会不见。

所以回到刚才的第二个问题, 刷机一定要解锁Boot Loader吗?你可能说不要,因为我刚说过可以用第三方Recovery来刷,这好像没Boot loader 什么事。 这问题也不好回答, 因为,你的第三方Boot loader 怎么来的呀?不是凭空出现的呀,通常是用Boot loader 刷进去的呀。不解锁Boot loader, 怎么刷第三方recovery 呢? 但答案也不是要, 因为的确有的机子可以在boot loader 锁住的情况下刷入第三方recovery,这就是机By机的了。 而且如果是联发科MTK的手机,可以直接用工具 SP flash tool从电脑上刷机。 三星没有boot loader, 用的是download 模式, 没有锁, 可以直接从电脑上用Odin刷。所以我说的答案是, 是也不是, case by case.


那第三个问题, 刷机一定要Root吗? 刚才说了这么多, 好像没ROOT什么事呀, 那答案是否喽? 不能这么说, 因为有些坑爹的手机,一定要root 了以后才能刷第三方recovery, 比如摩托罗拉。 有些手机, boot loader 不能解锁, 不能用fastboot 刷第三方recovery, 但却可以root. Root了以后却可以在开机的情况下通过软件刷入第三方recovery (比如Rom Manager by Koush), 这样root 就很关健了。所以有些机子,一定要root, 大部分机子,没root 啥事。


所以

刷机最好要安装第三方Recover吗?是!
刷机最好要解锁Boot Loader吗?是!
刷机最好要Root吗?是!


如果你的机子解锁了boot loader, 又安装了第三方recovery, 还root了, 完美,去刷吧。


--
Feng

星期三, 二月 21, 2018

真不省心, 没个眼镜能用过半年








Run Docker and Virtualbox at the same time

I just installed Virtual box and tried to install xp on it. But my windows 10 crashed every time I loaded the XP ISO file.

I then found that I could not run Hyper-V and Virtualbox at the same time, because Hyper-V is type 1 visualization, whereas Virtualbox is type 2.

I have docker running on my machine, I cannot disable Hyper-v. 

There is a solution for it. 

Docker toolbox, docker toolbox uses VirtualBox for visualization. 

I am not going to do it, will stick to hyper-v for now.


--
Feng

Hyper V VM with 16:9 resolution

I have a windows XP VM installed in Hyper V.  I would like to record a session within the VM, but I couldn't set the screen resolution to 1080x720. 

I then enabled remote desktop in the VM.





Then everything works perfectly. 









I have to run the screen recorder from the host machine. When I ran it within the VM, the mouse doesn't work well.

I am trying to attach my android phone to the VM, but failed. 

I also tried the remote desktop Pnp device, didn't help.



Comparing to VMWare Workstation, Hyper-V gave me a lot of troubles.  I would rather leave it for now, I am going back to virtual box.


--
Feng

Vysor black screen on mac mini os with inter hd 3000 graphic card

When I tried to install vysor chrome extension, I was told that vysor is not supported by this computer.

I then download vysor mac version. It worked well, except the mirror screen on the mac was black. I could still control from mac and take screenshots.

I checked the chrome extension again and noticed that webgl is required for vysor. I then tested webgl on both safari and chrome.




Both of them were not working.

I tried to enable webGL from safari's develop menu, but "enable webGL" is not there.





I also enabled webgl from chrome's settings, but it didn't help.

I thought my graphics card may not support webGL.

Then I found a page saying that Intel HD 3000 is blacklist by chrome on mac. 

Then I used the following command to launch chrome.

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --ignore-gpu-blacklist

Great thing suddenly happened.




I then navigated to the vysor extension again, and this time, I could install it.


I installed vysoy chrome extension and started. It started my mac stand along version. But the funny thing was that, it worked.



That's awesome, I then deleted the mac version and reinstall the chrome version. The Chrome version worked too.

I still haven't found the way to enable webGL on safari, but I don't need to worry about it for now.



--
Feng

星期六, 二月 17, 2018

Access your angular2 dev environment from VPN without remote desktop

Sometimes, Remote desktop is quite slow, access angular2 directory from a browser may be better.

By default, ng serve only bind to 127.0.0.1, which means the http port can only be accessed by local machine.

To allow connection from other machines, use the following command to allow all connections.
ng serve --host 0.0.0.0

Now, you will be able to access your angular2 app using ip address (e.g. 192.168.0.50:4200) from another machine. But it may not work properly. because your debug settings has all the config pointing to localhost,  your anguar2 app will make api calls to your backend using localhost rather than your ip address. To solve this problem, we can use Fiddler.

Go to Fiddler's Tools->Hosts, map localhost to your dev machine's ip address








Make sure you enable capturing




And also make sure your proxy setting doesn't bypass localhost









That's all, you are ready to go. Use localhost:4200 to access your dev angular2 app from another PC.  Because all HTTP traffic will go through fiddler, fiddler will forward all localhost traffic to your dev machine including api calls.

I will show you how to edit angular2 source code without a remote desktop.


--
Feng

星期五, 二月 16, 2018

Quickly install telnet on windows 10

We used to install telnet from control panel "features". 

In Windows 10, a quick way is executing following command in an admin cmd.

dism /online /Enable-Feature /FeatureName:TelnetClient

But it does require restarting the pc. 

A quicker way is just copying the telnet.exe from another machine. It will be efficient if you are just using it to check whether a port is opened.


--
Feng

Finally Moved my wordpress website to Azure container instance

When I initially built my website, I hosted on my own mac at home. I have fibre broadband at home, when I tested the speed, it was quite good. 

There were a few problems of hosing at home:

1. Dynamic ip address (i think that I have a static ip)
2. My ISP ban port 80
3. No data backup


For me, problem number 2 is a real problem. Although I never ask my ISP for a static IP, I don't see my ip address changed. So number 1 is always not a problem, although I also set a DDNS in my router. You have to pay extra money if you want to use your own domain for DDNS.

Problem number 3 is a little problem. I can easily write a script to do regular backup into dropbox folder. 

I don't want to use other ports than 80 for my website, that looks unprofessional. I was so lazy to move my website to the cloud. So that I map my domain to an Azure VM. Then I ran a fiddler in that VM and use VM's host feature to remap my public domain to ddns's domain. 



This works very well. My VM has a public ip address, and port 80 is available. All the traffic to my website will go to my VM first. Then fiddler as a reverse proxy, forward all the traffic to my home mac. 

This way, it doesn't save me any money for hosting. Because I have to run a VM. And all the traffic goes through my VM, I also need to pay for the bandwidth usage as well. I don't get much benefit by running host from home. But I have enough free credit for my Azure account, who cares.


I didn't think about moving my host to the cloud until one day I failed to open my website. Fiddler through an error of timeout when connecting to my home mac. I then noticed that I couldn't rely on my ISP to provide a good service for hosting at home.


Then I started thinking about moving my host to my Azure VM. This is straightforward, my VM has been there for years, and I rarely use it. And this is easy to do. I can install docker on the VM then start new mysql and wordpress container. I will only need to import my local mysql data to the new mysql container and also copy over my wp-content folder. 

By looking around, I noticed that Linux VM is cheaper than windows VM. Then I was thinking about creating a Linux VM instead. Yes, I have enough free credit to use, but once I started doing a thing, I would like to do it properly. I can use the remaining credit to do something else, a download server, a VPN, a web proxy whatever.

Then I realized that MS Azure now has Azure Container Instance, which is even cheaper than Linux VM. Then I decided to use it. I am using Azure mysql db for my database, I can customize my wordpress container to be able to host mysql as well, but for a better backup service, I use a separate mysql db, which will cost me a little bit more.  But the total cost will be still less than a windows VM.

Now, my website is hosted on ACI, I use the sourtheast asia resource group (which is more expensive than east us). The speed is all right.
















--
Feng


星期四, 二月 15, 2018

Apply your local wordpress changes to Azure Container Instance

In my last posts, I introduce how to create wordpress in azure container instance. I also demonstrated how to migrate your local mysql database to Azure mysql.

But migrating database will not affect your images in your gallery, and all your customzied themes and plugins are still not yet live.





You can create a changed docker image and upload to auzre. 

But in this case, docker commit does not work because /var/www/html is a volumn.

You can find out which volumn is used by the container    docker inspect -f '{{ .Mounts }}' containerid 

You can start a new container to mount to the volumn and also connect to azure mysql server to test the volumn.  

docker run --name some-wordpress -p 8011:80 -e WORDPRESS_DB_HOST=feng-test-mysql.mysql.database.azure.com \
 --mount source=3597ca843600a38db43fe553a5611d5c80c8365243a5f596236aa7bf95de7d91,target=/var/www/html \
    -e WORDPRESS_DB_USER=fennng@feng-test-mysql -e WORDPRESS_DB_PASSWORD=password  wordpress


The solution is putting your wordpress content on azure file share then mount your file share as a wordpress volume.

Firstly, let's create a storage account.


# Change these four parameters as needed
ACI_PERS_RESOURCE_GROUP=testACI
ACI_PERS_STORAGE_ACCOUNT_NAME=testacistorage$RANDOM
ACI_PERS_LOCATION=eastus
ACI_PERS_SHARE_NAME=testacishare

# Create the storage account with the parameters
az storage account create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --location $ACI_PERS_LOCATION \
    --sku Standard_LRS


# Export the connection string as an environment variable. The following 'az storage share create' command
# references this environment variable when creating the Azure file share.
export AZURE_STORAGE_CONNECTION_STRING=`az storage account show-connection-string --resource-group $ACI_PERS_RESOURCE_GROUP --name $ACI_PERS_STORAGE_ACCOUNT_NAME --output tsv`

# Create the file share
az storage share create -n $ACI_PERS_SHARE_NAME

STORAGE_ACCOUNT=$(az storage account list --resource-group $ACI_PERS_RESOURCE_GROUP --query "[?contains(name,'$ACI_PERS_STORAGE_ACCOUNT_NAME')].[name]" --output tsv)

echo $STORAGE_ACCOUNT

STORAGE_KEY=$(az storage account keys list --resource-group $ACI_PERS_RESOURCE_GROUP --account-name $STORAGE_ACCOUNT --query "[0].value" --output tsv)
echo $STORAGE_KEY

Now, we have a storage share ready. 







You can use  aci-hellofilesto manage this volume 

az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name hellofiles \
    --image seanmckenna/aci-hellofiles \
    --ip-address Public \
    --ports 80 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /aci/logs/




But you can't do much from here

You can also login to azure portal to manage it




Or use Azure Storage Explorer



Use the connection string in  AZURE_STORAGE_CONNECTION_STRING variable






This tool support uploading folders.





We will let wordpress to create wordpress for us.

Let's recreate a wordpress container 

 az container delete --name wp -g testACI


az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name wp\
    --image wordpress \
    -e WORDPRESS_DB_HOST=feng-test-mysql.mysql.database.azure.com\
     WORDPRESS_DB_USER=fennng@feng-test-mysql\
     WORDPRESS_DB_PASSWORD=password\
    --ip-address Public \
    --ports 80 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /var/www/html


Now, you should have your new wordpress working. Check your file share, you can see all the wordpress files generated by the container.




But this is the original wordpress files. 

You need to upload your local wp-content folder to overwrite the default one.


Now, let's copy the wp-content file out to current directory

docker cp wp:/var/www/html/wp-content .
you can zip it to move to usb if needed.
zip -r wp-content.zip wp-content/

Then you can upload the whole folder to Azure




It will take a long time to upload a big folder.


It can be a good idea to create a container to unzip the file, make sure you backup and delete the wp-config.php file on the file share before doing this.

We will create an ubuntu container with ssh access.

az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name ssh\
    --image rastasheep/ubuntu-sshd \
    --ip-address Public \
    --ports 22\
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /root


now ssh to it using it's ip address.

Note that you are in the risk of attacking.

So, the first thing to is changing the password, do this carefully, otherwise, you will not be able to login again. (you can still easily recreate the container)
passwd

once changed, logout and login again. It may take a minute before the new password works.

Now, you should upload the wp-content.zip to the volume using azure portal or azure storage explorer. You can also use psftp if you want.

Once uploaded

in your ssh shell, run apt-get update && apt-get unzip
then run unzip wp-content.zip
Now, type A to agree to replace all the files.

Wait for a few minutes.

Now, upload your wp-config.php file back to the server. 

And then delete your ssh server.
az contain delete -n ssh -g testACI


Login to your wordpress, you plugins are back, but they are inactive. You have to reactive them.





You are done.





--
Feng

其它博客地址

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