山姆的編程實作分享。。。

Sam Blog, Sam Sharing, Sam Studio

2019年5月28日

Python 讀書筆記 (4) : 改變 Anaconda prompt 工作目錄 / how to change default directory of Anaconda prompt


 Anaconda prompt 的default 工作目錄是 C:\Users\ID
以我而言, 我的 ID 是 "Sam", 所以我的原始工作目錄是  C:\Users\Sam
那如何改變?
可以在執行Anaconda prompt後直接就到Python的工作目錄?

答案是可以的!

Step 1:
On the start screen / menu, find the "Anaconda prompt" application

Step 2:
Right-click on "Anaconda prompt" application then select " Open File Location (開啟檔案位址)"

After Step 2, the GUI will move to the location of "Anaconda prompt" application

Step 3:
Right-click on "Anaconda prompt" application again then select "Properties (內容 )"
Step 4:
Edit the " Start in (開始位置)" property to your desired path
以我而言, 我的工作目錄是在D槽 ( D:\Workspace\Python )

2019年5月27日

Python 讀書筆記 (3) : Python 的禪意


The Zen of Python (英文原文版)

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Python 之道 (POT 眾譯版)

美麗優於醜陋,明講好過暗諭。
簡潔者為上,複雜者次之,繁澀者為下。
平舖善於層疊,勻散勝過稠密;以致輕鬆易讀。
特例難免但不可打破原則,務求純淨卻不可不切實際。
斷勿使錯誤靜靜流逝,除非有意如此。
在模擬兩可之間,拒絕猜測的誘惑。
總會有一種明確的寫法,最好也只有一種,
但或須細想方可得。
凡事雖應三思後行,但坐而言不如起而行。
難以解釋的實作方式,必定是壞方法。
容易解釋的實作方式,可能是好主意。
命名空間讚,吾人多實用。

真好的意境!
我覺得, 這不單是寫Python程式時需要有這種心態, 而是所有的程式語言都應該效法, 不是嗎?!

簡明程式的撰寫, 命名的意喻都應該讓閱讀者有如在看白話文一般, 這樣程式碼才會被永久的留下來或重複的被採用, 我想這也是工程師在開源專案所抱持的心態以及夢寐以求的境界

2019年5月25日

2019年5月24日

2019年5月19日

Arduino Robot : First Try


有了3D列印機後, 就想來嘗試做一隻機器人玩玩, 於是選擇OTTO這隻關節少的Robot來做個初體驗, 看看能不能在做好後, 拍幾集教學影片😀

立馬選擇OTTO v7版本列印出所有零件, 如下圖
疊疊樂, 看起來就很漂亮, 威風了吧!


接著開始組裝電子零組件, 這時發現
1. 這間隙也太大了, 鬆垮垮的 (紅色圈圈處)
2. 原設計只鎖一根螺絲 (黃色箭頭處), 也太不靠普了吧

這樣的組裝結構, 我自己都不滿意了, 怎麼推廣呢~
於是, 我決定停下腳步, 另尋方案~


2019年5月17日

Python 讀書筆記 (1) : What is Anaconda / Jupyter Notebbok


現在才學Python會不會太晚 ? Anyway, 活到老學到老嘛, 撩落去啦~

透過Google大神的幫忙, 從Python 開發環境的安裝, Hello World 的程式,
以及到多種 IDE 開發環境嘗試,  起手是算是練起來!
而最終我的開發環境選擇了 Visual studio Code 以及 Anaconda / Jupyter Notebook

選擇 Visual studio Code 是因為他是我熟悉且慣用的Editor, 並且她的專案管理及IntelliCode功能 非常好用.
而選擇 Anaconda  / Jupyter Notebook  則是因為她有虛擬的開發環境管理功能, 可以透過他來客製化自己開發環境, 進而清楚的知道自己的程式用了哪些packages及版本; 另外一個選擇他的原因是我想用Python來做數據分析 😀

到這階段(起手式), 來小記一下, 順便分享~

1. Visual studio code  大家應該再熟悉不過了, 我就不再多做解釋. 開發環境安裝可以參考
Getting Started with Python in VS Code

2. 至於甚麼是 Jupyter Notebook 以及 Anaconda ?
以下分享兩篇中文介紹好文給大家, 相信你看完就了解甚麼是 Jupyter Notebook 以及 Anaconda了.
Anaconda介紹及安裝教學
Jupyter Notebook介紹

3. Jupyter 操作說明可以參考這篇
Jupyter Notebook操作介紹

2019年5月15日

分享3D STL 檔案 : Nano+擴充板 保護底座


從 Fusion 360 轉換跑道到 Blender, 還真花了不少工夫 😅 還好有YouTube 大師們的分享影片, 讓我從中摸索出些門道 😀

我轉換跑道的原因是 " Why I change from Fusion 360 to Blender "

底下是用 Blender 畫出來的草圖


這個case是用來保護  Arduino Nano 結合擴充板的保護底座, 以免擴充板背面不小心短路損毀,
透過 Cura 4.0 轉出來STL檔案可在下面連接取得

底下這張照片是透過FLUX列印出來的成品, 內部上下有4個卡鉤用來卡住PCB板,
所以拆裝時要有個傾斜角.

和 "Nano + 擴充板" 結合的樣子

PS: 電源接口處有些微干涉, 我是用小刀處理掉!

2019年5月13日

Why I change from Fusion 360 to Blender


對一位 EE 背景的創客來說, 3D design 絕對是全新的領域, 在網路上搜尋及觀看影片後, 覺得Fusion 360 最容易上手, 且它內建好多 "一鍵完成" 功能, 如圓角, 導角, 所以就申請了帳號然後下載來使用, 一切如我預期的, 不到3天的時間, 我用Fusion 360劃出了 ESP8266 保護殼且用FLUX Delta 列印出來
分享3D STL 檔案 : ESP8266 WiFi 擴充板保護殼

以這樣的開發速度真的令我滿意, 但這設計過程中一直有無法開啟Fusion 360的現象, Windows 及 Macbook 都會如此; 但這無法開啟應用程式的問題又Always 發生在傍晚後, 是因為我是使用trial version? 傍晚後就因為優先權就被犧牲??? ( 這是我猜的)

就在我設計好 Nano 控制板的 case 且存好檔後, 隔天登入竟然沒有Nano 的設計檔案, 當場令我傻眼..., 常在需要它時又開啟不了應用程式再加上檔案不見, 讓我決定要來轉換跑道了, 換Blender 上路了!

2019年5月10日

Shipping a Linux Kernel with Windows


前不久我才自己打開Windows 10 在 build 14393 後新釋放的一個新功能 - WSL (Windows Subsystem for Linux), 然後嘗試這個新功能, 並且發文 (It's time to use Linux / Ubuntu by using Windows Subsystem) 鼓勵大家使用; 而這個新功能打開後, 使用者還必須自己去安裝 Linux kernel, 但在 May 6th這個時間點, Microsoft devblog 釋出以下的訊息

訊息連結 : Shipping a Linux Kernel with Windows
也就說, 再不久, Windows 10 就 build-in Linux Kernel, 我們真的可以擺脫 VM 或雙系統了😃

事實上, 從 Stack overflow 的9萬份的市調, 可以看到 Linux 已經是developer 心中開發平台的首選了, 姑且不論Microsoft 此舉是力挽狂瀾 ? 或順應潮流 ? 但這做法是我們期待的, 畢竟 Windows 是我們熟悉的, 日常的工作也都是在Windows 環境下.

Linux and Windows are the most common platforms

2019年5月9日

Google Flutter is ready for iOS, Android, Desktop (Mac, Linux, and Windows) and embedded devices, like Raspberry


才在3天前 PO 文 ( 還在猶豫要不要跳入 Dart / Flutter ? ) , 建議大家可以開始研究一下 Flutter SDK,
就在昨天的 Google IO 2019的大會上, Google 更強化Flutter SDK了 / 或稱更接近他之前訂下的目標了 - Beyond Mobile (超越行動裝置)



底下是Google IO 2019 開發者大會針對 Flutter 的介紹
Developer Keynote (Google I/O '19) (Flutter 的Keynote 在55分鐘處)
Beyond Mobile: Building Flutter Apps for iOS, Android, Chrome OS, and Web (Google I/O'19)

在這段Google Flutter 介紹影片中, 可以看到Google 在 Dart / Flutter的努力, 你是否也隱約嗅到Google 為下一代Android OS催生而努力呢?

但至少我已經看到了 single Flutter codebase 現在不只是可以build出 iOS 和 Android app 而已, 還可build 出可以在desktop PC ( Mac, Linux, Windows) 上跑的app了, 甚至下一階段的 Embedded device - Raspberry...

所以, 想寫App 的你, 不要猶豫了, 可以一頭栽進去了😀




熱門文章