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日 星期三

    2014年7月28日 星期一

    fbi : linux framebuffer imageviewer

    pi@raspberrypi ~ $ sudo fbi -d /dev/fb0 -a -T 2 raspi.png
    using "Droid Sans Fallback-16", pixelsize=16.67 file=/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf
    pi@raspberrypi ~ $ ps -aux |grep fbi
    warning: bad ps syntax, perhaps a bogus '-'?
    See http://gitorious.org/procps/procps/blobs/master/Documentation/FAQ
    root      3991 17.0 12.4  34252 15308 ?        Ss   10:35   0:01 fbi -d /dev/fb0 -a -T 2 raspi.png
    pi        3993  0.0  0.7   3932   880 pts/0    S+   10:35   0:00 grep --color=auto fbi
    pi@raspberrypi ~ $ sudo kill 3991



    pi@raspberrypi ~ $ fbi

    This program displays images using the Linux framebuffer device.
    Supported formats: PhotoCD, jpeg, ppm, gif, tiff, xwd, bmp, png.
    It tries to use ImageMagick's convert for unknown file formats.

    usage: fbi [ options ] file1 file2 ... fileN

        -h  -help               print this help text
        -V  -version            print fbi version number
            -store              write cmd line args to config file
        -l  -list <arg>         read image filelist from file <arg>
        -P  -text               switch into text reading mode
        -a  -autozoom           automagically pick useful zoom factor
            -(no)autoup           like the above, but upscale only
            -(no)autodown         like the above, but downscale only
            -(no)fitwidth         use width only for autoscaling
        -v  -(no)verbose        show filenames all the time
        -u  -(no)random         show files in a random order
        -1  -(no)once           don't loop (for use with -t)
            -(no)comments       display image comments
        -e  -(no)edit           enable editing commands (see man page)
            -(no)backup           create backup files when editing
            -(no)preserve         preserve timestamps when editing
            -(no)readahead      read ahead images into cache
            -cachemem <arg>     image cache size in megabytes
            -blend <arg>        image blend time in miliseconds
        -T  -vt <arg>           start on virtual console <arg>
        -s  -scroll <arg>       scroll image by <arg> pixels
        -t  -timeout <arg>      load next image after <arg> sec without user input
        -r  -resolution <arg>   pick PhotoCD resolution (1..5)
        -g  -gamma <arg>        set display gamma (doesn't work on all hardware)
        -f  -font <arg>         use font <arg> (anything fontconfig accepts)
        -d  -device <arg>       use framebuffer device <arg>
        -m  -mode <arg>         use video mode <arg> (from /etc/fb.modes)

    Large images can be scrolled using the cursor keys.  Zoom in/out
    works with '+' and '-'.  Use ESC or 'q' to quit.  Space and PgDn
    show the next, PgUp shows the previous image. Jumping to a image
    works with <number>g.  Return acts like Space but additionally
    prints the filename of the currently displayed image to stdout.

    reference: http://manpages.ubuntu.com/manpages/lucid/man1/fbi.1.html


    pi@raspberrypi ~ $ sudo fbi -d /dev/fb0 -a -T 2 -t 5 -1 *.png
    --> loop once *.png to /dev/fb0 , and 5 seconds interval to next picture.