Thursday, August 25, 2011
Wednesday, August 24, 2011
Linux Server commands
1. 更改password:passwd username
2. 更改port: vi /etc/ssh/sshd_config 找到Port 更改为比如:7777 还有找到PermitRootLogin 改为no 之后存盘退出,别忘了添加一个不是root的user和pw,adduser newuser, passwd newpassword, 重启ssh:service sshd restart
3. 查找文件: find / -name filename
4.更改iptable: vi /etc/sysconfig/iptables 查找 -A RH-Firewall-i-INPUT -p top -n state -m tcp --dport 22 --state NEW -j ACCEPT 把-dport 22 改成刚才那个-dport 7777,存盘退出,重启iptable:service iptable restart
2. 更改port: vi /etc/ssh/sshd_config 找到Port 更改为比如:7777 还有找到PermitRootLogin 改为no 之后存盘退出,别忘了添加一个不是root的user和pw,adduser newuser, passwd newpassword, 重启ssh:service sshd restart
3. 查找文件: find / -name filename
4.更改iptable: vi /etc/sysconfig/iptables 查找 -A RH-Firewall-i-INPUT -p top -n state -m tcp --dport 22 --state NEW -j ACCEPT 把-dport 22 改成刚才那个-dport 7777,存盘退出,重启iptable:service iptable restart
Tuesday, August 23, 2011
Domain unable to unsuspend in Plesk 9.5
After upgrading plesk to latest release one of our domain on plesk server was unable to unsuspend thus giving the following error.
“Warning: The domain is still suspended for the following reason: Domain is temporarily suspended for backing up or restoring”
Though it appear to be backup issue but backups were not running for the domain making it quite confusing, So we had the following method to unsuspend the domain.
Login into shell and ran the following command.
/usr/local/psa/bin/domain -u domain.com -status enabled
Segmentation fault
Voila !! So here is the problem plesk binaries is showing segmentation fault so it appears that the plesk upgrade didn’t go properly. Plesk itself work on these binaries which here appears to be a problem. Now Login into plesk and under “Updates ” select the plesk base package option and re-install the Plesk Base packages to make the plesk binaries working again. You should receive a email when the updates are completed.
Follow the steps to reconfigure the domain in plesk database.
Reconfigure Domain:
/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=domain.com
Change the status for domain
/usr/local/psa/bin/domain -u domain.com -status enabled
You should get a message the Object successfully enabled, Thats it the domain should be unsuspended in Plesk.
Domain unable to unsuspend in Plesk 9.5
“Warning: The domain is still suspended for the following reason: Domain is temporarily suspended for backing up or restoring”
Though it appear to be backup issue but backups were not running for the domain making it quite confusing, So we had the following method to unsuspend the domain.
Login into shell and ran the following command.
/usr/local/psa/bin/domain -u domain.com -status enabled
Segmentation fault
Voila !! So here is the problem plesk binaries is showing segmentation fault so it appears that the plesk upgrade didn’t go properly. Plesk itself work on these binaries which here appears to be a problem. Now Login into plesk and under “Updates ” select the plesk base package option and re-install the Plesk Base packages to make the plesk binaries working again. You should receive a email when the updates are completed.
Follow the steps to reconfigure the domain in plesk database.
Reconfigure Domain:
/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=domain.com
Change the status for domain
/usr/local/psa/bin/domain -u domain.com -status enabled
You should get a message the Object successfully enabled, Thats it the domain should be unsuspended in Plesk.
Domain unable to unsuspend in Plesk 9.5
Thursday, August 18, 2011
Configuration manager 里的build是干什么用的
Build->Configuration Manager
如果不想在debug的话,可以把Build的选项点掉。
Wednesday, August 17, 2011
JQuery 基础知识
1. do something after page ready to load:
$(document).ready(function(){
$('#message').fadeIn('slow');
});
2. how to use 'this':
<p onclick="$(this).hide();">hide this paragraph</p>
3. after a image loaded do sth.
$('#image').load(function(){
alert('something');
});
$('img').load(funtion(){ //each images have been loaded then do this thing.
...
});
4. after window load.
$(window).load(funciton(){
...
});
5. unload 当离开页面的时候启动.and confirm().
$(window).unload(function(){...
var c = confirm('are you sure?');
if(c){return ture;}else{ return false;}
});
5. serialize的用法,显示url里的一系列的值
$("form").serialize() 就是submit form之后在url里显示的值.也就是url里问号?之后的一系列的值
6. post
$.post(url, function(data){
}); 这里的data是从url的里得来的.
7. each(function)
$('.option:checked').each(funciton(){ total += $(this).val();});
$('.option:not(:checked)').each(function(){...});
8. form validation
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#edit_blog').validate({
rules:{
title: { required: true,},
blog_category: {required: true, email: true,},
blog_body: {required: true,},
}
});
});
</script>
8 Array
var arr = ['cat', 'dog', 'fish'];
1) 显示在页面里要用
$('#array').html(arr.toString());
or
$('#array').html(arr.join("+ "));
2)
arr.splice(0, 1); 去掉从第一个到第二个之前的值,结果是: dog,fish
arr.slice(0,1); 取得第一个到第二个之前的值, 结果是:cat
arr.pop(); 删除最后一个值,结果是:cat,dog
arr.push("duck"); 添加值到最后, 结果是: cat, dog, fish, duck
arr.shift(); 减去第一个值,结果是: dog, fish
arr.unshift("duck"); 在第一个值之前添加一个值,结果是: duck, cat, dog, fish
arr.length; array的长度;
3)
<input id="submit" type="submit" rel="21|cat|dog" />
var data = $('#submit').attr('rel'); 得到的结果是:21|cat|dog
变成数组可以这样做:
data = data.split('|');
4) each()
$.each(data, function(key, val){
$("#array").append(key+" => " + val + "<br />");
});
9. position()
var position = $('#player').position();
如果想要向左:$('#player').css('left', position.left - 10 + 'px');
向下: $('#player').css('top', position.top + 10 + 'px');
$(document).keydown(function(e){
//e在这里是event.
});
4. after window load.
$(window).load(funciton(){
...
});
5. unload 当离开页面的时候启动.and confirm().
$(window).unload(function(){...
var c = confirm('are you sure?');
if(c){return ture;}else{ return false;}
});
5. serialize的用法,显示url里的一系列的值
$("form").serialize() 就是submit form之后在url里显示的值.也就是url里问号?之后的一系列的值
6. post
$.post(url, function(data){
}); 这里的data是从url的里得来的.
7. each(function)
$('.option:checked').each(funciton(){ total += $(this).val();});
$('.option:not(:checked)').each(function(){...});
8. form validation
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$('#edit_blog').validate({
rules:{
title: { required: true,},
blog_category: {required: true, email: true,},
blog_body: {required: true,},
}
});
});
</script>
8 Array
var arr = ['cat', 'dog', 'fish'];
1) 显示在页面里要用
$('#array').html(arr.toString());
or
$('#array').html(arr.join("+ "));
2)
arr.splice(0, 1); 去掉从第一个到第二个之前的值,结果是: dog,fish
arr.slice(0,1); 取得第一个到第二个之前的值, 结果是:cat
arr.pop(); 删除最后一个值,结果是:cat,dog
arr.push("duck"); 添加值到最后, 结果是: cat, dog, fish, duck
arr.shift(); 减去第一个值,结果是: dog, fish
arr.unshift("duck"); 在第一个值之前添加一个值,结果是: duck, cat, dog, fish
arr.length; array的长度;
3)
<input id="submit" type="submit" rel="21|cat|dog" />
var data = $('#submit').attr('rel'); 得到的结果是:21|cat|dog
变成数组可以这样做:
data = data.split('|');
4) each()
$.each(data, function(key, val){
$("#array").append(key+" => " + val + "<br />");
});
9. position()
var position = $('#player').position();
如果想要向左:$('#player').css('left', position.left - 10 + 'px');
向下: $('#player').css('top', position.top + 10 + 'px');
$(document).keydown(function(e){
//e在这里是event.
});
里氏代换原则
里氏代换原则:
如果每个C1类型的对象O1,都有一个C2类型的对象O2,使得以C1定义的程序里面的O1都可以换成O2,那么就说C2是C1的一个子类。
里氏代换原则要求在使用基类的地方其子类也一定适用,这条原则是在进行OOD时候对对象抽象过程中的一个验证方法。比若说设计了一个超类A,我们又设计了 A的子类,那么检查我们的设计是否合理,就应该根据里氏代换原则,看看应用代码中使用到A的对象的地方,时候可以换成其子类对象也同样成立,如果不成立那 么则证明子类并不真正是超类的孩子。
如果每个C1类型的对象O1,都有一个C2类型的对象O2,使得以C1定义的程序里面的O1都可以换成O2,那么就说C2是C1的一个子类。
里氏代换原则要求在使用基类的地方其子类也一定适用,这条原则是在进行OOD时候对对象抽象过程中的一个验证方法。比若说设计了一个超类A,我们又设计了 A的子类,那么检查我们的设计是否合理,就应该根据里氏代换原则,看看应用代码中使用到A的对象的地方,时候可以换成其子类对象也同样成立,如果不成立那 么则证明子类并不真正是超类的孩子。
接口和抽象类的区别
关心有相同的功能---用接口
关心将来重复使用,重复功能的扩展---用抽象类(继承)
创建多个组件版本---抽象类
设计小而简练的功能块---接口
设计大型功能单元,搭建框架---抽象类
关心将来重复使用,重复功能的扩展---用抽象类(继承)
创建多个组件版本---抽象类
设计小而简练的功能块---接口
设计大型功能单元,搭建框架---抽象类
接口的显式实现
如果一个类,继承了2个接口,并且这两个接口有相同的方法.
public interface IFile{void Close();}
public interface IWindow(void Close(); }
public class FileWindow:IFile;IWindow
{
void IFile.Close(){...} //这样没有public字样的就是显式实现.他们默认地都是私有的
void IWindow.Close(){...}
public void Close(){
(this as IFile).Close(); //如果想调用其他的接口的方法, 必须先把相关对象转换成相应的接口类型. this是当前class的实例.
((IWindow)this).Close();
}//自己的close方法
}
//调用时
public static void Test(){
IFile file = new FileWindow();
IWindow = new FileWindow();
FileWindow fw = new FileWindow();
file.Close();
window.Close();
fw.Close();
}
public interface IFile{void Close();}
public interface IWindow(void Close(); }
public class FileWindow:IFile;IWindow
{
void IFile.Close(){...} //这样没有public字样的就是显式实现.他们默认地都是私有的
void IWindow.Close(){...}
public void Close(){
(this as IFile).Close(); //如果想调用其他的接口的方法, 必须先把相关对象转换成相应的接口类型. this是当前class的实例.
((IWindow)this).Close();
}//自己的close方法
}
//调用时
public static void Test(){
IFile file = new FileWindow();
IWindow = new FileWindow();
FileWindow fw = new FileWindow();
file.Close();
window.Close();
fw.Close();
}
判断类型转换 is and as
is 是先判断是不是指定接口类型(是不是实现了接口)
if(obj is IFlyable)
{
IFlyable fly = (IFlyable)obj;
fly.starfly();
}
as 是先执行转换(委婉型转换)然后再判断转换是否成功
IFlyable fly = null;
fly = obj as IFlyable; //as 在这里是把...当作...
IFlayable fly2 = obj as IFlyable; //如果成功转换,fly不为null,否则,就为null
if(fly == null){
...
}else{...}
if(obj is IFlyable)
{
IFlyable fly = (IFlyable)obj;
fly.starfly();
}
as 是先执行转换(委婉型转换)然后再判断转换是否成功
IFlyable fly = null;
fly = obj as IFlyable; //as 在这里是把...当作...
IFlayable fly2 = obj as IFlyable; //如果成功转换,fly不为null,否则,就为null
if(fly == null){
...
}else{...}
Tuesday, August 16, 2011
#region 这个是一个可以把一段程序收缩显示的方法
#region 需要显示的名称
#endregion
这个是一个可以把一段程序收缩显示的方法
#endregion
这个是一个可以把一段程序收缩显示的方法
Thursday, August 4, 2011
Symfony2 Install on Mac: Mysql Error – SQLSTATE[HY000] [2002] No such file or directory
I recently changed up the configuration of my Mac (running 10.6.4) and I was installing a fresh copy of Symfony2 when I ran into the following error when I got to the database credentials: SQLSTATE[HY000] [2002] No such file or directory.
I did some Googling around and came across someone that seemed to have a similar issue, though not with Magento. So I figured I’d give it a shot. Well, it worked. The unfortunate part is that, being not all too familiar with how all this configuration stuff works, I don’t know why it works (if you know why, please let me know).
The Solution
Open up your php.ini file (mine was in /etc/). Look for the following line:
pdo_mysql.default_socket=/var/mysql/mysql.sock
If that line exists for you, try changing it to:
pdo_mysql.default_socket=/tmp/mysql.sock
Restart apache after saving, and that’s all I had to do. One thing to keep in mind though is that I am using the stock php (with 10.6), and I’m using mysql installed with homebrew.
ref: http://prattski.com/2010/08/05/magento-install-mysql-error-sqlstatehy000-2002-no-such-file-or-directory/
I did some Googling around and came across someone that seemed to have a similar issue, though not with Magento. So I figured I’d give it a shot. Well, it worked. The unfortunate part is that, being not all too familiar with how all this configuration stuff works, I don’t know why it works (if you know why, please let me know).
The Solution
Open up your php.ini file (mine was in /etc/). Look for the following line:
pdo_mysql.default_socket=/var/mysql/mysql.sock
If that line exists for you, try changing it to:
pdo_mysql.default_socket=/tmp/mysql.sock
Restart apache after saving, and that’s all I had to do. One thing to keep in mind though is that I am using the stock php (with 10.6), and I’m using mysql installed with homebrew.
ref: http://prattski.com/2010/08/05/magento-install-mysql-error-sqlstatehy000-2002-no-such-file-or-directory/
mac – mysql does not connect on localhost but connect’s on 127.0.0.1
his issue came to me after i got “Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’” on a mysql connection on php on a fresh installed mac – php connect’s correctly to 127.0.0.1 , but does not connect to localhost .
On a mac the default mysql socket is ‘/private/tmp/mysql.sock‘ and not ‘/var/mysql/mysql.sock’, you can confirm it by using $ locate mysql.sock on a Terminal.
So basically you have to change the php default connection socket to mysql to ‘/private/tmp/mysql.sock‘ . To do this you have to edit your php.ini – probably located at ‘/private/etc/php.ini‘ – via:
* $ sudo nano /private/etc/php.ini
* ctrl+w (where is) “mysql.default_socket“
* alter to “mysql.default_socket = /private/tmp/mysql.sock”
* crtl+x followed by y and enter to save php.ini
* $ sudo httpd -k restart to restart Apache 2
Retry connecting to mysql localhost on php – should be working :)
Update:
if you use mysqli you also must set “mysqli.default_socket = /private/tmp/mysql.sock” on php.ini;
from: http://techtrouts.com/mac-mysql-does-not-connect-on-localhost-but-connects-on-127001/
On a mac the default mysql socket is ‘/private/tmp/mysql.sock‘ and not ‘/var/mysql/mysql.sock’, you can confirm it by using $ locate mysql.sock on a Terminal.
So basically you have to change the php default connection socket to mysql to ‘/private/tmp/mysql.sock‘ . To do this you have to edit your php.ini – probably located at ‘/private/etc/php.ini‘ – via:
* $ sudo nano /private/etc/php.ini
* ctrl+w (where is) “mysql.default_socket“
* alter to “mysql.default_socket = /private/tmp/mysql.sock”
* crtl+x followed by y and enter to save php.ini
* $ sudo httpd -k restart to restart Apache 2
Retry connecting to mysql localhost on php – should be working :)
Update:
if you use mysqli you also must set “mysqli.default_socket = /private/tmp/mysql.sock” on php.ini;
from: http://techtrouts.com/mac-mysql-does-not-connect-on-localhost-but-connects-on-127001/
Wednesday, August 3, 2011
Fatal error: Uncaught exception 'RuntimeException' with message 'Failed to write cache file
Fatal error: Uncaught exception 'RuntimeException' with message
'Failed to write cache file
give your catch folder a permission to write and also need give the log folder a write permission as well.
'Failed to write cache file
give your catch folder a permission to write and also need give the log folder a write permission as well.
Subscribe to:
Posts (Atom)