pretty code

2019年3月28日 星期四

Onyx Boox Note Lite 更新記錄

個人閱讀體驗感受﹝2019/02/15 入手時﹞:
Google Play 圖書 = Neo Reader > Readmoo = Kindle > Kobo。

個人閱讀體驗感受﹝2019/03/08 解決 Kindle App 翻頁問題後﹞:
Google Play 圖書 = Neo Reader = Kindle > Readmoo > Kobo。

個人閱讀體驗感受﹝2019/03/27 OTA 更新後﹞:
Neo Reader = Kindle = Kobo = Readmoo > Google Play 圖書。

從上面可以看出,每個電子書 App 的體驗感受都變好,只有 Google Play 圖書稍微變慢,但還是比前兩次的 Kobo app 感受快。

整體來說,真的可以一機通吃。

底下是此次更新的一些項目:
01. 可以自訂螢幕保護程式。
02. 增加飄浮球工具列,有 5 個快捷列可以設定﹝可以截圖﹞。
03. 電池圖示改變。
04. NeoReader 可以針對文字及圖片各別設定對比度。
05. App 優化選項增加 2 項針對淺色文字及深色背景的設定。


深度學習資源

底下是目前為止,我覺得寫得最好的教學網站,重點還是中文。

https://dotblogs.com.tw/greengem/2017/12/12/180258

其他參考
https://www.ithome.com.tw/news/115588
https://zhuanlan.zhihu.com/p/24687814
https://www.tensorflow.org/tutorials/keras/basic_classification
https://panx.asia/archives/53209
https://kknews.cc/tech/vzyvya2.html
https://software.intel.com/en-us/neural-compute-stick/get-started

推薦書籍
https://www.tenlong.com.tw/products/9781491962299
https://hand2st.apachecn.org/#/README (簡體中文線上版)

2019年3月19日 星期二

mongodump stderr message

最近在使用程式定時備份 MongoDB,發現在備份之後的 code 都無法執行。

查了一下才發現,mongodump 的 message 是往 stderr 丟,故程式不能以 stderr 是否有字串來判斷成功與否。

應該要對 stderr 再做一次過濾,如果有 "Failed" or "error ",理論上就是 dump 過程中有錯誤。

不過因為我不知道所有的錯誤訊息內容,以上方式只是針對 MongoDB service 沒有啟動的 case。

另外,為了自動排程執行,有些人可能是用 Windows batch 再包一層。

如果要在 batch 中將訊息直接導向到  log,正確做法應該如下。

run.bat > back.log 2>&1

">" 前面沒有寫就表示 default (STDOUT=1)。
"2>&1" 將 STDERR(2) 導向到 STDOUT(1)。

2019年3月13日 星期三

Fix "Python 2 Syntax" of UDK2018 BaseTools when your use Python 3 to build BaseTools


There are three kinds of "Syntax error" in codes of "BaseTools\Source\Python".

1. print "XXX" ===> print("XXX")
2. operator "<>" ===> "!="
3. except "YYY", X:  ===> except "YYY" as X:


2019年3月12日 星期二

Use VS2015 to build AppPkg of UDK2018

You need to comment the line 342 in "C:\UDK2018_Branch\StdLib\Include\sys\EfiCdefs.h".

The "#define __STDC_HOSTED__" has conflict with VS2015.

How to build Win32 "BaseTools" in UDK2018

The "UDK2018" is "UDK2018" branch in git, not "vUDK2018" tag in git.

OS: Windows 7 64 bit
VC: VS2015 (from VS2017 community installation)
UDK2018: I download the zip from git on 3/4, 2019.
Python: 2.7.11 64 bit
cx_Freeze module: 4.3.3 (from cx_Freeze-4.3.3.win-amd64-py2.7.msi)

You will not have any problems if you use these tools above.

The steps to build
0. Modify line  826 in "C:\Python27\Lib\site-packages\cx_Freeze\hooks.py". (sys.base_prefix -> 'C:\Python27'). This will solve "Python 3 Syntax" problem.
1. Open "VS2015 x86 Native Tools Command Prompt" link from Windows Program menu.
2. Enter your "UDK2018" folder.(my example is "C:\UDK2018_Branch")
3. set PYTHON_HOME=C:\Python27
4. set PYTHON_FREEZER_PATH=C:\Python27\Scripts
5. Run "edksetup Rebuild".

If you like to use Python 3, here are some hints.
1. Don't use "Python37", I can't install "cx_Freeze" 5.x in it.
2. Use" Python36", I can install cx_Freeze 5.x. But after completing to build the "BaseTools", you will encounter "build__init_" module issue when you start to build something. I guess the solution is to install old version of "cx_Freeze" as I did in Python 2.
3. Modify some codes in "C:\UDK2018_Branch\BaseTools\Source\Python" because source code use some "Python 2 Syntax".

電子書三兄弟 with Amazon program book

現在就只欠缺四弟 Onyx Boox Nova 了


2019年3月8日 星期五

Kindle app in Onyx Boox Note Lite

之前一直困惑 Kindle app 偶爾不能翻頁的問題,終於在無意中試出來了!

首先這是因為翻頁動畫造成的問題,故可以透過以下幾種方式解決。

1. 使用 A2 模式﹝之前就是因為偶爾有開,才會覺得這個問題時好時壞﹞。
2. 長按 icon 使用優化設定,增加動畫過濾延遲。
3. 去 Good e-Reader 下載 Kindle Lite app 來用﹝無法透過 Google Play﹞。

底下是我目前使用的設定。




Run UEFI Python on our new BIOS kernel.

I found something strange when I used UEFI Python on our new BIOS kernel.
The loading time of Python and importing time of "requests" module is slow now.

I did some tests for this problem.

OLD BIOS kernel
It is normal in first run -> loading time 1 ~ 2 seconds, importing time 3 ~ 4 seconds.
Other runs -> loading time 6 ~ 7 seconds, import time 13 ~ 14 seconds.
When you run Python directly, you can see the "Prompt message".

NEW BIOS kernel
It is slower in first run -> loading time 3 ~ 5 seconds, importing time 13 ~ 14 seconds.
Other runs -> It is slower than last run, and it will keep increasing in loading time and importing time.
When you run Python directly, you can't see the "Prompt message".

By the way, my building binary bases on UDK2017 and UDK2018. They all have the same problem.

Workaround
You can only use your Python script in first run.


2020/05/22 Update

I don't do anything today. But the problem is gone. This issue maybe came from BIOS or motherboard.

2019年3月5日 星期二

Reduce mobi file size by changing parameters of kindlegen tool.

Kindlegen tool adds the epub content to mobi file.
If we want to reduce output size, we can use parameters of "-dont_append_source" and "-c2".
 
I have a book named "越讀者" and I will show you the differences.

Original epub : 82,307 KB
"default" : 177,313 KB
"-dont_append_source" : 95,007 KB
"-dont_append_source -c2" : 94,725 KB
"-dont_append_source -gif" : 98,838 KB
"-dont_append_source -gif -c2" : 98,557 KB