Wednesday, March 24, 2010
Tuesday, March 23, 2010
[miranda] google talk
google talk實際用的protocol是Jabber
http://miranda.wikia.com/wiki/Google_Talk
http://www.google.com/talk/otherclients.html
Gmail Multiple Notifier (Unicode) 0.4.0.10
http://addons.miranda-im.org/details.php?action=viewfile&id=3677
http://miranda.wikia.com/wiki/Google_Talk
http://www.google.com/talk/otherclients.html
Gmail Multiple Notifier (Unicode) 0.4.0.10
http://addons.miranda-im.org/details.php?action=viewfile&id=3677
Labels:
miranda
[AJAX] GET cache problem
避免cache的作法 (利用timestamp傳不同get參數)
在url後面加個 '?q=' +new Date().getTime()
jQuery(".del").click( function() {
delPicId = jQuery(this).attr("id").charAt(3);
jQuery.getJSON("blah/"+delPicId +"?q="+new Date().getTime(),
function(data){
jQuery("#pic"+delPicId).attr("src", 'webroot?>img/blah.jpg');
}
);
});
delPicId = jQuery(this).attr("id").charAt(3);
jQuery.getJSON("blah/"+delPicId +"?q="+new Date().getTime(),
function(data){
jQuery("#pic"+delPicId).attr("src", 'webroot?>img/blah.jpg');
}
);
});
Monday, March 22, 2010
[CakePHP] validation
寫在model的 $validate array中
驗證方式
1) 自己寫function
2) 自己寫regex (cake使用preg_match)
3) 使用系統的rule
var $validate = array(
'nickname'=> array('rule'=>'checkNickname', 'required'=>false, 'message'=>'長度超過限制'),
'gander'=> array('rule'=>'/^1|0$/', 'required'=>false, 'on'=>'update'),
'height'=> array('rule'=>'numeric', 'required'=>false, 'allowEmpty'=>false, 'on'=>'update'),
);
function checkNickname($check) {
$value = array_values($check);
$value = $value[0];
$value = iconv('UTF-8', 'BIG5', $value);
if ($value && strlen($value)<=16)
return true;
else
return false;
}
驗證方式
1) 自己寫function
2) 自己寫regex (cake使用preg_match)
3) 使用系統的rule
var $validate = array(
'nickname'=> array('rule'=>'checkNickname', 'required'=>false, 'message'=>'長度超過限制'),
'gander'=> array('rule'=>'/^1|0$/', 'required'=>false, 'on'=>'update'),
'height'=> array('rule'=>'numeric', 'required'=>false, 'allowEmpty'=>false, 'on'=>'update'),
);
function checkNickname($check) {
$value = array_values($check);
$value = $value[0];
$value = iconv('UTF-8', 'BIG5', $value);
if ($value && strlen($value)<=16)
return true;
else
return false;
}
Labels:
CakePHP
[MySQL]optimization
EXPLAIN (瞭解MySQL如何處理select)
Ex: EXPLAIN select * from users.users
GROUP BY xxx,預設會對xxx欄位做sort,如果不希望sort要加ORDER BY NULL
Table欄位的順序也會影響到query的效率(primary key, unique index, index, normal columns)
Ex: EXPLAIN select * from users.users
GROUP BY xxx,預設會對xxx欄位做sort,如果不希望sort要加ORDER BY NULL
Table欄位的順序也會影響到query的效率(primary key, unique index, index, normal columns)
Labels:
mysql
[js] swap image
/*
img jQuery object of img tag element
new img suffix
1/0 suffix or not
*/
function imgSwap(img, suffix, state) {
// ext/. -3 -1
var img_src = img.attr("src");
var suffix_pos = img_src.length -4 -suffix.length;
var img_src_suffix = img_src.substr(suffix_pos, suffix.length);
var img_src_ext = img_src.substr(img_src.length-4);
if (state == 1 && img_src_suffix != suffix)
{
//prefix + suffix + ext
img.attr("src", img_src.substr(0, img_src.length-4) + suffix + img_src_ext );
}
else if (state ==0 && img_src_suffix == suffix)
{
//prefix + ext
img.attr("src", img_src.substr(0, suffix_pos) + img_src_ext );
}
}
function a_blur() {
jQuery("a").focus( function() { this.blur(); return false; } );
}
使用,1是over,0是mouse out
jQuery(".swap").hover(
function(){ imgSwap(jQuery(this), "-over", 1) },
function(){ imgSwap(jQuery(this), "-over", 0) }
);
img jQuery object of img tag element
new img suffix
1/0 suffix or not
*/
function imgSwap(img, suffix, state) {
// ext/. -3 -1
var img_src = img.attr("src");
var suffix_pos = img_src.length -4 -suffix.length;
var img_src_suffix = img_src.substr(suffix_pos, suffix.length);
var img_src_ext = img_src.substr(img_src.length-4);
if (state == 1 && img_src_suffix != suffix)
{
//prefix + suffix + ext
img.attr("src", img_src.substr(0, img_src.length-4) + suffix + img_src_ext );
}
else if (state ==0 && img_src_suffix == suffix)
{
//prefix + ext
img.attr("src", img_src.substr(0, suffix_pos) + img_src_ext );
}
}
function a_blur() {
jQuery("a").focus( function() { this.blur(); return false; } );
}
使用,1是over,0是mouse out
jQuery(".swap").hover(
function(){ imgSwap(jQuery(this), "-over", 1) },
function(){ imgSwap(jQuery(this), "-over", 0) }
);
[CakePHP] use model in component or model
$a = ClassRegistry::init('a');
$options['fields'] = array('a.eventname', 'a.event_pic');
$options['joins'] = array(
array('table' => 'soul_match_event_join',
'alias' => 'b',
'type' => 'INNER',
'conditions' => array( 'a.id = b.event_id'),
)
);
$options['conditions'] = array( 'b.uid' => $uid);
$options['order'] = array( 'a.id DESC');
$result2 = $a->find('first', $options);
if ($result2){
$res[$this->name]['event_name'] = $result2['a']['eventname'];
$res[$this->name]['event_pic'] = $result2['a']['event_pic'];
}
$options['fields'] = array('a.eventname', 'a.event_pic');
$options['joins'] = array(
array('table' => 'soul_match_event_join',
'alias' => 'b',
'type' => 'INNER',
'conditions' => array( 'a.id = b.event_id'),
)
);
$options['conditions'] = array( 'b.uid' => $uid);
$options['order'] = array( 'a.id DESC');
$result2 = $a->find('first', $options);
if ($result2){
$res[$this->name]['event_name'] = $result2['a']['eventname'];
$res[$this->name]['event_pic'] = $result2['a']['event_pic'];
}
Labels:
CakePHP
[vim] .ctp syntax highlight
root@h7dev06:~$ cat ~/.vim/ftdetect/ctp.vim
au BufRead,BufNewFile *.ctp set filetype=php
au BufRead,BufNewFile *.ctp set filetype=php
Labels:
vim
Friday, March 19, 2010
[vim] .vimrc
set shiftwidth=4
set tabstop=4
set t_Co=8
set t_Sf=^[[1;3%p1%dm
set t_Sb=^[[1;4%p1%dm
" set autoindent
set fileencoding=utf-8
highlight Comment ctermbg=4 ctermfg=6
syntax on
set ruler
set hlsearch
set showcmd
set backup
set patchmode=.orig
" set nu
" 讓"upper-case"被當成word
set iskeyword+=-
set showmatch
" set softtabstop=4
set expandtab
set tabstop=4
set t_Co=8
set t_Sf=^[[1;3%p1%dm
set t_Sb=^[[1;4%p1%dm
" set autoindent
set fileencoding=utf-8
highlight Comment ctermbg=4 ctermfg=6
syntax on
set ruler
set hlsearch
set showcmd
set backup
set patchmode=.orig
" set nu
" 讓"upper-case"被當成word
set iskeyword+=-
set showmatch
" set softtabstop=4
set expandtab
Labels:
vim
[SVN] command line
SVNBook
http://svnbook.red-bean.com/nightly/en/index.html
不 使用svn command line的請略過
svn st 檢查local檔案修改狀態
changelist (cl): Associate (or dissociate) changelist CLNAME with the named files.
svn cl
http://svnbook.red-bean.com/nightly/en/index.html
不 使用svn command line的請略過
svn st 檢查local檔案修改狀態
changelist (cl): Associate (or dissociate) changelist CLNAME with the named files.
svn cl
ex:
改東西時先加入list
svn cl pay xxx.php
要commit時
svn ci --cl pay
property
svn:ignore svn會略過的東西
svn ps svn:ignore
property
svn:ignore svn會略過的東西
svn ps svn:ignore
copy目錄時要小心
原目錄的/.svn 也會被一起copy
commit時,會commit進原目錄
要先砍掉目錄內的.svn,再重加進svn
filelist可以先處理過會比較好
sort -u svn_xxx.txt
[Mysql] db export, import
Dump db to your localhost (windows)
notice : mysql tool navicat is forbidden because using this tool is prone to delete data by accident. ( This stupid thing happened indeed )
1. Download MySql GUI ( http://dev.mysql.com/downloads/gui-tools/5.0.html )
2. Open MySql Migration
....
notice : mysql tool navicat is forbidden because using this tool is prone to delete data by accident. ( This stupid thing happened indeed )
1. Download MySql GUI ( http://dev.mysql.com/downloads/gui-tools/5.0.html )
2. Open MySql Migration
....
Dump MySQL db ( by MySQLdump)
使用--skip-create-options避免使用MySQL table specific option,避開新舊版本相容性
--quick 抓一個row就存一次,避免memory不夠裝滿整個table
--skip-lock-tables 不lock table
倒整個db
mysqldump --skip-create-options --quick --skip-lock-tables -u php -p -C -h 10.15.2.2 -B users soulmatch vhost14168 portrait gdaa arc smartmatrix adsmart > all_db.sql
我用上面的方法,某些table的primary key會沒有autoincrement,會出錯(不是全部,只有部份會沒有autoincrement)
可用手動在MySQL GUI query browser中複製出create table statement,再貼成一個檔案
只倒table data(一次一個db比較ok, 大小不會太大)
mysqldump -u 帳號 -p密碼 -h 10.15.2.21 --skip-opt --no-create-db --no-create-info --disable-keys --extended-insert --set-charset --skip-add-locks --skip-quick --databases users > d:\data_users.sql
Restore dumped db
mysql -u root -p < all_db.sqlmysql -u root -p dbname < table.sql
SQL query
有使用到中文時,要設定使用utf-8
mysql --default-character-set=utf8
PS. MySQL query browser 1.2.17不支援中文(或utf-8)
Labels:
mysql
[CakePHP] 元件重複利用
靜態頁面
echo $this->renderElement('blah');
動態內容頁面
array based cake style url
This allows the requestAction call to bypass the usage of Router::url which can increase performance.
echo $this->renderElement('blah');
動態內容頁面
requestAction
requestAction(string $url, array $options)
You can use requestAction()
to retrieve a fully rendered view by passing 'return' in the options: requestAction($url, array('return'));
array based cake style url
$this->requestAction(array('controller' => 'articles', 'action' => 'featured'), array('return'));
This allows the requestAction call to bypass the usage of Router::url which can increase performance.
測試結果只有 $options有給 return才有效,沒給return都是no return (another cake bug??)
[CakePHP] constant & variable
本機目錄
WWW (...user2/app/webroot)
IMAGES (...user2/app/webroot/img)
...etc
給url使用
$this->webroot (/users2/app/webroot/)
WWW (...user2/app/webroot)
IMAGES (...user2/app/webroot/img)
...etc
給url使用
$this->webroot (/users2/app/webroot/)
[jQuery] Accordion
http://jqueryui.com/demos/accordion/
http://bassistance.de/jquery-plugins/jquery-plugin-accordion/
jQuery("#menu_block").accordion({ event: 'mouseover', animated: false, autoHeight: false });
a包主選單,div包選取主選單時展開的內容
http://bassistance.de/jquery-plugins/jquery-plugin-accordion/
jQuery("#menu_block").accordion({ event: 'mouseover', animated: false, autoHeight: false });
a包主選單,div包選取主選單時展開的內容
[jQuery] disable rightclick
- $(document).ready(function(){
- $(document).bind("contextmenu",function(e){
- return false;
- });
- });
- W3C has added the method
preventDefault()
to the event. If you call it the default action is prevented. - Microsoft has added the property
returnValue
to the event. If you set it tofalse
the default action is prevented.
[jQuery] context
jQuery selector在找東西的時候會限制在context裡面找,不會找整個dom,better performance
var right_block = jQuery('#right_block');
jQuery("#close_fill", right_block).click( function() {
jQuery("#fill_info", right_block).css('display', '
});
var right_block = jQuery('#right_block');
jQuery("#close_fill", right_block).click( function() {
jQuery("#fill_info", right_block).css('display', '
});
[AJAX] load page
要讀取一個頁面插入網頁
jQuery可用Ajax.load
Prototype可用Ajax.Updater
用 jQuery,ctp中的js不會執行(好像是firefox會發生...忘了)
用Protoype,IE不會吃寫在ctp的css,一 定要寫在css檔中連結進來才有效
為了避免不同AJAX頁面的css衝突
1) 用js動態讀取/卸載css檔 (jQuery plugin xLazyLoader,1.4版會進jQuery)
2) 在id和class的naming都加入AJAX page的prefix
在ctp中
定義的function
連結的js檔
echo $javascript->link('jquery/jquery-1.3.2.min');
都不會起作用 (因為prototype是用eval來執行AJAX頁面的javascript)
jQuery可用Ajax.load
Prototype可用Ajax.Updater
用 jQuery,ctp中的js不會執行(好像是firefox會發生...忘了)
用Protoype,IE不會吃寫在ctp的css,一 定要寫在css檔中連結進來才有效
為了避免不同AJAX頁面的css衝突
1) 用js動態讀取/卸載css檔 (jQuery plugin xLazyLoader,1.4版會進jQuery)
2) 在id和class的naming都加入AJAX page的prefix
在ctp中
定義的function
連結的js檔
echo $javascript->link('jquery/jquery-1.3.2.min');
都不會起作用 (因為prototype是用eval來執行AJAX頁面的javascript)
[AJAX] form送出資料
jQuery可以用Ajax/serialize 把form的element都轉成query string再用Ajax
或是jQuery form plugin http://www.malsup.com/jquery/form/
Prototype 直接對form用 request就可以了
參考
$('submit').observe('click', function(){
$("info-form").request( {onSuccess: function(r) {
switch(r.responseJSON.error) {
case 0:
alert(r.responseJSON.result);
break;
}
} } );
} );
我是覺得用jQuery比較方便
Prototype需要在php令外送header才能接受json
用jQuery做AJAX post的範例 (補填個人資料)
jQuery("#send", right_block).click( function() {
jQuery.post('action_url',jQuery("#form_fill_info", right_block).serialize(),
function(data){
alert(data.msg);
if (data.error == 0)
jQuery("#fill_info", right_block).css('display', 'none');
},'json'
);
});
或是jQuery form plugin http://www.malsup.com/jquery/form/
Prototype 直接對form用 request就可以了
參考
$('submit').observe('click', function(){
$("info-form").request( {onSuccess: function(r) {
switch(r.responseJSON.error) {
case 0:
alert(r.responseJSON.result);
break;
}
} } );
} );
我是覺得用jQuery比較方便
Prototype需要在php令外送header才能接受json
用jQuery做AJAX post的範例 (補填個人資料)
jQuery("#send", right_block).click( function() {
jQuery.post('action_url',jQuery("#form_fill_info", right_block).serialize(),
function(data){
alert(data.msg);
if (data.error == 0)
jQuery("#fill_info", right_block).css('display', 'none');
},'json'
);
});
Windows開發環境設定
hosts檔(懶人設定)
位置
%SystemRoot%\system32\drivers\etc\
10.1.1.220 test1
10.15.2.x dev
10.15.2.21 h7
以後就不用打ip了10.15.2.x dev
10.15.2.21 h7
===DreamWeaver設定===
手動加入ctp在php的地方就可支援cakephp
C:\Program Files\Macromedia\Dreamweaver 8\Configuration\DocumentTypes\MMDocumentTypes.xml
C:\Documents and Settings\[username]\Application Data\Adobe\Dreamweaver 9\Configuration\Extensions.txt
===
utf8 codepage 65001 for WinMerge ...etc
Labels:
work
[網頁] 點連結後不出現虛線框
原理是在出現後馬上用blur()消除
去除連結 的虛線框
TEXT
jQuery("#menu_block a").focus( function() { this.blur(); return false;} );
去除連結 的虛線框
TEXT
[Python] file list_converter
#!/usr/bin/env python3.1
#把file list檔案轉成目前的os目錄格式
import sys
import os
import re
svn = 'svn up ' #svn program and argument
pattern = re.compile('(?:\\\\|/)')
pattern2 = re.compile('(?:\\n+|\\r+)') #line feed & carriage return
with open(sys.argv[1], 'r') as f:
with open(sys.argv[1] + '_out.txt', 'w') as out:
with open(sys.argv[1] + '_one.txt', 'w') as one:
one.write(svn)
for line in f:
line = pattern.sub(os.sep, line)
out.write(line)
line = pattern2.sub(' ', line)
one.write(line)
one.close()
out.close()
f.close()
#把file list檔案轉成目前的os目錄格式
import sys
import os
import re
svn = 'svn up ' #svn program and argument
pattern = re.compile('(?:\\\\|/)')
pattern2 = re.compile('(?:\\n+|\\r+)') #line feed & carriage return
with open(sys.argv[1], 'r') as f:
with open(sys.argv[1] + '_out.txt', 'w') as out:
with open(sys.argv[1] + '_one.txt', 'w') as one:
one.write(svn)
for line in f:
line = pattern.sub(os.sep, line)
out.write(line)
line = pattern2.sub(' ', line)
one.write(line)
one.close()
out.close()
f.close()
[CakePHP] debug mode under conditions
在php檔最前面開debug mode的方法
/app/config/core.php限用
Configure::write('Session.save', 'php');
session使用php的機制,不是cake或database
session_start();
if ($_SESSION['userid']==51489) {
Configure::write('debug', 3);
}
/app/config/core.php限用
Configure::write('Session.save', 'php');
session使用php的機制,不是cake或database
session_start();
if ($_SESSION['userid']==51489) {
Configure::write('debug', 3);
}
Labels:
CakePHP
Linux初始開發環境設定
想查指令請下man blah 或用
blah --help / blah help 軟體通常有內建的說明
login as root or
login and su - as root
===非必要===for security reason only
開新帳號,不要一直用root做事 (必要時 sudo blah)
adduser blah
改sudo設定,以後用sudo取代root
visudo
加一行
blah ALL=NOPASSWD: ALL
save file
logout and login as normal user
============
edit ~/.bashrc
在 #force_color_prompt=yes 這行下面加
color_prompt=yes
以後就有顏色了
或是在putty把term從 xterm改成xterm-color
加一行
export LC_CTYPE="zh_TW.UTF-8"
解決svn co時遇到中文卡住 (by Thomas)
save file
改putty設定
Windows->Translation->UTF-8
更新apt資料庫 (建議用aptitude取代apt-get)
aptitude update
更新已安裝package
aptitude safe-upgrade
aptitude dist-upgrade
清理暫存空間
aptitude clean
===非必要===
先裝個screen來用用 (screen是好物,不會用很可惜,對screen不熟的,可以google一下)
aptitude install screen
edit ~/.screenrc
encoding utf8 utf8
save file
===APT package管理系統=====
建議使用aptitude取代apt-get (功能較強大,也支援apt-get的所有參數)
找package
aptitude search blah
裝package
aptitude install apache2 mysql-server php5 cakephp subversion
清理下載檔案
aptitude clean
查詢已安裝package狀態
dpkg-query actions
See dpkg-query(1) for more information about the follow-
ing actions.
-l, --list package-name-pattern...
List packages matching given pattern.
-s, --status package-name...
Report status of specified package.
-L, --listfiles package-name...
List files installed to your system from package-name.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
-p, --print-avail package-name...
Display details about package-name, as found in
/var/lib/dpkg/available.
===MySQL===
開帳號 權限
mysql -u root -ppassword mysql (新系統root預設是無密碼,所以要用mysql -u root mysql)
CREATE USER 'blah'@'%' IDENTIFIED BY 'foo';
GRANT ALL PRIVILEGES ON *.* TO 'blah'@'%' WITH GRANT OPTION;
改mysqld 的 listen ip
edit /etc/mysql/my.cnf
comment out
#bind-address = 127.0.0.1
save file
重開MySQL
/etc/init.d/mysql restart
把svn checkout
svn co https://svn的網址
使用到的db看
\app\config\database.php (cakephp db config file)
帳號請爬 code
===php===
edit php.ini (/etc/php5/apache2/php.ini)
date.timezone = Asia/Taipei
===Zend Framework===
把Zend library搬到/usr/share/php
sudo mv ~/ZendFramework-1.9.5/library/Zend/ /usr/share/php/
改php.ini (/etc/php5/apache2)
加入Zend library的path
include_path = ".:/usr/share/php"
===CakePHP===
chmod -R 777 user2/app/tmp (因為svn的關係,否則正常程序為 chown -R www-data app/tmp)
在 /app/config/core.php 中 comment掉
#Configure::write('App.baseUrl', env('SCRIPT_NAME'));
mod_rewrite用到的檔案 (不用可以砍,或是不開目錄的AllowOverride就沒事)
# /.htaccess
# /app/.htaccess
# /app/webroot/.htaccess
有沒有開的差別
Cake's built in pretty URLs
www.example.com/index.php/controllername/actionname/param
URL when mod_rewrite is on
www.example.com/controllername/actionname/param.
===Vim .ctp設定===
=============
web server路徑相關設定請參考kevin寫的windows環境設定
apache設定mod_rewrite
edit httpd.conf (Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf)
DocumentRoot要開AllowOverride
Options FollowSymLinks
AllowOverride All
參考cakephp文件 3.3.4 Apache and mod_rewrite (and .htaccess)
=====svn sever 以下可省略====(有興趣的請自行研究)
aptitude install subversion-tools libapache2-svn
edit /etc/apache2/mods-enabled/dav_svn.conf
把該uncomment的 uncomment
設你自己想要的路徑後再生目錄
SVNPath /var/lib/svn
mkdir /var/lib/svn
svnadmin create /var/lib/svn
chown -R www-data:www-data /var/lib/svn
認證檔位置
AuthUserFile /etc/apache2/dav_svn.passwd
生檔案設密碼
htpasswd /etc/apache2/dav_svn.passwd blah
https support
foo@bar:/etc/apache2/mods-enabled$ ln -s ../mods-available/ssl.* .
/etc/apache2/sites-enabled也要做link
sample
/etc/apache2/mods-enabled/dav_svn.conf
DAV svn
SVNPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
blah --help / blah help 軟體通常有內建的說明
login as root or
login and su - as root
===非必要===for security reason only
開新帳號,不要一直用root做事 (必要時 sudo blah)
adduser blah
改sudo設定,以後用sudo取代root
visudo
加一行
blah ALL=NOPASSWD: ALL
save file
logout and login as normal user
============
edit ~/.bashrc
在 #force_color_prompt=yes 這行下面加
color_prompt=yes
以後就有顏色了
或是在putty把term從 xterm改成xterm-color
加一行
export LC_CTYPE="zh_TW.UTF-8"
解決svn co時遇到中文卡住 (by Thomas)
save file
改putty設定
Windows->Translation->UTF-8
更新apt資料庫 (建議用aptitude取代apt-get)
aptitude update
更新已安裝package
aptitude safe-upgrade
aptitude dist-upgrade
清理暫存空間
aptitude clean
===非必要===
先裝個screen來用用 (screen是好物,不會用很可惜,對screen不熟的,可以google一下)
aptitude install screen
edit ~/.screenrc
encoding utf8 utf8
save file
===APT package管理系統=====
建議使用aptitude取代apt-get (功能較強大,也支援apt-get的所有參數)
找package
aptitude search blah
裝package
aptitude install apache2 mysql-server php5 cakephp subversion
清理下載檔案
aptitude clean
查詢已安裝package狀態
dpkg-query actions
See dpkg-query(1) for more information about the follow-
ing actions.
-l, --list package-name-pattern...
List packages matching given pattern.
-s, --status package-name...
Report status of specified package.
-L, --listfiles package-name...
List files installed to your system from package-name.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
-p, --print-avail package-name...
Display details about package-name, as found in
/var/lib/dpkg/available.
===MySQL===
開帳號 權限
mysql -u root -ppassword mysql (新系統root預設是無密碼,所以要用mysql -u root mysql)
CREATE USER 'blah'@'%' IDENTIFIED BY 'foo';
GRANT ALL PRIVILEGES ON *.* TO 'blah'@'%' WITH GRANT OPTION;
改mysqld 的 listen ip
edit /etc/mysql/my.cnf
comment out
#bind-address = 127.0.0.1
save file
重開MySQL
/etc/init.d/mysql restart
把svn checkout
svn co https://svn的網址
使用到的db看
\app\config\database.php (cakephp db config file)
帳號請爬 code
===php===
edit php.ini (/etc/php5/apache2/php.ini)
date.timezone = Asia/Taipei
===Zend Framework===
把Zend library搬到/usr/share/php
sudo mv ~/ZendFramework-1.9.5/library/Zend/ /usr/share/php/
改php.ini (/etc/php5/apache2)
加入Zend library的path
include_path = ".:/usr/share/php"
===CakePHP===
chmod -R 777 user2/app/tmp (因為svn的關係,否則正常程序為 chown -R www-data app/tmp)
在 /app/config/core.php 中 comment掉
#Configure::write('App.baseUrl', env('SCRIPT_NAME'));
mod_rewrite用到的檔案 (不用可以砍,或是不開目錄的AllowOverride就沒事)
# /.htaccess
# /app/.htaccess
# /app/webroot/.htaccess
有沒有開的差別
Cake's built in pretty URLs
www.example.com/index.php/controllername/actionname/param
URL when mod_rewrite is on
www.example.com/controllername/actionname/param.
===Vim .ctp設定===
vim .ctp syntax highlight
root@h7dev06:~$ cat ~/.vim/ftdetect/ctp.vim
au BufRead,BufNewFile *.ctp set filetype=php
au BufRead,BufNewFile *.ctp set filetype=php
=============
web server路徑相關設定請參考kevin寫的windows環境設定
apache設定mod_rewrite
edit httpd.conf (Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf)
DocumentRoot要開AllowOverride
Options FollowSymLinks
AllowOverride All
參考cakephp文件 3.3.4 Apache and mod_rewrite (and .htaccess)
=====svn sever 以下可省略====(有興趣的請自行研究)
aptitude install subversion-tools libapache2-svn
edit /etc/apache2/mods-enabled/dav_svn.conf
把該uncomment的 uncomment
設你自己想要的路徑後再生目錄
SVNPath /var/lib/svn
mkdir /var/lib/svn
svnadmin create /var/lib/svn
chown -R www-data:www-data /var/lib/svn
認證檔位置
AuthUserFile /etc/apache2/dav_svn.passwd
生檔案設密碼
htpasswd /etc/apache2/dav_svn.passwd blah
https support
foo@bar:/etc/apache2/mods-enabled$ ln -s ../mods-available/ssl.* .
/etc/apache2/sites-enabled也要做link
sample
/etc/apache2/mods-enabled/dav_svn.conf
DAV svn
SVNPath /var/lib/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
Labels:
Linux
Saturday, March 6, 2010
以前寫的irssi 抓網址plugin
很久以前寫的東西,現在perl忘光了
http://docs.google.com/Doc?docid=0AWdnpsRpvzhDZGY4ZDI2MnRfMWR3azR0cGdq&hl=en
可惜令一個irssi plugin寫完送人,備份不知道備到哪一顆hd了,也沒得挖了
http://docs.google.com/Doc?docid=0AWdnpsRpvzhDZGY4ZDI2MnRfMWR3azR0cGdq&hl=en
可惜令一個irssi plugin寫完送人,備份不知道備到哪一顆hd了,也沒得挖了
Labels:
software
Subscribe to:
Posts (Atom)