2015年4月27日 星期一

bootstrap 第一天實驗

1.網頁為MVC架構,前端主要為html,javascrip,css三者所構成。
   框架的跟目錄為 \partjs-master\public
   例如:include css檔放在 <link href="/index.css" rel="stylesheet">
   其中index.css所在的目錄為\partjs-master\public\index.css

2.自動更新網頁的工具gulp

  • 安裝gulp: npm -g i gulp
  • 編輯gulpfile.js   在gulp.task('serve', function () 加入
           browserSync.init(null, {

                  server: {
                        baseDir: ['app', '.tmp']
                   },
                  notify: false
          });


         gulp.watch(['public/index.cssl'], reload); 


  • 執行 gulp serve 
3.minify
  • 方法一 grunt build
  • 方法二 修改Gruntfile.js
           uglify: {
                     less: {
                              views: {

                                         files: [{
                                                 expand: true,
                                                 cwd: 'public/',
                                                 src: ['*.css'],
                                                 dest: 'public/',
                                                 ext: '.min.css'
                                         }

                              }   
                     }             
           }
         
         執行grunt less:views
4.jade jade file可編譯成html語法上用縮排來代表巢狀結構
   找到routes.js檔找到//partjs boilerplate
   參考 app.get('/dashboard',requirre(./views/index').dashboard);
   由此可知道在views底下有一個index.jade檔將他打開來後在檔案的頭有一行
   extend layouts/default 然後去views/layouts
   底下找到default.jade就可以找到相對應的jade檔案設定再根據裡面的設定去修改他。


Bootstrap 環境架設

Bootstrap:
1.網頁APP的主流框架,但不知緣目前依些網頁設計工具
2.其特色是使用command line方式來操作

環境架設
windows:
1.安裝node js  https://nodejs.org/
2.安裝python 2.7.X  https://www.python.org/downloads/
3.安裝git for windows  http://git-scm.com/download/win
4.下載 partjs  https://github.com/partjs/partjs  解壓縮到 C:\底下
5.申請 mongolab 帳號 https://mongolab.com/
   在MongoDB deployment增加一個plan,然後在plan創建一個user
6.打開命令提示字元進入C:\partjs-master
7.cp config.example.js config.js
8.然後打開config.js修改紅色字的地方
  uri: process.env.MONGOLAB_URI || process.env.MONGOHQ_URL || 'localhost/drywall'
改成申請的帳號跟密碼'mongodb://<dbuser>:<dbpassword>@ds041387.mongolab.com:41387/moko365_test'
ps:此字串在mongolab中申請得到的
9.install 一些npm工具
   npm update -g bower
   npm i -g bower
   npm -g i forever
   npm -g i grunt-cli
10.執行node app.js
11.開瀏覽器輸入http://localhost:3000/

就可以看到網頁的畫面

一些free source的網站
http://getbootstrap.com/
http://bootsnipp.com/
https://github.com/erikflowers/weather-icons
https://unsplash.com/
http://designmodo.github.io/Flat-UI/


ps:過程中出現"Error: Cannot find module 'express'"這個錯誤
     決方法:執行 npm install



2015年4月17日 星期五

Conversion From ' ' To Non-Scalar Type ' ' Requested

CeMMCDriver *pFDriver = new CeMMCDriver ();
CFlash tflash = new CFlash(pFDriver );

以上的 code編譯後將出現
Conversion From ' CFlash ' To Non-Scalar Type ' CFlash ' Requested 的錯誤

若將程式碼改成
CeMMCDriver *pFDriver = new CeMMCDriver ();
CFlash *tflash = new CFlash(pFDriver );

CeMMCDriver *pFDriver = new CeMMCDriver ();
CFlash *tflash ;
tflash = new CFlash(pFDriver );
則沒問題

2015年3月9日 星期一

在ubuntu 14.04 編譯 linux kernel

首先下載想要的linux kernel
https://www.kernel.org/pub/linux/kernel/v3.x/
然後解壓縮

安裝必要的package:
sudo apt-get install fakeroot build-essential kernel-package libncurses5 libncurses5-dev
sudo dpkg -i kernel-package_13.003_all.deb
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock

接下來設定環境:
kerVer='3.15.7/linux-3.15.7'
KernelPath=$(sudo find /media/vli -name 'Kernel' | grep 'Test_tool')
cd ~/Desktop/
ln -s $KernelPath/$kerVer linux
cd ~/Desktop/linux
cp /boot/config-`uname -r` ./.config

編譯kernel:
sudo make menuconfig
sudo make-kpkg clean
sudo fakeroot make-kpkg --initrd kernel_image kernel_headers

安裝kernel:
sudo dpkg -i linux-image-3.15.8_3.15.8-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-3.15.8_3.15.8-10.00.Custom_amd64.deb

重新開機:
sudo reboot

編譯 linux MMC module

到linux source code的目錄下執行
 sudo make M=drivers/mmc modules

2015年3月4日 星期三

SQL使用範例說明

1.      WCT_trace:ER模型sahaema


共有5table當要使用SQL搜尋需要的資料時可以善加利用這個Schema
2.      幾個簡單SQL範例
(1)   選擇出Blk_Data所有的資料:
selectfrom Blk_Data

(2)選擇出WCT_Table所有的資料:
selectfrom WCT_Table

(3)選擇出Blk_Data當中的LFT_Key,Dat_Addr,count(Dat_Addr)資料當CH_No = 0 and CE_No =0 其中的 Dat_Addr是不重複的:
select LFT_Key,Dat_Addr,count(Dat_Addr)  from Blk_Data where CH_No = 0 and CE_No =0 group by Dat_Addr

       (4)選擇出Blk_Data當中的所有資料當CH_No = 0 and CE_No =0 其中根據 Dat_Addr做排序:
selectfrom Blk_Data where CH_No = 0 and CE_No =0 order by Dat_addr

       (5)選擇出Blk_Data當中的LFT_Key資料當 LFT_Table.TAT_Key = 1 AND             LFT_Table.LFT_Key = Blk_Data.LFT_Key其中Blk_Data.LFT_Key是不重複:


select Blk_Data.LFT_Key from LFT_Table, Blk_Data where LFT_Table.TAT_Key = 1 and LFT_Table.LFT_Key = Blk_Data.LFT_Key group by Blk_Data.LFT_Key

2015年2月17日 星期二

使用eclipse 編譯json函式庫

C語言

參考 https://linuxprograms.wordpress.com/2010/05/20/json-c-libjson-tutorial/

使用終端機


  1. 首先安裝需要的package
  2. 利用以下的測試程式來測試環境
#include <json/json.h>
#include <stdio.h>

int main() {
 char * string = "{"name" : "joys of programming"}";
 json_object * jobj = json_tokener_parse(string);
 enum json_type type = json_object_get_type(jobj);
 printf("type: ",type);
 switch (type) {
 case json_type_null: printf("json_type_nulln");
 break;
 case json_type_boolean: printf("json_type_booleann");
 break;
 case json_type_double: printf("json_type_doublen");
 break;
 case json_type_int: printf("json_type_intn");
 break;
 case json_type_object: printf("json_type_objectn");
 break;
 case json_type_array: printf("json_type_arrayn");
 break;
 case json_type_string: printf("json_type_stringn");
 break;
 }
}
     3.  編譯   gcc json_type.c -l json

使用Eclipse

  1. 建立一個C專案,將上列測試程式加到專案中。
  2. 點專案再按右鍵->Properties->C/C++ General->Paths and Symols ->Includes加入/usr/include/json
  3. 接下來選C/C++ Build->Settings->GCC C++ Linker->Libraries加入json

C++語言

  1. 安裝需要的package # sudo apt-get install libjsoncpp-dev (ubuntu)
  2. 建立一個C++專案將下列程式碼加入
#include <iostream>       // std::cout
#include <string>         // std::string
#include <json/json.h>

int main() {
        std::string raw = "{\"key\":\"value\",\"我\":\"是誰\",\"array\":[\"a\",\"b\",123]}";
        Json::Reader reader;
        Json::Value value;
        std::cout << "Input: " << raw << std::endl;
        if (reader.parse(raw, value)) {
                std::cout << "parsing: " << value ;//<< std::endl;
                std::cout << "get: " << value["我"] ;//<< std::endl;
                std::string data = value["key"].asString();//toStyledString();
                std::cout << "string: [" << data << "]" << std::endl;

                // with -std=c++11
                std::cout << "---" << std::endl;
                for (auto it : value) {
                        std::cout << "elm: " << it ;//<< std::endl;
                        if (it.isArray()) {
                                for (auto it2 : it)
                                        std::cout << "array data: " << it2 ;//<< std::endl;
                        } 
                }         
        } 
        return 0;
}

       3.  點專案再按右鍵->Properties->C/C++ General->Paths and Symols ->Includes加入/usr/include/jsoncpp/json
       4.  接下來選C/C++ Build->Settings->GCC C++ Linker->Libraries加入jsoncpp
       5.  接下來選C/C++ Build->Settings->GCC C++  Compile->include加入/usr/include/jsoncpp/,/opt/local/include/
       6.  接下來選C/C++ Build->Settings->GCC C++  Compile->Dialect->Language standard 選   ISO C++11(-std=c++0x) PS:因為這個測試函數用到C++11的語法。