2021年6月9日 星期三

[Python] 將 ipynb 轉成 python

好吧,其實好像沒有直接轉成功。

先安裝套件

$ pip install ipython
$ pip install nbconvert

轉換單一檔案

$ ipython nbconvert abc.py abc.ipynb

reference: https://medium.com/@researchplex/the-easiest-way-to-convert-jupyter-ipynb-to-python-py-912e39f16917

2021年6月2日 星期三

[Wordpress] 幾個坑

 最近在轉換網站,遇到幾個坑,紀錄一下。

1. plugin 無法背景更新,或是一些 AJAX 的程式不能順利執行。查了一下 /var/log/apache2/error.log 看到一些神奇的錯誤訊息 " AH01630 Client Denied by Server Configuration: ... wp-admin/admin-ajax.php",解決方法是修改 Apache 的目錄設定,把 AllowOverride All 改成 AllowOverride None

reference: https://linux.101hacks.com/unix/client-denied-by-server-configuration/


2. 在執行 FTP 相關指令時失敗,錯誤訊息如

PHP Warning:  ftp_nlist() expects parameter 1 to be resource, null given...
PHP Warning:  ftp_pwd() expects parameter 1 to be resource, null given in...
PHP Warning:  ftp_rmdir() expects parameter 1 to be resource, null given in...

要修改 wp-config.php,將 define('FS_METHOD','direct'); 放在 require_once ABSPATH . 'wp-settings.php'; 之前就可以了。

reference: https://wordpress.stackexchange.com/questions/365737/ftp-nlist-and-ftp-pwd-warnings


3. 今天在刪除使用者時,發現有 wp cli 這樣的指令列,不過在安裝完畢之後需要先設定 wordpress 目錄才會好用。

$ wp plugin status --path=/path/to/wordpress

refence: https://stackoverflow.com/questions/61275895/wp-cli-how-to-get-set-path


把沒有交易過的使用者刪除,可以用這個

 

4. 要增加新商品沒問題,但網址列有 index.php 很醜,因此要用permalinks 把 .htaccess 修改路由規則。但如果發現 .htaccess 沒有生效的話,可以從 phpinfo() 看 mod_rewrite 是否有載入? 沒有的話就用sudo a2enmod rewrite 安裝吧。

reference: https://wordpress.stackexchange.com/questions/105795/remove-index-php-from-permalinks


5.如果修改 .htaccess 之後一直出現 Forbidden 403 Error,可以將 Options +FollowSymLinks 放在 .htaccess 最前面,或是在 Apache 目錄的設定加上去。

reference: https://coolestguidesontheplanet.com/403-forbidden-error-wordpress-htaccess/