Git clone 方式有什麼差異? 剛開始接觸Git的人,無論是使用GitLab 還是 GitHub 在clone專案複製連結的時候都會發現有HTTPS和SSH可以選擇 兩者有什麼區別呢? HTTPS 優點: 簡單, 只需要 GitHub 帳戶的使用者名稱和密碼。 通用, 無需額外配置即可在任何有網路的地方使用。 缺點: 安全性較低, 每次操作都需要輸入使...
Github 上開發教學 Step by Step(2/3)(中文)
將內容加入 google 搜尋中
將內容加入 google 搜尋中 當你辛苦產生的內容希望被別人搜尋到時,這時候就需要將內容加入 google 搜尋中。 以下分享一個不容易注意到的問題,這會大大的影響你的內容是否會被別人搜尋到。記得看到最後! 先介紹一下 google search console 吧! Google Search Console Google Search Console 是 Google 提供的...
Adding Content to Google Search(English)
Adding Content to Google Search When you want your hard-earned content to be searchable by others, it’s crucial to add your content to Google Search. Here’s a problem that’s often overlooked but ...
Android app 版本更新(中文)
Android app 版本更新 因為收到 GOOGLE 的通知版本目標太舊需要更新,所以順便研究如何更新APP的版本。 以下分享我的摸索出的更新歷程。 修改程式 上傳新版本 修改程式 主要更新 compileSdk、targetSdk。 versionCode 跟 versionName 是為了上傳 google 的時候使用,所以必須與之前的版本不同。 修...
Android app Version Update(English)
Android App Version Update I received a notification from Google that the version target is too old and needs to be updated. Therefore, I researched how to update the app version. Below, I’ll s...
Item 26 - 範圍 for 迴圈增強(中文)
範圍 for 迴圈增強 來講個比較小範圍的增強吧,c++20 支援 for 迴圈的初始化語句(init-statements)和初始值設定項(initializers) 直接看 code 吧! #include <iostream> #include <vector> int main() { // 使用範圍 for 迴圈進行初始化語句 for...
Item 26 - Range-based for Loop Enhancements(English)
Range-based for Loop Enhancements Let’s talk about a relatively small enhancement. C++20 supports initialization statements and initializers in the range-based for loop. Let’s look directly at th...
Item 30 - likely 和 unlikely 屬性(中文)
c++ 屬性 在 code 中,偶爾會看到 [[nodiscard]]..加在神奇的地方, 這些語法稱為屬性,屬性要幹嘛用的? 屬性 C++ 中的一種語法,用於向編譯器提供額外的信息,這些信息可以影響程序的編譯或執行方式。這些屬性可以應用於各種程式元素,如類、結構體、函數、變量等。 常見的屬性 [[nodiscard]]: 標記一個函數的返回值不應該被忽略。 [[deprecated...
Item 30 - likely and unlikely Attributes(English)
C++ Attributes In code, you might occasionally see [[nodiscard]] and other similar syntax in interesting places. These are called attributes, and they serve a specific purpose. Attributes in C++ ...
Item 22 - reduce(中文)
std::reduce std::reduce 是 C++17 引入的標準函數,用於對範圍內的元素進行歸約操作。 它類似於 std::accumulate,但有一些重要的區別,包括默認使用並行執行和一些優化,真是太方便了! 累加範圍內的所有元素。 #include <numeric> #include <vector> #include <iostrea...
Item 22 - reduce(English)
std::reduce std::reduce is a standard function introduced in C++17 for performing reduction operations on a range of elements. It is similar to std::accumulate, but with some important difference...
Item 17 - shared_ptr Supports for Creating Dynamic Arrays (English)
Support for Creating Dynamic Arrays In C++11, std::shared_ptr does not support creating dynamic arrays. If you forgot, you can check this article. C++17 introduced support for this, making the fu...
Item 17 - shared_ptr 支援創建動態數組 (中文)
支援創建動態數組 C++11 時,std::shared_ptr 尚無支援創建動態數組,忘記的話可以看這篇 C++17 支援了,讓 std::shared_ptr 的功能變得更全面。 code #include <iostream> #include <memory> class Resource { public: Resource() { s...
Item 5(2/2) - Lambda expression (English)
捕捉變數 Let’s review the content from the previous articlebefore diving deeper. The basic syntax of a Lambda expression is as follows: [capture](parameters) -> return_type { body } If I have t...
Item 5(2/2) - Lambda expression 匿名函數(中文)
捕捉變數 回顧一下上一篇的內容,在往下討論。 Lambda 表達式的基本語法如下 [capture](parameters) -> return_type { body } 如果我要 capture 的變數超級多,那我要一一指名,lambda function 就會被寫得很醜, 有沒有比較優雅的方式去完成 ? Yes!! 捕獲模式 [=] 的含義 [=] 表示 按值捕獲...
Item 7 (2/2) - Smart pointers(English)
std::shared_ptr Circular Reference Issue Is std::shared_ptr smart enough for us to use it without worries? No!!! Although std::shared_ptr is indeed very useful, careless use can still lead to prob...
Item 7 (2/2)- 智能指针(smart pointers)(中文)
std::shared_ptr 循環引用(circular reference)問題 std::shared_ptr 很聰明,我們可以放心的使用它了嗎? No!!! 雖然 std::shared_ptr 真的很不錯,但是不小心使用還是會有問題! std::shared_ptr 的循環引用(circular reference)問題,是指當兩個或多個 std::shared_ptr 對象相...
Item 7 (1/2) - Smart pointers(English)
Smart Pointers When you see an int* ptr being used in your C++ code, do you need to delete it after use? If yes, should you use delete[] ptr or delete ptr? If the later code performs a delete, rep...
Item 7 (1/2) - 智能指针(smart pointers)(中文)
智能指针 當你看到一個 int* ptr 在你的 c++ code 中使用,用完後要不要去 delete 它 ? 如果要,請問是使用 delete [] ptr or delete ptr ? 若後面的 code 有做 delete , 則 重複 delete 會造成 crush. 如果不要,而後面沒有 code 做 delete ,則造成 memory leak。 上述的困境,你一定遇...
Item 27 - 模塊(modules)(中文)
模塊(modules) C++20 引入了模塊(modules),這是自 C++11 引入的範本(templates)以來最大的語言特性改變之一。 模塊旨在替代傳統的頭文件機制,以改善編譯時間並提供更好的封裝性。 傳統的 c++ include 真的好難用喔,像 python 都可直接 import 模組使用 ex: import numpy as np 我們來看一下 include 造...
Item 27 - Modules(English)
Modules C++20 introduced modules, which is one of the biggest language feature changes since the introduction of templates in C++11. Modules aim to replace the traditional header file mechanism to...
Item 23 - 概念(Concepts)(中文)
概念(Concepts) 在 C++20 中,概念(Concepts)是一種新的語法工具,用於約束模板參數,以提高模板代碼的可讀性和錯誤提示。 概念可以幫助開發者在編譯時期捕捉錯誤,並提供更具體的錯誤信息。 概念是用來定義模板參數所需滿足的條件。 這些條件通常是型別特性、方法簽名或其他編譯時期可檢查的性質。 概念使得模板代碼更加直觀和易於理解,並且可以大大減少模版使用錯誤時的錯誤訊息。 ...
Item 23 - Concepts(English)
Concepts In C++20, concepts are a new syntactical tool used to constrain template parameters, enhancing the readability of template code and improving error messages. Concepts help developers catc...
Item 28 - 指定初始化器 (中文)
指定初始化器 在 C++20 中,designated initializer 是一種語法,允許我們在初始化結構體或聯合體時,顯式地指定每個成員的初始化方式。這種語法源自 C 語言,在 C++20 中得到了支持。使用 designated initializer,可以在初始化列表中指定要初始化的特定成員,而不是按照成員在結構體或聯合體中定義的順序依次初始化。 基本語法: StructT...
Item 28 - Designated Initializer (English)
Designated Initializer In C++20, the designated initializer is a syntax that allows us to explicitly specify how each member of a structure or union is initialized when using an initializer list. ...
Item 25 - 協程(coroutines)(中文)
什麼是協程 相信很多人看到 c++20 提供的新功能協程,因該滿頭問號,更不用說去使用了? 到底協程是不是多線程? 直接說答案:不是! 協程本身並不是一種多線程技術,而是一種在單線程內實現非阻塞異步操作的方法。 協程允許在一個線程內進行高效的任務切換,而不需要多線程帶來的上下文切換和同步開銷。 了解到這點後,再去看 code 就會清楚很多了。 協程與多線程的區別 協程(Corouti...
Item 25 - Coroutines(English)
What are Coroutines? When many people see the new feature coroutines introduced in C++20, they might be puzzled and unsure how to use it. Are coroutines the same as multithreading? The answer is...
DownGit 下載 Github repo 的部分檔案 (中文)
下載 Github repo 的部分檔案 可以只下載 Github repo 的部分檔案嗎? Yes! 在 GitHub 上,你可以只下載某個公共倉庫的部分資料夾或檔案, 但需要一些技巧,因為 GitHub 的界面本身不支援直接下載部分內容。 其中最簡單的方式就是線上 DownGit 啦。link 打開 DownGit. 輸入你想要下載的資料夾的 URL,例如:https...
Download Specific Files from a GitHub Repository (English)
Download Specific Files from a GitHub Repository Is it possible to download only specific files from a GitHub repository? Yes! On GitHub, you can download only certain folders or files from a pu...
.h vs .hpp (中文)
.h vs .hpp 在 project 中,常常會看到 .h 和 .hpp 的檔案。 這個到底有什麼不同呢? .hpp 和 .h 文件在本質上是相同的 .hpp 和 .h 文件在本質上是相同的,都是C++和C語言中用於定義函數原型、類聲明、常量和宏定義的頭文件。它們的主要區別在於擴展名的命名慣例和用途的歷史來源。 .h 文件 擴展名:.h 是歷史上用於C語言頭文件的標準擴展名,...