symfony起步

1.routing   /app/config/routing.yml

code:

_demo:
resource: “@AcmeDemoBundle/Controller/DemoController.php”
type:     annotation
prefix:   /demo

resource: “@AcmeDemoBundle/Controller/DemoController.php”   =  src/Acme/DemoBunlde/Controller/DemoController.php

code:

/**

* @extra:Route(“/hello/{name}”, name=”_demo_hello”)

* @extra:Template()

*/

public function helloAction($name)

{

return array(‘name’ => $name);

}

ubuntu下解决chrome修改默认字体无效的问题

在ubuntu下chrome修改默认字体,通过 chrome自带的选项修改有时候会无效,找到一种有效的办法,在ubuntu10.04 +chrome10.0.696 组合下有效

编辑   ~/.config/google-chrome/Default/User StyleSheets/Custom.css 这个文件
@charset “utf-8″;
body * {
font-family:”WenQuanYi Micro Hei”,”wqy-microhei”,Tahoma,SimSun !important;
}
~
~

@charset “utf-8″;
body * {
font-family:”WenQuanYi Micro Hei”,”wqy-microhei”,Tahoma,SimSun !important;}~                                                                                                                                                                                            ~

用UNetbootin把U盘或移动硬盘做成Live USB

用UNetbootin把U盘或移动硬盘做成Live USB
作者:Jandy

不用刻录光盘,对硬盘数据毫无影响。
只要你有一个1G或以上的U盘或移动硬盘,而且U盘或移动硬盘和电脑都支持从USB设备启动,即可轻易体验Ubuntu的华丽。
制作安装过程只需几分钟!

你也可以用这个Live USB来把Ubuntu正式安装到硬盘里。

制作Live USB需要用到UNetbootin这个软件,Unetbootin有Windows版和Linux版,就算你现在使用的是Windows系统,也可以轻松体验。

Ubuntu自带的“USB启动盘创建器”也可以制作Live USB,但UNetbootin可以在Windows或Linux里使用,而且制作的速度更快,支持的Linux发行版也更多。

Live USB制作步骤如下:

1、下载Ubuntu的iso文件。

2、下载UNetbootin。
下载地址:http://unetbootin.sourceforge.net
Ubuntu用户下载“for Linux”的版本即可。

3、将U盘插到USB接口。
注意:一定要先插U盘再运行UNetbootin!

4、运行UNetbootin。
Windows版是免安装的绿色软件,双击下载来的文件即可运行。
Linux版的文件也是免安装的,但要先赋予它可执行的权限,Ubuntu用户可用右键单击下载来的文件,选择“属性”,点击“权限”标签,选中“允许以程序执行文件”,点“关闭”按钮。然后双击文件,即可运行程序。

5、选择“磁盘镜像”(Diskimage)和下载好的iso文件。
不要选择“显示所有驱动器”(Show All Drives)。
“类型”(Type)选择“USB设备”(USB Drive),“驱动器”选择你的U盘。注意:千万不要选错驱动器,如果错选为硬盘的话,会导致硬盘文件丢失!
在Ubuntu中,如果你不确定哪个是你的U盘的话,可以打开菜单“系统 ——系统管理——分区编辑器”确认一下,根据驱动器容量即可分辨。

6、确认选择正确后,点“确认”(OK)开始安装。

7、只需几分钟即可安装完毕。

8、重启电脑,并设置USB设备为第一启动设备,即可启动U盘里的操作系统。

这样创建的Live USB类似于Live CD,其优缺点如下:
缺点:
1、不能保存个人文件或系统设置。(可以把文件保存到其他驱动器,如另一个U盘或移动硬盘,或电脑里的硬盘。)
2、需要电脑支持USB设备启动。
优点:
1、制作方便。
2、运行速度比光盘快。

备注:
移动硬盘的做法跟U盘一样。
Unetbootin也支持Fedora、openSUSE、红旗Linux等Linux发行版,详细列表请到官方主页查阅。

如果想真正把Ubuntu装到移动硬盘里的话,可参考此帖:http://ubuntuabc.com/123/?p=58

签出  svn co

签入 svn ci

删除svn上的某些文件  svn  delete xxx  然后 svn ci

提交本地新的文件到svn上    svn import trunk  http://svn.svn.com/trunk/

squid对于php的浏览器端缓存的处理

主要包括 expires last-modified cache-control
现在线上前面一个硬件的分发服务器,后面两台nginx服务器,在expires last-modified cache-control 等都设置无误的情况下 ,对于php文件还有rewrite后的html文件,还是每次都200,没有出现304

然后上了一台squid,在同样设置的情况下,对于rewrite后的html有效,对于php的缓存仍然无效

附php代码

$sec=1200;

$last_modified_time = intval(time() / $sec) * $sec;
$etag = md5($last_modified_time);
header(“Cache-Control: max-age=$sec”);
header(“Expires: $sec”);
header(“Last-Modified: ” . gmdate(“D, d M Y H:i:s”, $last_modified_time) . ” GMT”);
header(“Expires:” . gmdate(“D, d M Y H:i:s”, $last_modified_time + $sec) . ” GMT”);
这种是通过nginx或者squid实现的,设置expires是通过php但是再次请求的时候通过nginx和squid等就可以实现304了,无需再次运行php文件

另一种通过php实现的方法如下,设置周期内同意etag,php通过etag来判断是否需要304然后中断
$last_modified_time = intval(time() / $sec) * $sec;
$etag = md5($last_modified_time);
header(“Cache-Control: maxage=$sec”);
header(“Last-Modified: ” . gmdate(“D, d M Y H:i:s”, $last_modified_time) . ” GMT”);
header(“Etag: $etag”);

if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
header(“HTTP/1.1 304 Not Modified”);
exit;
}

linux下php定时备份sql和www目录

上次burst挂了之后,只好从备份恢复,丢失了一些数据,于是想自己搞个定时备份,从A服务器到B 服务器(未必是vps,也可以是空间)
由于shell写的不好,考虑采用PHP的exec去执行,在A服务器上用php的mysqldump 导出 用zip压缩,生成时间戳文件名到固定的abc.txt,然后file_get_contents通知B服务器去读取A的abc.txt然后抓去zip文件到B ,然后B 服务器
再调用A 的clean.php去用rm命令清理,在A或者B上挂个crontab去定期wgetA上的备份页面,三个页面分别执行 导出 备份 清理的功能,用了半天时间写好了,测试可用

QQ旋风挂代理思路

貌似apache的proxy不支持ed2k,至少我这边有些是下不了,然后由于是腾讯的会员,想使用旋风离线下载,于是要悲剧地给我那个没有网络的A机挂代理,原来部分用的是apache的代理
搞了个copssh安装到可以上网的F机(为啥叫F机呢,因为速度跟坐飞机差不多,快啊),然后用myentunnel在A机转发下端口,然后用sockcap(绿色版)给挂上去,然后用sockcap启动要走代理的程序(旋风)(开始的时候旋风会卡十几到几十秒),然后就可以下载了,爽也
旋风自带也可以支持好多种类型的代理,但是如果你旋风所在的机器不能联网的话,用户登录会超时,这个主要能解决用户登录超时的问题

PHP抓取某站漫画图片

set_time_limit(0);
function getimg($index){
$indexb=str_repeat(0, 8-strlen($index*18527)).$index*18527;
$indexc=str_repeat(0,8-strlen($index)).$index;
return (string)”http://pic2.89890.com/cn3/qiannvyouhun/01/”.$indexb.$indexc.’.jpg’;

}
for($i=1;$i<143;$i++){
$imgurl=getimg($i);
exec(“wget $imgurl”);
}

这个漫画还不错,记得要先开exec函数

http://www.89890.com/comic/5531/1/?

memcache批量删除方案

php soap

共三个文件,测试有效(需开soap扩展)

soapfun.php

<?php</div>
function reverse($str){</div>
$retval = '';</div>
if(strlen($str) < 1) {</div>
<div id="_mcePaste">return new SoapFault('Client','','Invalid string');</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">for ($i = 1; $i <= strlen($str); $i++) {</div>
<div id="_mcePaste">$retval .= $str[(strlen($str) - $i)];</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">return $retval;</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">function add2numbers($num1, $num2) {</div>
<div id="_mcePaste">if (trim($num1) != intval($num1)) {</div>
<div id="_mcePaste">return new SoapFault('Client','','The first number is invalid');</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">if (trim($num2) != intval($num2)) {</div>
<div id="_mcePaste">return new SoapFault('Client','','The second number is invalid');</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">return ($num1 + $num2);</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">function gettime(){</div>
<div id="_mcePaste">$time=strftime("%Y-%m-%d %H:%M:%S");</div>
<div id="_mcePaste">return $time;</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">?></div>

soapser.php

<?
include_once('soapfun.php');
$soap = new SoapServer(null,array('uri'=>"http://testq-uri/"));
$soap->addFunction('reverse');
$soap->addFunction('add2numbers');
$soap->addFunction('gettime');
$soap->addFunction(SOAP_FUNCTIONS_ALL);
$soap->handle();
?></pre>
<div></div>
<pre>

soapcli.php

</pre>
</span>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;"><?
try {
        $client = new SoapClient(null, array('location' =>
      "http://localhost/test/soapser.php",'uri' => "http://test-uri/"));
        $str = "This string will be reversed";
        $reversed = $client->reverse($str);
        echo "If you reverse '",$str,"', you get '",$reversed,"'";
        echo "<br>";
        $n1=20;
        $n2=33;
        $sum = $client->add2numbers($n1,$n2);
        echo "If you try ",$n1,"+",$n2,", you will get ",$sum,"";

        echo "<br>";
        echo "The system time is: ",$client->gettime();
} catch (SoapFault $fault){
        echo "Fault! code:",$fault->faultcode,", string: ",$fault->faultstring;
}
?></pre>
<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal;">
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;">