บทความ

กำลังแสดงโพสต์จาก 2023

เชื่อมต่อ Web Application ผ่าน Websocket กับ MQTT Broker ด้วย Paho MQTT

รูปภาพ
เพิ่ม Script ใน tag <header> จาก CDNJS <script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.1.0/paho-mqtt.min.js"></script> สร้าง Client Instance ของ Paho MQTT ด้วยคำสั่ง let client = new Paho.Client("<broker-url>", Number(<port>), "<client-id>"); สร้างฟังก์ชั่น onConnect ทำการเชื่อมต่อและ subscribe ไปยัง topic ด้วยคำสั่ง                             const onConnect = () => {                                      console.log("Connected");                                      console.log("Subscribing to topic: <topic-name>");                            ...

Git Command

รูปภาพ
เริ่มต้นสร้าง Git repository หรือสร้างโฟลเดอร์ .git (hidden folder) ด้วยคำสั่ง git init เพิ่มไฟล์เข้าไปใน staging area ด้วยคำสั่ง git add <file name> หรือ git add . เพื่อ add ไฟล์ทั้งหมด Commit ไฟล์ไปยัง local repository ด้วยคำสั่ง git commit -m "<commit-message>" ตรวจสอบสถานะของไฟล์ด้วยคำสั่ง git status ตรวจสอบ remote repository ด้วยคำสั่ง git remote -v Add remote repository ด้วยคำสั่ง git remote add <remote-name> <remote-url> เปลี่ยน remote url ด้วยคำสั่ง git remote set-url <remote-name> <new-remote-url> ลบ remote repository ด้วยคำสั่ง git remote rm <remote-name> ตรวจสอบ branch ปัจจุบันด้วยคำสั่ง git branch ตรวจสอบ branch ทั้งหมดด้วยคำสั่ง git branch -a เปลี่ยนชื่อ branch ปัจจุบันด้วยคำสั่ง git branch -M <new-branch-name> สร้าง branch ใหม่ด้วยคำสั่ง git branch <new-branch-name> เปลี่ยน branch ปัจจุบันด้วยคำสั่ง git checkout <branch-name> ลบ local branch ด้วยคำสั่ง git branch -d <branch-name> ลบ remote branch ...

Deploy React App บน GitHub Page

รูปภาพ
  ติดตั้ง gh-pages npm package ด้วยคำสั่ง npm install gh-pages เพิ่ม homepage property ในไฟล์ package.json "homepage": "https://<username>.github.io/<repository-name>" เพิ่ม predeploy และ deploy ใน script ของไฟล์ package.json "predeploy": "npm run build", "deploy": "gh-pages -d build" Add remote repository ด้วยคำสั่ง git remote add origin https://github.com/<username>/<repository-name>.git Push React app ด้วยคำสั่ง npm run deploy หรือ npm run deploy -- -m "<commit-message>" npm จะทำการ build ไฟล์เก็บไว้ในโฟลเดอร์ build แล้ว deploy ขึ้นไปที่ gh-pages branch หากต้องการเก็บ React app source code ไว้บน GitHub สามารถใช้คำสั่ง git add . git commit -m "<commit-message>" git push origin main React app source code จะถูกเก็บใน main branch build file จะถูกเก็บใน gh-pages branch แหล่งอ้างอิง  https://github.com/gitname/react-gh-pages

Docker Command

รูปภาพ
docker --version ตรวจสอบการติดตั้ง Docker + ตรวจสอบ version docker ps ตรวจสอบ Container ที่ run อยู่ ps (process) docker ps -a  ตรวจสอบ Container ทั้งหมด -a (all) docker run -it --name <container name> -p <user port:container port> <image name:tag> Run container จาก image -it (interactive) และ -p (port) โดยเป็นการ expose user post กับ container port ถ้าเปลี่ยนจาก -it เป็น -d (daemon) จะเป็น background running docker stop <container name> หยุดการ run container ตามชื่อ container docker start <container name> เริ่มการ run container ตามชื่อ container docker exec -it <container name> bash ทำการ SSH เข้าไปใน container ตามชื่อ container exit ออกจาก SSH docker rm <container name> ลบ container ตามชื่อ container โดยต้อง stop container ก่อน docker rm -f <container name> ลบ container ตามชื่อ container แบบบังคับลบ -f (force) docker images ตรวจสอบ image ทั้งหมดที่มีอยู่ docker pull <image name:tag> ดึง image มาจาก Docker hub docker b...

ขั้นตอนการประกอบติดตั้ง KAT Walk C2

รูปภาพ
 

เปลี่ยนสีและ Weight ของ Text ใน Arduino IDE ผ่าน Theme

ไฟล์ theme.txt จะอยู่ใน C:/Program Files (x86)/Arduino/lib/theme ซึ่งจะต้องใช้สิทธิ์ Administrator ในการแก้ไขไฟล์ แต่เราสามารถ Copy ไฟล์ theme.txt แล้วเปลี่ยนชื่อไฟล์ theme.txt เดิมเป็นชื่ออื่น เช่น default-theme.txt จากนั้น้ราก็แก้ไขไฟล์ theme.txt ได้โดยไม่จำเป็นต้องใช้สิทธิ์ Administrator ส่วนที่ 1 Keywords # TEXT - KEYWORDS # FUNCTIONS editor.keyword1.style = #E06C75,bold editor.data_type.style = #E06C75,bold           บรรทัดนี้คือคำสั่ง Serial, WiFi, etc.                                                                         ซึ่งเป็น Built-in library # METHODS editor.keyword2.style = #E06C75,plain editor.function.style = #61AFEF,plain             ...

ทดสอบความเร็วในการอ่าน/เขียน Storage รูปแบบต่างๆ ด้วยซอฟต์แวร์ CrystalDiskMark 8

รูปภาพ
ผลการทดสอบมีดังต่อไปนี้ 1) Sandisk USB flash drive ขนาด 64 GB (exFAT) 2) Sandisk USB flash drive ขนาด 64 GB (NTFS) 3) Sandisk USB flash drive ขนาด 32 GB (FAT32) 4) Kingston SD card 8 GB (FAT32) 5) WD SATA SSD 2 TB (NTFS) 6) Toshiba M.2 SSD 512 GB (NTFS) Link สำหรับดาวน์โหลดซอฟต์แวร์ :  https://crystalmark.info/en/software/crystaldiskmark/ Link วิดีโอสอนการใช้งานซอฟต์แวร์ :