Git 使用技巧

按照文件结构导出最近的修改

这样可以比较方便的更新文件。

来源:Zip latest committed changes only

比如:


 如果是Subversion,并且安装了TortoiseSVN客户端的话,可以试一试这个:如何让TortoiseSVN仅导出新增或修改过(变更过)的文件

 按照指定格式输出提交历史

更为丰富的颜色显示

wp-db-backup备份数据库出现错误:Only variables should be passed by reference 的解决方案

使用WordPress Database Backup备份wordpress数据库时,如果选择了发送邮件,可能会出现多种种错误。

1、一种是邮件不可发送,这个可能是wordpress托管主机不支持mail服务。这时可以选择smtp的方式发送邮件,下载插件:WP-Mail-SMTP来解决这个问题。网上有很多关于WP-Mail-SMTP的设置文件,可以搜索一下。

2、启用WP-Mail-SMTP后,可能还会出现ereg的错误提示,编辑wp_mail_smtp.php文件,395行,把

 替换为

 即可。即把validate_email替换为is_email,一是因为validate_email已经过期,而是validate_email使用了过期的方法:ereg。

3、如果还有错误出现,比如:Only variables should be passed by reference,解决方法,把953行,954行:

 的$from_email替换为真实的email地址,$from_name可换可不换。便可以解决这个问题。

使用phar包配置phpuint

先看官方文档,安装phpunit:http://www.phpunit.de/manual/current/en/installation.html

 phpunit.phar包几乎包含所有的依赖组件(也包括一些可选组件),所以用phpunit.phar设置单元测试时,无需单独安装其他的可选包了。

但是凡事都有例外,phpunit.phar里没有测试框架生成器,需要单独安装。

php 5.4 + apache 2 + xdebug 2 + Windows

如果配置xdebug有问题,请先配置好php,然后把phpinfo()输出到浏览器的html复制到页面:

http://xdebug.org/wizard.php

中的输入框,然后点击按钮:“Analyse my phpinfo() output”,让xdebug帮你决定用哪个php_xdebug.dll。

GIT 配置相关文章

最近花时间了解了一下Git,并配置了一个。学习过程中,查阅了一些文章,分享出来。

工作环境:ubuntu

1、《ubuntu上配置git服务器

作者:Xandy
当执行:git clone git@server:gitosis-admin.git,如果出现:fatal: ‘/home/git/repositories/gitosis-admin.git’ does not appear to be a git repository,请参看条目2。
如果 git://eagain.net/gitosis.git 不可访问,可以试一试这个:git://github.com/res0nat0r/gitosis.git。
 

文章最后:Host “host”HostName “host_name”User “git”IdentityFile “/tmp/id_rsa” 的具体例子(出处):

3、《浅谈Gitosis实现原理

卢克 /

gitosis通过一个gitosis-admin库来对git库的访问者进行授权。授权通过公钥和私钥实现。访问者的权限配置在gitosis-admin库内的gitosis.conf文件,公钥放在keydir目录。公钥的名字必须和配置文件中的member名字一致。

4、《GotGitHub

Author: Jiang Xin
Version: v0.9.1-8-gf708729
Copyright: Creative Commons BY-NC-SA

5、《nginx gitweb配置

May 10th, 2011

6、《Pro Git》

http://git-scm.com/book/zh

中文PDF下载

中文ePub下载

给Mac的PHP添加gettext扩展

本来以为就这么简单,下载与Mac匹配的PHP源码,然后

cd ext/gettext
phpize
./configure
make
sudo make install

谁知道遇到错误:configure: error: Cannot locate header file libintl.h

google了一下,这里有解决办法:PHP with Intl and Gettext on OSX Lion

大致步骤是:

1、安装ICU

2、安装PHP自带的intl扩展

3、如果需要,安装Gettext

4、安装PHP自带的gettext扩展即

Apache 重写规则的一个注意点(MultiViews)

做了一个项目,用到了URL重写,虚拟主机的部分配置:

<Directory “/projects/ccc”>

Options Indexes FollowSymLinks MultiViews

AllowOverride all

Order allow,deny
Allow from all

</Directory>

测试时,发现重写有问题,很多URL显示错误,比如http://ccc.net/corp/order/list.html无法正确显示。

仔细看重写规则日志,发现重写记录如下:

[perdir /projects/ccc/] add path info postfix: /projects/ccc/corp/order.php -> /projects/ccc/corp/order.php/list.html

神奇啊。google好半天,才发现是MultiViews的问题。

Multiviews

MultiViews is a per-directory option, meaning it can be set with an Options directive within a <Directory><Location> or <Files> section in httpd.conf, or (if AllowOverride is properly set) in .htaccess files. Note that Options All does not set MultiViews; you have to ask for it by name.

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client’s requirements.

意思是:如果服务器接收了一个对/some/dir/foo的请求,/some目录启用了MultiViews,但/some/dir/foo不存在,则服务器会查找这个目录下所有的 foo.* 文件,并理所当然地为这些文件伪造一个类型映射表,分配给他们相同的媒体类型和内容的编码,用户请求一个文档时,类型映射表会选择其中最符合客户请求的文档,返回给客户。

在上面的例子中,Apache发现corp/order/list.html不存在,但是/projects/ccc/corp/order.php存在,就把重写地址转换为order.php/list.html。

将MultiViews移除,重启Apache,搞定。

附记:当开启MultiViews,即时重写规则为空,Apache也会文档URL重写处理。这个是因为在找问题的过程中,我把.htaccess内容清空,发现corp/order/list.html也有返回。当时莫名惊诧啊。原来却是Apache的默认设置,搞得我差点重新编译Apache。

月季

 

北京的春天应该是没有办暂住证,这么快就被撵走了

DSC00174

大运河森林公园

该绿的都该绿了,所以今天带着欣乐去了早就想去的通州大运河森林公园。

通州大运河森林公园位于北运河两侧,占地面积10700亩,公园沿水系长达8公里,分别建有潞河桃柳、月岛闻莺、明镜移舟等六大景区和长虹花雨、半山人家、皇木古渡等十八景点。(摘自互动百科的通州大运河森林公园条。注,一亩合计666平米,故10700亩大约是700多万平米,哇得盖多少房子啊。)

上午是阴天,运河边的空气清冷但湿润,沿着运河跑了一路,心旷神怡,在高pm2.5的淫威下淤积了一周的污浊消散的无影无踪。

计划每周或每2周都来这里泡一天。

一张全景图,今天我们就在左侧3、4、5、6处,转悠了大半天。