[Mac] 修改環境變數下的路徑 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 6月 10, 2019 列出環境變數 printenv 列出環境變數下的 Path echo $PATH 打開 bash profile vi ~/.bash_profile 新增路徑到 PATH export PATH=$PATH:路徑名稱 存擋 :wq 執行 bash profile source ~/.bash_profile 取得連結 Facebook X Pinterest 以電子郵件傳送 其他應用程式 留言
Chrome native messaging host with C# app in windows 4月 16, 2020 由於工作需要使用到chrome擴充功能跟C#寫的app做資料傳輸,所以學了一下 以下開始來看,先看chrome extension的部分: chrome的manifest.json: { "name": "Native Messaging Windows", "version": "1.0", "manifest_version": 2, "description": "Communicate with a native application.", "icons": { "16": "icons/icon_windows.png", "48": "icons/icon_windows.png", "128": "icons/icon_windows.png" }, "app": { "launch": { "local_path": "main.html" } }, "permissions": [ "nativeMessaging" ] } main.html: <!DOCTYPE html> <html> <head> <script src='./main.js'></script> </head> <body> <button id='connect-button'>Connect</button> <input id='input-text' type='text' /> <button id='send... 閱讀完整內容
Little Endian VS Big Endian 10月 16, 2019 Endianness, 當一個資料要儲存到記憶體時 有兩種儲存方式, 如上圖其一為 Little Endian, 另一為 Big Endian 通常而言不需要考慮此排列方式的問題, 但是當要將資料傳遞到別的硬體平台上,或是網路上時 這問題就變得需要在意了, 在網路傳輸上使用的是 Big Endian, Kernel 中也有提供 htonl, htons, ntohs, ntohl 等 function 幫助將資料在 Big Endian 及 機器的 Endian 之間作轉換 ~ 目前也有平台是支援多種 Endianness 的 ex: ARM, PowerPC, MIPS … 透過硬體上的一個 Register 來設定要使用那種方式 當拿到一個新的硬體時,要如何得知此硬體目前使用的是哪一種 Endianness 呢? 1. 翻閱 Spec, 一般而言 CPU Spec 上都會標明是哪一種,不過在可以並存的硬體上 就需要別的方式來幫助判斷了。 2. 寫小程式來判別,在此提供兩種程式寫法 2-1 先宣告 integer 0x12345678 再使用一個 char pointer 檢查第一個 byte 存 0x12 or 0x78 #include int main() { int a = 0x12345678; char *ptr = (char *)&a; if (*ptr == 0x12) printf("Big Endian\n"); else printf("Little Endian\n"); return 0; } 2-2 使用 htonl 來幫忙 剛剛有提到 htonl 會將資料轉成 Big Endian,若轉換前後一致那就是 Big endian 啦 #include int main() { int a = 0x12345678; int b = htonl(a); if (b == a) printf("Big Endian\n"); el... 閱讀完整內容
Electron - 跨平台的視窗應用程式 2月 14, 2020 一、Electron介紹 Electron Logo Electron(原名為Atom Shell)是 GitHub 開發的一個 開源 框架 。 [5] 它允許使用 Node.js (作為後端)和 Chromium (作為前端)完成桌面 GUI 應用程式 的開發。Electron現已被多個開源 Web應用程式 用於前端與後端的開發,著名專案包括GitHub的 Atom 和 微軟 的 Visual Studio Code 。 由於開發環境就是基於 Node.js ,請務必安裝好。 很多知名的桌面應用程式都是使用 Electron 開發的例如: Github Desktop Discord WordPress.com Visual Studio Code Slack Atom 二、專案建立 以下實務操作將建立一個桌面鬧鐘通知應用程式,此範例從 此處 學習 首先我們建立專案資料夾,並初始化: mkdir electron-alarm-clock && cd electron-alarm-clock npm init -y 你可以直接手動新增資料夾,然後進入(可以不用這麼工程師的方式) 進入專案後使用終端機輸入 npm init -y 進行初始專案(-y 是將詢問的條件通通默認 yes) 安裝 electron: npm install --save--dev electron --save-dev 會將指定套件存於 package.json 的 devDependencies 因為 electron 只有開發階段才需要用到,因此只需要 --save--dev 在 package.json 修改程式進入點位置: 在 main 的部分,將 index.js 改為 main.js 。 在 script 的部分,新增 start 。 [ package.json ] { "name": "electron-alarm-clock", "version": "1.0.0", "description": "... 閱讀完整內容
留言
張貼留言