2020年8月27日 星期四

bash 的載入順序

打開bash後,要編寫變數可以寫在 ~/.bash_profile 或 ~/.bashrc。

也許還聽過 /etc/profile

位置不同但效果相同,有想過這些順序和情境到底怎麼使用嗎?

  • /etc/profile
  • ~/.bash_profile
  • ~/.bashrc
  • ~/.bash_login
  • ~/.profile
  • ~/.bash_logout
// 一般順序
execute /etc/profile
IF ~/.bash_profile exists THEN
    execute ~/.bash_profile
ELSE
    IF ~/.bash_login exist THEN
        execute ~/.bash_login
    ELSE
        IF ~/.profile exist THEN
            execute ~/.profile
        END IF
    END IF
END IF
// 互動登出
IF ~/.bash_logout exists THEN
    execute ~/.bash_logout
END IF
//互動式非登入
IF ~/.bashrc exists THEN
    execute ~/.bashrc
END IF


參考文章在此

Execution sequence for .bash_profile, .bashrc, .bash_login, .profile and .bash_logout

 https://www.thegeekstuff.com/2008/10/execution-sequence-for-bash_profile-bashrc-bash_login-profile-and-bash_logout/

2020年6月30日 星期二

Enable shutdown button on windows logon screen

For Windows 7 & 10 Regedit \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System shutdownwithoutlogon 1: Enable 0: Disable

2020年6月29日 星期一

[Git] unable to get local issuer certificate 解決

假設 git pull 時遇到

Cloning into 'project'...

fatal: unable to access 'https://myproject.mattmytech.com:31001/project/project.git/': SSL certificate problem: unable to get local issuer certificate



有一個簡單但不安全的作法就是暫時關掉 HTTPS SSL 的檢查
git config --global http.sslVerify false


如果不要全域就拿掉 global
git config http.sslVerify false


再次 pull code 就成功了

但要記得你把 sslVerify 關了喔!

2020年6月18日 星期四

不建議在 Windows 10 中關閉固態硬碟的磁碟重組(Trim)

在 Windows 10,相信大部份使用者是使用 SSD (固態硬碟)。
為了避免不必要的操作 SSD。可以照下列步驟關閉「磁碟重組」這項功能。
但是 Windows 10 系統會自動判斷磁碟硬體是固態硬碟或傳統硬碟,若是固態硬碟所執行的為 Trim 指令,傳統機械硬碟才是 Defrag 重組。

根據狐大的介紹,我們還是不要去動這些設定比較好!
參考連結:https://www.fox-saying.com/blog/post/47402717





1. 在開始的地方輸入「重組」就能快速找到系統內建的重組工具




2. 選擇每個「固態硬碟」並點選右下側的變更設定




3. 取消勾選「依排程執行」



所以結論就是:固態硬碟就讓 Windows 10 自動最佳化。傳統機械硬碟就由使用者自行決定是否要自動重組。

2020年6月1日 星期一

移除Win10檔案總管中 [3D物件][文件][桌面][音樂] 那些不想看到的資料夾

移除Win10檔案總管中 [3D物件][文件][桌面][音樂] 那些不想看到的資料夾

參考1 https://zhuanlan.zhihu.com/p/25942015
參考2 https://www.howtogeek.com/331361/how-to-remove-the-3d-objects-folder-from-this-pc-on-windows-10/

// Remove 64
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]
[-HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]

// Restore 64
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]

// Remove 32
Windows Registry Editor Version 5.00
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]

// Restore 32
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}]

最後將檔案存成 .reg 即可

2020年4月21日 星期二

[Git] 如何避免每Git每次都問帳號密碼 How to avoid always asking username

也許你的工作站帳號因為更新密碼,導致之後 git 操作都會重新問帳號密碼

// 透過下行重置憑證設定
git config --unset credential.helper


// 重新設定憑證記憶方式
git config --unset credential.helper store


接著進行一次需要帳密的操作後,帳號密碼會被以「明碼」的方式存在 ~/.git-credentials 檔案內,例如:
$ cat  ~/.git-credentials
https://matt:mypassword@myProject.matt.com:32100


這是很危險的!
如果你的作業系統是 Windows 且有裝 TortoiseGit 工具的話,可以參考我另一篇文章
[Git] 在 TortoiseGit 裡記憶專案密碼 

然後再去重置憑證設定並檢視 ~/.git-credentials 檔案是否仍放有明碼,並將它刪除。


最後在 ~/.gitconfig 裡會出現
[credential]
        helper = manager
        username = matt


manager 代表使用 windows 的管理工具


2020年4月20日 星期一

Git 重設驗證密碼 Reset credential



當我工作站的密碼變更後
When workstation password changed

// 因驗證操作錯誤
// access denied
$ git pull
remote: HTTP Basic: Access denied;
fatal: Authentication failed for 'https://my-project.com:34567/project/project.git/'

// 重新設定驗證
// reset credential
$ git config --system --unset credential.helper

2020年3月26日 星期四

筆電的觸控板無法使用 Touchpad not working

這問題困擾我一兩年了。

我有一臺Win10的筆電,但它的觸控板時常無反應,有時候心情好開機後就有指標,有時候沒有指標;有時候休眠後重啟就有指標;有時候莫名奇妙就有指標。driver也重裝過,能否使用根本是碰運氣。但我又不想為了這事重灌,畢竟系統設定重來很麻煩。

不知道哪看來的
連按

Fn6 + Fn9 + Fn12 + Fn5

就可以出現滑鼠指標了!傑克這真是太神奇了!


神奇的影片底佳
https://www.youtube.com/watch?v=l0qhOGofV_c

2019年7月23日 星期二

WebsStorm display NPM tab

The Tab [NPM] was gone, where can we show/display it?

It is easy. Right click on package.json, then choose [Show npm Scripts]


2019年6月18日 星期二

Synology NAS 開機執行特定 Script 於 rc.d 資料夾下

想在 Synology NAS 開機時執行特定 Script

1. 將寫好的 script 放在 /usr/local/etc/rc.d/ 之,檔案名稱一定要有 .sh 為結尾(ex. your_script.sh)

2. 變更權限 sudo chomd 755 your_script.sh

3. script 內容必須包含 start 和 stop 等參數,範例如下

#!/bin/sh
#
# Put this file in /usr/local/etc/rc.d/your_script.sh

case "$1" in
stop)
 echo "[Stop]"
 # do something here"
 ;;
start) 
 echo "[Start]"
 sudo "/volume1/matt/your_script.sh"
 ;;
restart)
 echo "[Restart]"
 $0 stop
 sleep 1
 $0 start
 ;; 
status)
 ps | grep laravel_queue_listen | grep -v grep
 ;;
*)
 echo "usage: $0 { start | stop | restart | status}" >&2
        exit 1
        ;;
esac
之後你可以透過手動 ./your_script.sh start|stop|restart 來操作。

在系統開機時也會自動執行 ./your_script.sh start

可參考官方文件 [Run Scripts When the System Boots]
https://originhelp.synology.com/developer-guide/integrate_dsm/run_with_system_boot.html