- 產生個別的 ssh keys
$ cd ~/.ssh $ ssh-keygen -t rsa -C "account1@email.com" -f id_rsa_account1 $ ssh-keygen -t rsa -C "account2@email.com" -f id_rsa_account2
- 建立 config 檔
$ cd ~/.ssh $ touch config $ gedit config
編輯內容如下#account1 Host github.com-account1 HostName github.com User git IdentityFile ~/.ssh/id_rsa_account1 #account2 Host github.com-account2 HostName github.com User git IdentityFile ~/.ssh/id_rsa_account2 - 修改相對應 repo 的 remote url。例如:
$ cd /path/to/repo1 $ git remote set-url origin ssh://git@github.com-account1/account1/repo1.git
- 完成
2013年3月6日 星期三
多個 SSH Key 對應多個 Github 帳號
Git HTTP 協定的檔案大小限制
使用 git push 經由 HTTP 協定的時候要注意了,因為有檔案大小的限制,預設是 1MB。
發生的錯誤訊息如下所示:
發生的錯誤訊息如下所示:
$ git push Counting objects: 199918, done. Delta compression using up to 8 threads. Compressing objects: 100% (188542/188542), done. error: RPC failed; result=22, HTTP code = 413MiB | 53 KiB/s fatal: The remote end hung up unexpectedly Writing objects: 100% (199918/199918), 1.98 GiB | 7.61 MiB/s, done. Total 199918 (delta 55401), reused 0 (delta 0) fatal: The remote end hung up unexpectedly fatal: expected ok/error,...
有兩種方式可以解決這個問題:
- 使用 SSH 來作為 git 的通訊。
- 加大 HTTP 檔案大小限制,如下:
git config http.postBuffer 524288000 #Set to 500MB
2013年2月15日 星期五
Yii 安裝 Bootstrap
安裝方法:
http://www.cniska.net/yii-bootstrap/setup.html
Github 版的 Yii Bootstrap 可以從這邊取得:
https://github.com/joujiahe/yii-bootstrap
注意: 需將 webapp/protected/extensions/bootstrap/theme/* 下的檔案複製到
webapp/themes/bootstrap/
http://www.cniska.net/yii-bootstrap/setup.html
Github 版的 Yii Bootstrap 可以從這邊取得:
https://github.com/joujiahe/yii-bootstrap
注意: 需將 webapp/protected/extensions/bootstrap/theme/* 下的檔案複製到
webapp/themes/bootstrap/
Yii 使用偽靜態網址
在 webapp 下新增一個 .htaccess 檔,並將以下內容複製貼上:
修改 webapp/protected/config/main.php 設定檔來啟用 urlManager:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
修改 webapp/protected/config/main.php 設定檔來啟用 urlManager:
// uncomment the following to enable URLs in path-format 'urlManager'=>array( 'urlFormat'=>'path', 'showScriptName'=>false, 'urlSuffix'=>'.html', 'rules'=>array( '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),這樣就可以將 index.php 藏起來並偽裝成 .html 的網址了。
2013年2月7日 星期四
Yii 抽象資料庫欄位類型的支援
Yii Migration 支援多種抽象欄位類型,如下所示:
- pk: an auto-incremental primary key type, will be converted into "int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY"
- string: string type, will be converted into "varchar(255)"
- text: a long string type, will be converted into "text"
- integer: integer type, will be converted into "int(11)"
- boolean: boolean type, will be converted into "tinyint(1)"
- float: float number type, will be converted into "float"
- decimal: decimal number type, will be converted into "decimal"
- datetime: datetime type, will be converted into "datetime"
- timestamp: timestamp type, will be converted into "timestamp"
- time: time type, will be converted into "time"
- date: date type, will be converted into "date"
- binary: binary data type, will be converted into "blob"
訂閱:
文章 (Atom)