發表文章

目前顯示的是 9月, 2021的文章

解決:安裝測試APP發生INSTALL_FAILED_NO_MATCHING_ABIS的問題

這個INSTALL_FAILED_NO_MATCHING_ABIS問題會發生在安裝APK內有Native Library的APP,例如react-native。關於ABI的說明可參考 官方文件 。

建立私有docker registry與基本設定

  私有registry docker run -d -p 5000:5000 --restart=always --name registry registry:2 非常有docker的style,registry本身也docker一下。不過我們跑私有就是要持久化,看一下 image設定 的內容是放在 儲存庫位置: /var/lib/registry 設定檔位置: /etc/docker/registry/config.yml 雖然上面指令小改一下就好,但是我都統一改用docker-compose 私有docker registry最小設定 只是可以跑起來的compose設定檔(docker-compose.yml) version : "3.8" services : registry : restart : always image : registry:2 ports : - 5000:5000 volumes : - ./data:/var/lib/registry 回憶: 啟動服務 docker-compose up -d 回憶: 關閉服務 docker-compose down 私有docker registry簡易設定 可登入的compose設定檔(docker-compose.yml) version : "3.8" services : registry : container_name : my-docker-hub restart : always image : registry:2 ports : - 5000:5000 environment : REGISTRY_HTTP_SECRET : simpletokensecret REGISTRY_AUTH : htpasswd REGISTRY_AUTH_HTPASSWD_PATH : /myauth/htpasswd REGISTRY_AUTH_HTPASSWD_REALM : Registry Realm volumes : - ./data:/var/lib/r

開發Android APP要設定的環境變數及PATH

圖片
這篇彙整一下2021要設定的環境變數,因為開發React-Native, Flutter等都會使用到command line tool,然後因為近期Google有釋出新的command line tool,所以我也重新調整了一下環境變數

筆記:安裝ssh server並設定防火牆

最近需要用到雲伺服器, 要好好的保護定一下

筆記:在Ubuntu20.04安裝Docker及Compose

Install docker/docker-compose in Ubuntu 20.04 今天想到自己沒有做個docker安裝的筆記,趕快補上! 安裝前需求套件 sudo apt update sudo apt -y install apt-transport-https ca-certificates curl gnupg lsb-release 加入gpg key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 設定來源 echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 安裝docker套件 sudo apt update sudo apt -y install docker-ce docker-ce-cli containerd.io 設定群組權限 將docker加入,這樣就不用每次docker時要sudo,而且使用VSCode remote development也需要這個設定  sudo groupadd docker sudo usermod -aG docker $USER newgrp docker 參考: https://docs.docker.com/engine/install/linux-postinstall/ 測試 docker run hello-world docker會去官方repository抓示範用的image,只會印出歡迎訊息。 安裝Compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-comp

從Wireshark封包檔擷取以DASH/HLS影音串流

圖片
關於這個擷取影音串流方法,現今大部分的影音平台都是會使用HTTPS加密,要先請您排除HTTPS的影音串流,因為在加密狀態下只要沒有金鑰這裡一切白談!

筆記:ffmpeg和alsa指令錄音PCM及WAV

因為工作研發及驗證需要整理一下ffmpeg和alsa錄音指令

在heroku app加上ffmpeg轉檔

因為最近想要使line bot可以接受影音資料並儲存起來供瀏覽器瀏覽,會需要有轉檔的機制,因為之前已經做過node.js的line bot就繼續延伸下。

修復Github Action遭遇This request was automatically failed because there were no enabled runners online to process the request for more than 1 days.問題

圖片
這幾天重拾前一年開發的APP專案,因為掛上github action在merge前要先通過unit test。然後,github action就失敗了... 原因 This request was automatically failed because there were no enabled runners online to process the request for more than 1 days.

heroku的app自動取得目前app名稱

起因 Heroku上的專案預設都是用 https://{your-heroku-app-name}.herokuapp.com 但是每次發布到各的地方都要在改一下設定/程式實在麻煩,像是我常用heroku config去設定HOST_URL,不過原來官方早就有做這個功能,只是我們都沒打開

使用put/get取得或設定Android Settings.Global數值

若有需要讀寫Android系統內Java所儲存的global數值,以下以display_outputmode_auto作為範例 取得 settings get global display_outputmode_auto 設置 settings put global display_outputmode_auto 1 settings put global display_outputmode_auto 0 問題 如果出現下面錯誤表示需要高於system的權限 settings put global display_outputmode_auto 1 Error while accessing settings provider java.lang.SecurityException: null from uid 1000 not allowed to perform WRITE_SETTINGS     at android.os.Parcel.readException(Parcel.java:1465)     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)     at android.content.ContentProviderProxy.call(ContentProviderNative.java:636)     at com.android.commands.settings.SettingsCmd.putForUser(SettingsCmd.java:208)     at com.android.commands.settings.SettingsCmd.run(SettingsCmd.java:137)     at com.android.commands.settings.SettingsCmd.main(SettingsCmd.java:55)     at com.android.internal.os.Runt

VSCode存檔時自動執行格式化javascript程式碼

圖片
1. 安裝VSCode外掛 eslint https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint 之前tyescript微軟有寫tslint不過廢棄了,現在用eslint外掛 2. 設定VSCode 建立.vscode/settings.json檔案,將eslint的設定開啟。 {     "editor.codeActionsOnSave": {         "source.fixAll.eslint": true     } } 3. 設定你要的lint風格 eslint設定檔是.eslintrc.json 你也可以用eslint套件來產生 yarn add -D eslint 輸入以下指令後會以交互提問來確認你想要產生的設定檔 yarn eslint --init 以下是我產生一個typescript用的.eslintrc.json設定檔 { "env" : { "node" : true , "jest" : true }, "extends" : "standard" , "parser" : "@typescript-eslint/parser" , "parserOptions" : { "ecmaVersion" : 12 , "sourceType" : "module" }, "plugins" : [ "@typescript-eslint" , ], "rules" : { }, "ignorePatterns" : [ "node_modules" , "dist"

強化BASH下的ADB指令的自動完成功能

Improve the auto completion of BASH for adb commands 會想要強化adb的自動完成功能主要是我要adb安裝apk時Tab兩次竟然不會列出當前目錄下的apk檔案,這問題實在太夭壽啦! 然後就開始研究一下bash的auto completion

解決git在Windows下中文亂碼問題

修正git中文亂碼問題 1. 修正git-gui和gitk git config --global gui.encoding utf-8 2. 修正git show 永久設使用者環境變數 SETX LC_ALL C.UTF-8 需使用系統管理員權限的powershell或命令提示字元 3. 修正git status 顯示中文檔名亂碼 git config --global core.quotepath false 參考資料 https://blog.miniasp.com/post/2017/09/17/Git-for-Windows-Command-Prompt-Display-Chinese-Issues

Dayjs升1.9到1.10+的parse問題(已獲得臨時解法)

最近在做RN升版時發現Dayjs升到1.10.7有parse時間字串的問題,跟1.9版結果不同。所以我只能升級到1.9的最新版。 前文

React-Native從0.63.2升級到0.65.1版問題解法集合

圖片
這個升級其實沒什麼實際理由只是想升升看,沒想到問題也是很多。 以下分為建置跟測試兩方面的問題整理解法

查看正在佔用Port的程式

因為有時候程式沒寫好所以會需要查一下佔用Port得程式

臨時解法:Ubuntu 20.04的react-native run-android卡住的問題

Stuck on "info starting JS server ...." 最近遭遇yarn android或react-native run-android卡住的問題,是大部分時候都會卡住,偶而正常。查了一些資料表示,@react-native-community/cli 新版的裡面在啟動server遭遇卡住的問題,

React-Native該把NDK路徑設定在哪? local.properties還是環境變數

圖片
上次沒紀錄會被搞得很亂,下次又得重找所以就紀錄在這裡 先說我目前系統是Ubuntu 20.04,Android Studio版本是Android Studio Arctic Fox | 2020.3.1 Patch 2 Build #AI-203.7717.56.2031.7678000, built on August 27, 2021

從Wireshark封包檔擷取以RTP串流的RTSP影音資料

圖片
因為最近工作上要確認影音封包狀態,所以需要從Wireshark封包檔擷取RTSP的影音資料,再用播放器開起來確認是否正常。 不過遭遇了擷取出的檔案使用RTP作為串流格式,該檔案只有ffplay可以播放,vlc和Ubuntu內建的影音播放器皆無法播放,使用mediainfo也無法工作,什麼資訊都沒有。

React Native開發Android APP用指令

使用React-Native開發Android APP時,會使用 react-native run-android 建置並安裝到模擬器。不過在實際運作的專案上,我需要更多的功能。而下面這些指令我都寫在專案的package.json裡以備不時之需。 啟動debug,release,或stage模式 跑指定模式 像是我要開debug或release甚至其他的config,就會用到--variant react-native run-android --variant=release Android APP預設variant至少有debug和release。 跑指定package react-native run-android --variant=debug --appId=com.example.dev 如果你的app的package在debug模式下用另一個package,以便在同一台機器上測試正式或除錯版 建置JS bundle 有時候只是想build js的部份,可以用bundle build就好,指令舉例如下: react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 不過後來這會生成一些檔案在android/app/src/main/res,導致我的專案APK建置失敗,所以後來就不太使用了 清除Cache 開發用hot-reload有時不管怎樣都不會讀取我的新程式碼,就需要清除cache react-native start --reset-cache 這個指令執行完會啟動RN dev server所以需要再ctrl+c停止 APK建置 建置APK之前會先建置JS bundle 建置正式版 cd android && ./gradlew assembleRelease && nautilus app/build/outputs/apk/release 建置除錯版 cd android && ./gradlew assem

Ubuntu 20.04 apt指令的小變更

之前用14.04和16.04,apt指令有分apt-get, apt-cache, apt-file等等,在Ubuntu 20.04都簡化了。以下整理並複習一下指令。 向更新伺服器取得套件訊息 sudo apt update 列出可升級的套件 sudo apt list --upgradable 更新可升級的套件 sudo apt upgrade 列出已安裝的套件 sudo apt list --installed # 列出所有 sudo apt policy {套件名稱} # 特定套件; 沒裝會寫沒裝 安裝新套件 sudo apt install {套件名稱} 備註: 指令打到sudo apt isntall 之後按兩次tab會有自動完成功能可以幫助 安裝指定版本的套件 sudo apt-get install {套件名稱}={版本號} 例如: sudo apt-get install apache2 =2.4.\* sudo apt-get install apache2 =2.4.41-4ubuntu3.4 # 要打的非常完整 搜尋可安裝的套件版本 sudo apt list -a {套件名稱} 例如: $ sudo apt list -a apache2 apache2/focal-updates 2.4.41-4ubuntu3.4 amd64 apache2/focal-security 2.4.41-4ubuntu3.3 amd64 apache2/focal 2.4.41-4ubuntu3 amd64 搜尋套件名稱部份包含 sudo apt search apache2 參考資料: APT操作簡記 https://codingnote.blogspot.com/2016/12/apt-get-apt-get-update-apt-get-install.html dpkg指令簡記 https://codingnote.blogspot.com/2017/05/dpkg.html dpkg cheat sheet https://www.cyberciti.biz/howto/question/

在VSCode中使用docker開發react

在VSCode中使用Docker環境開發react Development React App with docker in VSCode 嘗試使用過 在VSCode在使用Docker環境開發Flutter 後,就想到應該我現在所有的開發工作應該都可以docker化了吧! 就開始著手研究起了React部份。 起手使用了nodejs的docker環境,只是跑起來有權限不足的問題,果然轉套一個技術沒這麼簡單,中間琢磨了許久,後面將調整的結果與大家分享。

解決:Ubuntu上的wireshark無法找到網路裝置

Ubuntu上的wireshark無法找到網路裝置的解法 Why the wireshark on ubuntu cannot list any network device? the solution is .... 安裝好Wireshark後開啟時常常會出現錯誤訊息,並且找不到本機上的網路裝置,這是因為Wireshark沒有網路裝置權限的問題。然而當你用sudo開啟時,雖然可以正常抓到網路裝置,但是wireshark會顯示不建議使用root使用者開啟Wireshark。 以下是我找到的解法

Ubuntu 20.04用指令改網路設定

Ubuntu 20.04下指令改變網路設定 change your network setting by command line in Ubuntu 20.04 因為工作需要在一個網路卡切換固定IP做對連測試,無奈Ubuntu網路管理GUI無法提供這樣的服務,以前用ip up down現在都沒效果了,只好自己又再琢磨了一下。

解法:用VSCode在docker內開發flutter App遭遇tzdata問題

用VSCode在docker內開發flutter App 看到 這篇 介紹的超完整的,推薦要這樣開發都要看一下。 我自己照著它的介紹在把docker升到Ubuntu 20.04上試了一下,要小修一下Dockerfile內容。

用CRA(create-react-app)建立React App

用create-react-app建立app 1. 先安裝npm或yarn 請參考我的 前一篇 2. 用標準範本建立app 以下三種都是建立新app的方法,我自己是yarn派的。不過因為網路上資源寫法各式各樣,所以還是都要認識一下,才知道怎改 npm init react-app my-app npx create-react-app my-app yarn create react-app my-app 也可以選擇其他template yarn create react-app my-app --template typescript yarn create react-app my-app --template cra-template-pwa yarn create react-app my-app --template cra-template-pwa-typescript 3. 進入專案目錄 建立完成後要進入app目錄 cd my-app 建置app npm run build yarn build yarn run build 實際上run的指令都跑package.json的script內寫的,如果懶的看有哪些指令也可以只打yarn run,它會列出指令的內容再打要跑得指令就好了。 執行app npm start yarn start 跑測試 npm test yarn test 這個基本上我也不會自己手動跑, 裝VSCode的套件自動在存檔時自動跑測試 資料來源 https://create-react-app.dev/docs/getting-started/

Ubuntu20.04安裝clasp佈署工具

Ubuntu20.04安裝clasp佈署工具 因為最近升級系統所以需要安裝Google Apps Script的部屬工具clasp, 之前 我在16.04安裝clasp問題比較多,換成20.04就安裝clasp沒什麼問題。 1. 安裝yarn 請參考我之前 安裝yarn 的文章 2. 安裝clasp sudo yarn global add @google/clasp 確認版本 $ clasp -v 2.4.1 如果你沒辦法打clasp指令,表示你忘了打sudo,請先remove再add一次 3. Trobuleshooting 不知道怎不能用之前的.clasprc.json檔案,所以得重新登入 clasp login 後續操作 其他使用指令可以參考我之前的 文章

Ubuntu20.04安裝React-Native及編譯APK

Ubuntu20.04安裝React-Native install react-native development tools in ubuntu 1. 安裝Node.js和Yarn 請參考我的 前一篇 2. 安裝React-Native的CLI工具 sudo yarn global add react-native-cli 測試一下是否安裝完整 $ react-native -v react-native-cli: 2.0.1 react-native: n/a - not inside a React Native project directory 如果你安裝完沒有辦法打react-native看版本 3. 安裝JDK sudo apt install openjdk-8-jdk 測試一下是否是安裝的jdk $ java -version openjdk version "1.8.0_292" OpenJDK Runtime Environment (build 1.8.0_292-8u292-b10-0ubuntu1~20.04-b10) OpenJDK 64-Bit Server VM (build 25.292-b10, mixed mode) $ javac -version javac 1.8.0_292 如果你是只有裝一套JDK的系統就不需要調整PATH跟JAVA_HOME 4. 設定Android SDK路徑 以我的Android SDK目錄放在/mnt/hdd2/Android/來說,我會在.bashrc下設定 ANDROID_SDK_ROOT=/mnt/hdd2/Android/Sdk ANDROID_HOME=/mnt/hdd2/Android/Sdk PATH=$PATH:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools 5. 編譯你的APP 從cmd編譯 先進入你的Project下的android目錄編譯你的APP 編譯Debug版APP ./gradlew assembleDebug 生成的檔案路徑預設是android/app/build/outputs/apk/debug 編譯Release版APP ./gradlew assembleRelease 生成

Ubuntu 20.04安裝node.js和yarn

 Ubuntu 20.04安裝node.js v16和yarn 先下載v16的script並跑設定 curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - 參考:https://github.com/nodesource/distributions 依照script設定的建議安裝套件 sudo apt-get install -y nodejs gcc g++ make 安裝yarn curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn 2021-09-06安裝後各版本號碼如下 node 16.8.0 npm 7.21.0 gcc 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04) make 4.2.1 yarn 1.22.5

產生空檔案和單行內容的檔案

產生空檔案 Windows命令提示字元 copy NUL a.txt Linux command line touch a.txt 預先創建一個大小的檔案 truncate -s 47484 empty_file truncate -s 50k empty_file 單行內容檔案 這裡指的內容只有一行,且沒有換行符號 Windows命令提示字元 Linux command line echo -n "one string without next line character" > a.txt echo -e "one string without next line character\c" > a.txt printf "one string without next line character" > a.txt

Ubuntu 16.04的ffmpeg編譯啟用gnutls

我在上一篇 用docker-compose編譯ffmpeg 時,使用--enable-openssl作為--enable-gnutls的替代。 這裡是遭遇了一個libz的錯誤 /usr/bin/ld: attempted static link of dynamic object `/usr/lib/x86_64-linux-gnu/libz.so' 這部份從build log看起來是因為檢測libgnutls28-dev套件時會使用到shared版本的libz,就算我在前面已經編譯了static版本的libz,它也還是找了shared版本的libz來檢測,導致config不過。 這也意謂著,我要使用啟用gnutls就須要重編譯整個套件,下面就介紹若要啟用gnutls該如何處理。

用docker-compose編譯ffmpeg

用docker-compose編譯ffmpeg ffmpeg官方網站有提供ffmpeg的編譯方法,是static的版本,不過編譯時會報錯,做些微調後我放上github了 https://github.com/Mirochiu/docker-build-static-ffmpeg

Docker-compose無法進入Ubuntu的Bash解法

 Docker-compose無法進入Ubuntu的Bash解法 這個問題困擾我2個小時,最後其實也只能workaround

Docker-compose使用筆記

Docker-compose使用筆記 前一篇的 Dockerfile筆記 已經先學會基本的Docker用法,但是docker只能一次操作一個系統,如果要產生MEAN stack不就要下好多個指令嗎? 同事推薦再學一下docker-compse指令,只要寫好yml,你可以一個指令操作好多個docker container,關閉時也很簡單。 以下搭配我已經建立好的 php-mariadb的docker-compose 來講解