2017年6月18日 星期日

Line Bot Message API

之前建一個查字典的Line bot,自從Line Bot更新API後,就一直沒時間更新,趁著這大雨的週日,重新建立Line Bot。

參考 這篇 不必真的架站也能 5 分鐘實機體驗 LINE bot – 教學 ( by node.js & ngrok )
很快的又建立起了Line Bot, 搞定了ECHO功能,很快的就接上之前寫的查字典功能。再加上問天氣的功能,沒時間寫parser,直接就帶出網址點來看。
使用 ngrok 這工具真是方便,用本機就可以直接測試。

最後deploy到Heroku,參考這篇 注意設置PORT轉換,和建立package.json,習慣用command line deploy,可參考Heroku官方文件-Deploying with Git




2016年6月12日 星期日

Github 的遠端檔案操作

新增一個檔案

$ ls > test.txt
$ ls
1 README.md node-crawler.js node_modules result.json test.txt

把檔案加入git

$ git add test.txt
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

new file:   test.txt


對加入檔案的動作下個註解

$ git commit -m 'add test.txt'
[master 1b9d497] add test.txt
 1 file changed, 6 insertions(+)
 create mode 100644 test.txt

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

推送到遠端

$ git push
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 323 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/david0932/node-crawler.git
   45e24d1..1b9d497  master -> master









刪除檔案的操作

$ git rm test.txt
rm 'test.txt'

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

deleted:    test.txt

$ git commit -m 'delete test.txt'
[master f6e5af2] delete test.txt
 1 file changed, 6 deletions(-)
 delete mode 100644 test.txt

$ git push
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 218 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To https://github.com/david0932/node-crawler.git
   1b9d497..f6e5af2  master -> master


2016年3月11日 星期五

Real-time weather Information with Onion Omega



Onion Omega是一個使用OpenWRT系統的微型電腦,就用這做個即時天氣小看板。
為了解決中文顯示問題,用了另一台Web Server來解決抓天氣資料和轉換成OLED DATA,Web Server使用PHP和Node.js,Onion Omega 用Python來與Web Server連線與控制OLED。



2015年8月28日 星期五

Node.js with Windows 10 IoT on Raspberry Pi 2

繼續Pi的Windows 10 IoT奇幻旅程,試做Node.js的學習。Follow一些網頁的作法,遇到不少問題,不過,總算是有搞定,做個記錄先。

PC環境設置

  • Install the latest Node.js Tools for Windows IoT from here.
  • Install Python 2.7.


  • Copy Node.js to Pi
    官網是用PowerShell指令操作,有點複雜搞不定,其實用"檔案總管"就可以了。
    將PC上安裝好的Node.js複製到Pi上,再置換node.exe為ARM版本的就好了。



    Build Addon - MemoryStatus
    這程式主要是 node.js 呼叫取得系統中記憶體狀態,需要用到Python 2.7來build.


    Copy Node.js Apps to Pi
    把node.js的執行程式Server.js,和上個步驟所build出來的MemoryStatusAddon.node,copy到Pi。


    Run Node.js App
    這部份就要用PowerShell連到Pi來操作,設定好firewall rule後,就可以執行了。
    用browser連連看…有出現就成功了
    Pi中有Node.js的行程,按X就就可結束

    Reference:
    http://ms-iot.github.io/content/en-US/win10/samples/Nodejs.htm
    http://blogs.windows.com/buildingapps/2015/05/12/bringing-node-js-to-windows-10-iot-core/
    http://ms-iot.github.io/content/en-US/win10/samples/Nodejs.htm
    https://github.com/ms-iot/ntvsiot/releases

    2015年8月26日 星期三

    Raspberry Pi 2 for Windows IoT Core

    Raspberry Pi 2 上跑 Windows IoT Core


    使用Browser連入Pi 2,有相關的裝置資訊和管理介面
    程式App的執行與結束也可透過Web介面管理

    這就像Windows工作管理員一般,顯示執行中的行程
    CPU效能也可在Web上呈現
    也有裝置管理員…cool
    基本網路設定是一定有的,還有藍芽設定
    趕快寫個程式來測試一下,最近剛在做Digital Signage,就用VS 2015寫個Web Browser來連連看





    2014年12月10日 星期三