2017年7月7日 星期五

一些常用的 npm 指令

npm 要常更新
$npm i -g npm 

初始化 node project , 建立 package.json
$ npm init

初始化 node project , 有沒有 y 的差別在於,沒有 y 時,npm 會以互動方式詢問要建在 package.json 的項目內容,諸如 package name, description 等等。有 y 時 npm 就會使用預設值,一次建立完成。
$ npm init -y [ --yes ]

範例如下:
D:\tmp\testnpm2>npm init -y
Wrote to D:\tmp\testnpm2\package.json:
{
  "name": "testnpm2",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}


安裝目前目錄下 package.json 下 dependencies 列的套件
$npm install  
全域安裝
套件                                      
$ npm install <package name> -g

移除全域套件
$ npm install <package name> -g

安裝最新版本的 Package
$ npm install <package name>@latest

列出全域套件

$ npm ls -g

更新全域套

$ npm update -g

安裝套件,套件僅列在 devDependencies ,同 --save-dev

npm install <package name> -D   

2017年7月5日 星期三

Firebase CLI 使用

Firebase CLI 主要是用來管理 及部署  firebase 專案,目前常用到的就是初始化專案及佈署 Cloud functions, Hosting SPA ......

首先要安裝 Firebase CLI (當然要先安裝 Node.Js 環境 ) 如下:
$ npm install -g firebase-tools (記得用安裝命令來更新到最新版本) 

再來是登入 Firebase 
$ firebase login  ( 會跳出一個登入畫面 )



還會跳出一個登入成功的頁面



初始化 firebase,要先建立專案目錄,移到該目錄下再執行 INIT。
$ firebase init
選擇要建立的設定檔,有 realtime database rule,cloud functions , Hosting


D:\WorkSpace\firebase\recipe-book-4ng>firebase init

     ######## #### ########  ######## ########     ###     ######  ########
     ##        ##  ##     ## ##       ##     ##  ##   ##  ##       ##
     ######    ##  ########  ######   ########  #########  ######  ######
     ##        ##  ##    ##  ##       ##     ## ##     ##       ## ##
     ##       #### ##     ## ######## ########  ##     ##  ######  ########

You're about to initialize a Firebase project in this directory:

  D:\WorkSpace\firebase\recipe-book-4ng

? Are you ready to proceed? Yes
? Which Firebase CLI features do you want to setup for this folder? Press Space to select features, then Enter to confirm you
r choices. Database: Deploy Firebase Realtime Database Rules, Functions: Configure and deploy Cloud Functions, Hosting: Confi
gure and deploy Firebase Hosting sites

=== Project Setup ( 目前的目錄是要建給哪個 project 用的 )

First, let's associate this project directory with a Firebase project.
You can create multiple project aliases by running firebase use --add,
but for now we'll just set up a default project.

? Select a default Firebase project for this directory: recipe-book-4ng (recipe-book-4ng)

=== Database Setup ( realtime database 的 rule 設定 , 看 firebase console database )

Firebase Realtime Database Rules allow you to define how your data should be
structured and when your data can be read from and written to.

? What file should be used for Database Rules? database.rules.json
+  Database Rules for recipe-book-4ng have been downloaded to database.rules.json.
Future modifications to database.rules.json will update Database Rules when you run
firebase deploy.

=== Functions Setup ( Cloud functions 的功能,執行在 Node.js 環境 )

A functions directory will be created in your project with a Node.js
package pre-configured. Functions can be deployed with firebase deploy.

+  Wrote functions/package.json
+  Wrote functions/index.js
? Do you want to install dependencies with npm now? Yes
npm notice created a lockfile as package-lock.json. You should commit this file.
added 90 packages in 17.299s

=== Hosting Setup (設定 static html page , 使用 Angular 2 建立的 SPA )

Your public directory is the folder (relative to your project directory) that
will contain Hosting assets to be uploaded with firebase deploy. If you
have a build process for your assets, use your build's output directory.

? What do you want to use as your public directory? public
? Configure as a single-page app (rewrite all urls to /index.html)? Yes
+  Wrote public/index.html

i  Writing configuration info to firebase.json...
i  Writing project information to .firebaserc...

+  Firebase initialization complete!



2017年7月3日 星期一

Extend Disk of VirtualBox

剛開始建立 VirtualBox 虛擬機器,只留作業系統的實體空間,以便以後做各種測試環境的來源,可是後來遇到要安裝軟體時,安裝程式會檢查可空間夠不夠用,這時只好乖乖的把存放裝置變大:

1. 先確認虛擬硬碟的位置 ( 虛擬機器 > 設定值)

2.確認大小


3.卸除虛擬硬碟


4. 使用Vboxmanage.exe 命令工具修改檔案大小
( Vboxmanage modifymedium  <fileName>  --resize  <size>


5.然後再把硬碟加回去,開啟虛擬機器,再從系統管理員的硬碟管理工具將未配置的部分,使用延伸磁區加進來


2017年5月31日 星期三

建立 Universal Data Link (.udl) 檔

一個很好用的工具,可以用來建立 Microsoft Data Access Components (MDAC) 資料提供者之間的連接資訊,在 Excel VBA 讀取外部資料建立連線資料時號好用, 常常忘記副檔名,所以寫下來 。

方法很簡單,在當案總管理,新增一個文字文件,然後將 txt 副檔名改成 udl,會發現小圖也會跟這改變。


直接 double click 檔案就可以設定資料連線 


用 notepad 就可以開啟連線字串內容如下:
[oledb]
; Everything after this line is an OLE DB initstring

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=localhost

2017年4月17日 星期一

Install VirtualBox Extension Pack 安裝 VirtualBox 擴充套件

因為想要在我的 VM WINDOW 7 上新增 USB 無法成功,發現我的 USB 版本還是在 1.1 ,所以會顯示驅動程式安裝失敗。

檢查發現我的 USB 控制器還是在 1.1,改成 2.0 時,VM 就出現一個無效設定訊息,要我要安裝擴充套件。



上網看了 一下,要安裝擴充套件(Extension Pack ),才有支援 USB 2.0/3.0 等等。

1.當然第一個要先下載擴充套件,再來在 VM 管理員視窗上,從檔案 > 喜好設定進去

2. 在喜好設定內就可以看到擴充套件 ,以及安裝了那些套件,當然啦,現在一個也沒有...

3. 點選新增按鈕,選擇之前下載的套件檔案,過程還有些版權確認的資訊,都確認過就可將套件加入


4. 安裝完的套件


5. 以上的環境是: HOST : Win 10 專業版 ( x64 ) ,QUEST : Win 7 (x64),VM VirtualBox  5.1.18


2017年4月10日 星期一

VirtualBox 和 Host OS 間的資料交換

Oracle VM Virtual 是個不錯的工具,用來建立測試環境剛剛好, OS 建立起來後,要開始安裝測試必須的軟體,這時需要一個可以將資料傳遞進去的方法,那就是共享目錄,在 QUEST 和 HOST 端建一個共享目錄,再將需要的檔案複製過去:

環境:
HOST : Win 10 專業版,Intel x64
QUEST: Win 7 x64
VM VirtualBox :5.1.18

1 安裝 Guest Additions CD: 從工作列表選裝置  > 插入 Guest Additions CD 映像.


 2 執行 Additions 安裝如下

3 在 HOST 端,建立共用目錄 VirtualShare,並以特定人員建立共用對象

4 將 Everyone 設為讀取


5 在 Guest OS 設定共用資料夾


6 在 Guest OS 將在 HOST 建立的 VirtulaShare 目錄加進來


7 重新啟動 Guest OS ,即可看到 共用目錄






一些常用的 npm 指令

npm 要常更新 $npm i -g npm  初始化 node project , 建立 package.json $ npm init 初始化 node project , 有沒有 y 的差別在於,沒有 y 時,npm 會以互動方式詢問要建在 package.js...