2016年7月7日 星期四

mac, vim color

1- Create this file 

vim ~/ .vimrc



2- Add this content in .vimrc

filetype plugin indent on
syntax on

set t_Co=256

set term=builtin_beos-ansi

set term=builtin_ansi


set term=xterm-256color

django tutorial

installation :

pip install Django 

django-admin startproject mysite

python manage.py migrate

python manage.py runserver



  • manage.py: A command-line utility 
  •  mysite/ directory is the Python package for the project. Its name is the Python package name you’ll need to use to import anything inside it (e.g. mysite.urls).
  • mysite/__init__.py: An empty file, considered a Python package.
  • mysite/settings.py: Settings/configuration
  • mysite/urls.py: The URL declarations for this Django project; a “table of contents” of your Django-powered site. You can read more about URLs in URL dispatcher.
  • mysite/wsgi.py: An entry-point for WSGI-compatible web servers to serve your project. See How to deploy with WSGI for more details.


model - migrate 
DB





Module, package:

2016年7月5日 星期二

google storage nodejs 上傳教學

最近在整合 node server 檔案上傳到google cloud storage , 發現可以的工具只有 google 官方推出gcloud 工具. 但缺少和前端 檔案上傳 和 ACL 設定, 所以為大家介紹第三方套件, 針對上傳檔案到 google cloud storage 而設計 ,

https://www.npmjs.com/package/gcloud-storage-api



  • 提供3個google cloud storage 檔案的function , 

前2個上傳function, uploadLocalFile 和 uploadBuffer 而且設定為public link 下載, 以 formidable 方式 獲得multipart 檔案和 json:
  • googleAPI.uploadLocalFile(BUCKET_NAME, fileName, fileLocalPath)
  • googleAPI.uploadBuffer(BUCKET_NAME, fileName, buffer)
  • googleAPI.deleteStorageFile(url)



  • 安裝:

$ npm install --save gcloud-storage-api



  • 使用:

service-key 和 account  的設定可以參考官方教學:

https://www.npmjs.com/package/gcloud


1- 到google cloud console 中新增 Credentials, 選 service account key



2- key 類型選 JSON , 檔案下載請放到nodejs 的目錄底下


3- 成功下載的service-key.json 

4- service-key.json 的內容如下
{
  "private_key_id": "******",
  "private_key": "******",
  "client_email": "******",
  "client_id": "******",
  "type": "service_account"
}

5- node_modules/gcloud-upload-api 有一個測試用的html 檔案, 可以用作測試












google storage nodejs 上傳教學

最近在整合 node server 檔案上傳到google cloud storage , 發現可以的工具只有 google 官方推出gcloud 工具. 但缺少和前端 檔案上傳 和 ACL 設定, 所以為大家介紹第三方套件, 針對上傳檔案到 google cloud storage 而設計 ,

https://www.npmjs.com/package/gcloud-storage-api



  • 提供3個google cloud storage 檔案的function , 

前2個上傳function, uploadLocalFile 和 uploadBuffer  是以 formidable 方式 獲得multipart 檔案和 json:

  • googleAPI.uploadLocalFile(BUCKET_NAME, fileName, fileLocalPath)
  • googleAPI.uploadBuffer(BUCKET_NAME, fileName, buffer)
  • googleAPI.deleteStorageFile(url)



  • 安裝:

$ npm install --save gcloud-storage-api



  • 使用:

service-key 和 account  的設定可以參考官方教學:

https://www.npmjs.com/package/gcloud


1- 到google cloud console 中新增 Credentials, 選 service account key



2- key 類型選 JSON , 檔案下載請放到nodejs 的目錄底下


3- 成功下載的service-key.json 

4- service-key.json 的內容如下
{
  "private_key_id": "******",
  "private_key": "******",
  "client_email": "******",
  "client_id": "******",
  "type": "service_account"
}

5- node_modules/gcloud-upload-api 有一個測試用的html 檔案, 可以用作測試












2016年6月22日 星期三

tmux



reload config:
tmux source-file ~/.tmux.conf

水平分割
ctrl+a , "

垂直分割
ctrl+a , %

重新命名
ctrl+a , ,

新增 window
ctrl+a , c
tux new -s server
跳到 window 1
ctrl+a , 1
tmux a -t server
看目前視窗
tmux ls

2016年6月19日 星期日

react-native run-android, error,


react-native run-android

Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment


solution:
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1


自訂 command

Valuable:
echo ${abc}
abc=iamabc
echo ${abc}


Export:
abc=iamabcecho ${abc}
//iamabc
bash
//進入到所謂的子程序
echo ${abc}
//null
exit
export abc
bash
echo ${abc}
//iamabc

alias:
alias react-native="node /path/to/this"
react-native