2018年3月25日 星期日

配置react -native環境

公司的新專案需要用到react-Native

上網找教學影片

後盾人孫老師錄的

整個過程非常順利,只遇到兩個小坑

1.我java安裝成第10版不支援,所以就補安裝了第8版
這邊教你怎設定環境變量
http://www.ituring.com.cn/article/207395
2.android SDK有條款沒接受
https://stackoverflow.com/questions/39760172/you-have-not-accepted-the-license-agreements-of-the-following-sdk-components

稍微注意的點:
3.文件路徑要轉譯一下變成\\雙斜線(影片有提)
4.安裝android SDK我是整個studio都載下來(跟影片不同),下一步下一步這樣安裝完成


然後設置環境變量不需要重新開機,powershell重開就行了

2018年3月18日 星期日

在centos7裡面安裝nginx+php+mysql

話不多說,直接先參考教學
http://www.smalljacky.com/linux/centos/centos7-install-setup-nginx-mariadb-php-phpmyadmin-lemp/
其餘遇到的問題列在下面


[root@www ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
文章裡面的這一條會幫你建好/etc/yum.repos.d/nginx.repo這個檔案

重點是版本要對,不然會一直安裝失敗


遇到的第一個問題就是

Error: Package: nginx-1.12.2-1.el6.ngx.x86_64 (nginx)

           Requires: libpcre.so.0()(64bit)
所以安裝失敗



解決方法參考至:

This happened to me. I updated my EPEL repository with

yum update epel-release

yum install nginx

https://serverfault.com/questions/620684/cant-install-nginx-using-epel-repo-on-centos-7-64bit
--> Finished Dependency Resolution

然後就成功了
遇到的第二個問題是

systemctl start nginx

Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" f

因為port號被用走了

nginx: [emerg] bind() to 0.0.0.0:8843 failed (98: Address already in use)


解決方法參考至:

https://serverfault.com/questions/565339/nginx-fails-to-stop-and-nginx-pid-is-missing 之後80port就正常啟動了 遇到的第三個問題
改了設定檔要換port重啟的時候

 [emerg] bind() to 0.0.0.0:8843 failed (13: Permission denied)


此時就開始關心是不是防火牆的關係了,就開始到處找文章
iptables -I INPUT -p tcp --dport 8843 -j ACCEPT
然後就不小心開錯port了,要怎刪掉?

列出所有規則,前面加上行號
  • iptables -L INPUT -n --line-numbers
要刪除某一行的規則
  • iptables -D INPUT 1 # 若只有上述那行,那就是 1
  • iptables -D INPUT 3 # 若有多行,只要刪除第三行
參考至:https://blog.longwin.com.tw/2016/07/iptables-delete-rule-by-line-2016/
然後開了還是不行,結果是selinux 的問題,要關掉....
或者加port進去該軟體
http://n.sfs.tw/mymedia/index/10393
解決方法參考至:
http://blog.51cto.com/liuqh/1839889
最後終於正常重啟了QQ

第4個問題mariadb安裝完之後,改port號
同樣參考至:http://n.sfs.tw/mymedia/index/10393

第5個問題
改完port號之後遠端不能登入
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION

參考至:
https://stackoverflow.com/questions/25777943/failed-to-connect-to-mysql-at-127-0-0-13306-with-user-root-access-denied-for-us
https://stackoverflow.com/questions/8348506/grant-remote-access-of-mysql-database-from-any-ip-address


再來又遇到 /var/run/php-fpm/php-fpm.sock failed (2: No such file or directory)
重開服務,解決
systemctl restart php-fpm

2018年3月14日 星期三

遠端編輯VSC

因為內測環境要連遠端,不是建置在本機上面,原因其實我也不是很清楚,大概是為了省電吧(平常下班要自己電腦要關機),共用的不用關,也可能是遠端機子比較好,環境跟正式的一樣,我本機也不用那麻煩再安裝一次laravel,大概是諸如此類的原因,我需要對遠端的程式碼進行coding

於是找到
http://www.cnblogs.com/learn21cn/p/6189023.html
https://spin.atomicobject.com/2017/12/18/remote-vscode-file-editing/

以下linux作業系統就是我的遠端
在linux上裝rmate
在vsc上裝Remote VSCode擴展
自訂一下ssh config
就可以直接在命令列上打入
C:\Users\xin02> ssh kestanley
root@10.10.10.32's password:****
來登入linux
然後
rmate my.text 就可以在VSC打開囉

但是!!!
這種方法不是我想要的那種,這一次只能開一個檔案,我希望他跟平常一樣在旁邊的explorer列出所有的文件阿~~~


於是乎放棄上面這種方法
改用
https://github.com/liximomo/vscode-sftp
SFTP這個擴展就大功告成了,繞了好大一圈阿
{
"protocol": "sftp",
"context":"D:\\remote",
"host": "10.10.10.32",
"port":22,
"username": "root",
"password":"****",
"ignore": [
".vscode",
".git",
".DS_Store",
".svn"
],
"uploadOnSave": true,
"remotePath": "/usr/share/nginx/html/"
}

2018年3月13日 星期二

vsc裝 php intelliSense擴展


https://github.com/Microsoft/vscode/issues/13356

Added in Settings:
{
    "php.executablePath": "C:\\PHP_7\\php.exe",
    "php.validate.executablePath": "C:\\PHP_7\\php.exe",
    ...
}

2018年3月12日 星期一

程式著作權相關

請問在程式前的著作權和授權宣告要怎麼寫
https://www.openfoundry.org/tw/forum?func=view&catid=10&id=345

想寫出造福世界的程式?你得先通過著作權這關!
https://buzzorange.com/techorange/2013/07/31/what-coders-should-know-about-copyright-licensing/

關於程式碼的著作權
https://tw.answers.yahoo.com/question/index?qid=20110603000010KK03315

授權流言終結者#3:jQuery 授權的分析與探討
https://www.openfoundry.org/enterprise-application/8680

小數點運算誤差

電腦對於小數點運算組是有誤差

浮点运算结果出现误差原因分析及解决方案
http://www.cnblogs.com/xiongpq/archive/2010/05/17/1737747.html
使用浮點數最最基本的觀念
http://blog.dcview.com/article.php?a=VmhQNVY%2BCzo%3D
php踩過的那些坑
https://kknews.cc/zh-tw/finance/y86vrrj.html