2021年9月15日 星期三

[RPi] sudo apt-get update 更新

 今天拿到一張舊的 SD 卡,用的 image 是 

```

pi@raspberrypi:~ $ uname -a
Linux raspberrypi 4.19.97-v7+ #1294 SMP Thu Jan 30 13:15:58 GMT 2020 armv7l GNU/Linux
```

想要更新卻出現這樣的錯誤訊息

```

Repository 'http://raspbian.raspberrypi.org/raspbian buster InRelease' changed its 'Suite' value from 'stable' to 'oldstable'

```


這樣更新之後就沒問題了

```

sudo apt-get update --allow-releaseinfo-change

```

2021年8月16日 星期一

[ML] 簡單粗暴 TensorFlow 2 | A Concise Handbook of TensorFlow 2

為寫書做準備。

真不錯,有線上版和實體書籍可以選擇。

2021年7月29日 星期四

[RPi] Pi 3 網路設定維修

最近拿到一片 Pi 3 網路有問題。設定 static ip 可以,但 dhcp 不行。

看到 ethtool 這指令,搭配這篇文章試了一下,原理可以參考這裡

原本的設定

$ sudo ethtool eth0
Settings for eth0:
    Supported ports: [ TP MII ]
    Supported link modes:   10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full
    Supported pause frame use: No
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Half 10baseT/Full 
                            100baseT/Half 100baseT/Full 
    Advertised pause frame use: Symmetric Receive-only
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                         100baseT/Half 100baseT/Full 
    Link partner advertised pause frame use: Symmetric Receive-only
    Link partner advertised auto-negotiation: Yes
    Link partner advertised FEC modes: Not reported
    Speed: 100Mb/s
    Duplex: Full
    Port: MII
    PHYAD: 1
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: pumbag
    Wake-on: d
    Current message level: 0x00000007 (7)
                   drv probe link
    Link detected: yes
    
$ ifconfig eth0
eth0: flags=4163  mtu 1500

改成 speed 10 之後,竟然可以 dhcp 了~

$ sudo ethtool -s eth0 autoneg on speed 10 duplex full
測試結果
$ sudo ethtool eth0
Settings for eth0:
	Supported ports: [ TP MII ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Full 
	Advertised pause frame use: Symmetric Receive-only
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Link partner advertised link modes:  10baseT/Full 
	Link partner advertised pause frame use: Symmetric Receive-only
	Link partner advertised auto-negotiation: Yes
	Link partner advertised FEC modes: Not reported
	Speed: 10Mb/s
	Duplex: Full
	Port: MII
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: pumbag
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

$ ifconfig eth0
eth0: flags=4163  mtu 1500
        inet 192.168.1.129  netmask 255.255.255.0  broadcast 192.168.1.255
...
將 eth0 重新設定
$ sudo ethtool -r eth0

2021年7月23日 星期五

[Wordpress] WP Offload Media plugin

之前用 WP Offload Media Lite plugin 蠻開心的,但移機發現竟然產品的 url 沒有跟著匯出。 

有發現一篇可能可以解決的方法,但有點麻煩而且怕不小心誤砍了資料庫就更糟糕了。

 最後還是花錢升級成 pro,有一個功能會將移過去的圖片上傳到 S3。

不知道還有沒有其他解決方法? 看來要等人 support 了

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/

2021年5月30日 星期日

[CV] Google Colab Widget

最近開始測試使用 Colab 教學,有一些互動的限制,例如 OpenCV 常使用的按鍵或是滑動條(trackbar),都要改成 IPython Widget 來使用 

看完這幾篇,應該就會使用了

* advanced_outputs.ipynb

* Widget Events

* https://github.com/jupyter-widgets/ipywidgets/issues/1680