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

星期一, 二月 12, 2018

Wordpress on Azure Container Instance

In my last post, I tried out using Azure Container Instance to host a simple HTTP service. Today, I am going to host wordpress on it. 

Once loginned, run the following command:

az container create --name wp --image wordpress --resource-group testACI --ip-address public --port 80



You can find the full image name from docker hub: https://hub.docker.com


Use the ip address and port number from the output

Navigate it from a browser:



Choose the language and next



Now you will need to connect to a database



Let's create one, in this example, I will use a mysql database



Enter database details



Then wait



Once finished, you can see all the info of this sql server





Telnet to test the server 




To make things simple 

I disabled SSL and enable Azure service



Before connecting from wordpress to mysql, we need to create a database for wordpress. I use phpmyadmin in docker to do this:

docker run --name myadmin1 -d -e PMA_HOST=feng-test-mysql.mysql.database.azure.com -p 8070:80 phpmyadmin/phpmyadmin










Now enter the database detail to wordpress














Now my wordpress is ready to use, remember to update the URLs when a domain name is used.



--
Feng

星期六, 二月 10, 2018

Azure Container Instance Play Around

To start with Azure Container Instance, we will need to install Azure CLI tool, which is a tool to manage Azure from the command line.


I installed Azure CLI on my Mac OS EI Capitan 

brew update && brew install azure-cli

then encountered this error:



Follow the instruction to install Xcode Command Line tools



Click on Install and agree with the agreement



It will take a while to download




Run again 

brew update && brew install azure-cli

The following dependencies will be installed:
openssl, sqlite, gdbm, python3

Once finished, use the following command to login to your azure account.

az login



Follow the instruction to login from browser



Once done, you can close the browser window


Then you will be able to see your subscription from the command line



Then run the following command to create a new resource group

az group create --name testACI --location eastus



Then run 
az container create --name simpleservice --image magneticio/simpleservice:1.0.0 --resource-group testACI --ip-address public --port 3000


to create a service



You can always run the following command to see the service detail

 az container show --name simpleservice --resource-group testACI

Find ip address and port number from the output

Now try to browse it from the browser



How to host my own stuff? Leave it next time!



--
Feng

星期五, 二月 09, 2018

Kiwi Saver 的回报率到底是多少?让我来告诉你

NZ 的 Kiwi Saver 到底怎么计算的? 相信很多朋友跟我之前一样,搞不清,也不想搞清。 

今天有个同事问我这个问题,我发现我不懂, 于是上网了解了一下。 

在2012政策改变以前,Kiwi Saver 的回报率是100%. 非常高,因为你只要往你的Kiwi Saver 帐户里放一块钱,你的公司也要放一块钱进去。 所以你的回报率是100%, 而且是即时的。当然,公司在最少的情况下,只需要交你税钱工资的3%. 交满这么多,那自己放多少, 公司就不用跟着放了。 

举个例子,你的月工资是税前1万, 每个月往kiwi saver 里面放%3,也就是300块。 你的公司也得跟着放300块进去,你的回报率是100%. 但如果你放500块进去, 你的公司也只需要放300块。 这时候你的回报率就不足100%了。 有的公司会match 你放的数额, 有些公司只付minimum 的3%。

可惜的是,2012年,政策改变,当你的公司放这300块进你的kiwi saver 帐户的时候, 政府过来插一脚, 这个钱先进政府扣税, 用的ESCT来计算, 以我们上面的例子来算,这个税率是33%。 也就是,公司给的这300块,你只能收到200。所以,你每个月进kiwi saver的钱是你自己的300加公司的200, 是500块。

我同事问我,这300块是税前扣的还是税后扣的? 

答案是税后扣的。 

有些朋友就纳闷了,不是说3% of gross salary 吗? 怎么会是税后扣的?

从以下引用看的确是这样。


If you're employed, you can choose to contribute either 3%, 4% or 8% of your before-tax pay. Otherwise you can agree your contribution rate with your provider.


The employer must make KiwiSaver deductions at the default rate of 3% of the new employee's total salary or wages, unless the employee has given them notice that their contribution rate is 4% or 8%.


但是,这句话实际上只是用来说明你可以存多少钱进你的kiwi saver 帐户,而不是说这些钱是从gross salary 里面扣的。 

再举上面的例子,你一个月1万块,那你就可以最高存800进你的kiwi saver account, 而你的公司得最少付3%, 也就是300进你的kiwi saver account, 这300会被税。而如果你一个月工资只有1千,你就最多只能存80, 而你只能从你公司白拿30块。 看到差距了吧,gross salary越高,可以白拿的越多。

但你自己存进kiwi saver 帐户的钱其实是被税了吧。 因为你付的PAYE是按你总的gross salary 里面计算的, 而不是减去3%以后才计算的。 

如果你月入是1万,那年入就是12万,可以计算出你的net income 是 73.18%. 



也就是说,如果kiki saver 没有最高8%的限制,你也只能存73.18% 的 gross income 到你的kiwi saver account, 而不是100%. 因为这些钱是从你的net income里扣的。 重复一次, 这个3% of gross income 只是用来计算你想放多少钱进kiwi saver account 而已。

这3%的gross income 其实占 net income的比就不只3%了。 而是 3/73.18 = 4.1%, case by case.

所以, 不要幻想你存进kiwi saver 的钱是免税的,你存进8%的钱也不能省更多的税。因为税已经扣过了。

那到底你税前的多少钱进入了kiwi saver 呢?以月入1万为例,如果你选择的是3%的话,那你进Kiwi saver account 的钱就是300块,而这300块的净收入,其实是从 300/0.07318 = 410 块的毛收入里来的。

搞笑的是,你是用税前410块存进你的kiwi saver的(变成税后300块),但公司却只是match 你税后交的,也就是说, 公司只会存300块到你的kiwi saver account. 而且这300块还要被税,也就是变成200块。所以有些朋友会觉得公司给的这份钱是不是被税了两次。不是的, 就是这么算的。

好了,这就是kiwi saver 的各种计算方法了,想了解ESCT算法的话可以看这里:

 

--
Feng

星期四, 二月 08, 2018

用手机上的Youtube APP投屏到小米盒子上的Youtube TV, 可遥控

用手机上的Youtube控制小米盒子上的Youtube, 这个功能真的很好, 一这下要分享. 这个功能其实早就存在了, 但我好久后才注意到.


--
Feng

庆祝Youtube Channel 获得首次100个订阅

哈哈, 昨天收到谷歌邮件通知得到100个订阅, 非常开心. 

这个月发了十几个视频, 虽然每个视频的制作都要花我好几个小时的时间, 但是看到我的视频被看了几千次, 网友看视频的时候远远超过我制作它们的时间的时候,我就觉得我花的每一分钟都非常值得.



一个月得到100个订阅, 感觉还是很有成就感的. 

这一百个是一个里程碑, 代表了网友对我的支持, 来之不易, 是对我今后继续分享知识最大的动力.

昨天刚过100, 今天就到153了, 后面这53来得有点容易 :) 
last 28 days 的曲线也非常漂亮, 基本是稳步增长.





--
Feng

Use Local network to access internet when VPN is connected

I recently worked a few times at home using company VPN. Once connected with VPN, I remote desktop to my computer in my office to work. The VPN speed is unstable, sometimes slow, sometimes all right. I would like to only use remote desktop through VPN. All other internet access from my local network. There are problems on both Mac os and Windows, and their problems are different. 

I first tried with mac os. I have mac os EI Capitan, which is not the latest OS Sierra. 

The connection to the VPN is totally fine. But after connecting, I still couldn't access my remote desktop. I couldn't even ping my PC in the office. 

I checked my VPN IP address and found that it's different from my office LAN IP. The VPN adapter has an IP address of 172.16.1.118, but my office computer has an IP address of 192.168.0.50. But this wasn't the problem. If you are trying to fix your VPN IP, stop it.

I checked my route table with the command netstat -nr and noticed that there was no routing route to the VPN network. 

I then added a static route manually using the following command:

sudo route -n add 192.168.0.0/24 172.16.1.1

This did all the trick for me. 

Now I can remote desktop to my office PC, and my local network is used to access the internet.


whereas on Windows 10, it's a different situation. VPN connection on Windows 10 is straightforward. Windows can detect the VPN protocol type, you don't have to enter if you don't know. 

Once connected, I could remote into my office computer without any problem. But my internet became very slow, as all my traffic went to the VPN.  I found out this by trace route.


And interestingly, there are two routes for defaults. Obviously, the second one is used.


This is not what I want, I need to change my routing table to route all other traffic (outside 192.168.0.1 - 192.168.0.254 range) to my local gateway.

I did this by using the following command:

route delete 0.0.0.0
route add 192.168.0.0 mask 255.255.255.0 172.16.1.118
route add 0.0.0.0 mask 0.0.0.0 172.16.1.118

In theory, the above command should resolve the problem. But It didn't. I couldn't access any internet anymore. I could still access the VPN network.

The default route was not working. 

Now my routing table looked like:


The routing table is perfect, but it didn't work as expected.

The one more trick to do is to disable  Use default gateway on remote network






You need to do this for both ipv4 and ipv6. 

Once this is done, reconnect to the VPN. This time, your routing table will not be changed by VPN. 

But the behavior will become the same as mac os.  I couldn't access my office network by default. I needed to add a static route to access my office network.

I did these commands again

route add 192.168.0.0 mask 255.255.255.0 172.16.1.118


Now, all done. I can access my office PC through remote desktop. And all my other traffic to the internet will still go through my local network.


-
Feng

星期二, 二月 06, 2018

被微软One Drive 坑了

One Drive 其实好久没用了. 因为大多数照片在Google Photo里面, 只有一年左右的照片在OneDrive 里. 今天突然想找那一年的照片, 于是登于一看,吓了一跳...



忘了截图了, 上面那张图是网上找的, 日期不对, 反正我的就是显示明天就过期, 我X. 连一点思考的时间都不给我.

因为我之前Unfroze过, 当初登录的时候没有太认真看, 直接点unfroze 就不理了. 现在微软不给机会了, 除了花钱买它的服务, 不买? 明天就删你的照片. 我哭!!

好吧, 大丈夫能屈更能缩. 付款.

才不! 


这里有个office 365 的 plan, 可以试用一个月.  试用就试用吧, 被逼试用... 需要信用卡


注册完后, 得到 1T空间



空间容量比百度云差远了, 虽然我也不用百度云放照片. 

然后, 赶紧的, 取消, 取消后还是可以试用了一个月的. 不会自动续费就是.




哈, 还能得到一个office的key, 能用多久不知道, 还没试. 

然后下载one drive 开始同步






等我同步完了我就跟one drive say goodbye



下一次就是得想办法把这些照片搞到 Google Photo 上去, 还没想好怎么搞. Google Photo好像没有mac 版. 以前的picaza 肯定是不能再用了. 

应该可以用google drive client 搞定, 等我onedrive 同步完再说吧.











--
Feng

星期五, 二月 02, 2018

落枕后遗症?背痛

之前有两次没睡好,连续两周落枕。第二次落枕好后,右后背开始隐隐作痛。 本来以为过几天就好了,可是现在都有几周了,还没见好。抬手从肩膀过去揉的时候发现,手臂肌肉很酸,像干过重活第二天那种酸涨无力的感觉。 我这是怎么了? 感觉想颈椎病,又像肌肉炎症。一直没有时间去看医生,我得赶紧去看看了。



--
Feng

Wordpress postie 使用HTML版的邮件

原来是要在这里设置



只是设置完后变这样了




​人家BLOGGER是这样的



不过图片顺序估计这回能对。



--
Feng

小米盒子3增强版安装谷歌框架,Play商店,官方Youtube,可登录


有个朋友说搞了一天没搞出来,我看了下,果然有点难搞,也搞了我两个小时. 其实也不难,只要找到窍门.


--
Feng

免ROOT,免谷歌,小米盒子安装Youtube APP, 可登录,可遥控,可中文搜索

这个方法不需要ROOT,也不需要安装谷歌框架,非常简单, 而且也可以登录你自己的帐号, 可以用遥控器操作, 中文搜索也没有问题.


--
Feng

替换小米盒子广告墙桌面去除开机准备桌面广告

​需ROOT, 替换小米原来的桌面,换成更简约的桌面,原来的小米桌面依然保留, 可以随时进入 (就是打开一个APP).

https://youtu.be/c_RRNyq-HKc

峰哥出品







--
Feng
​​


其它博客地址

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