[转] 韩寒 - 我只是在猜想

作者:airwin 发布时间:January 26, 2010 分类:唠叨

阅读剩余部分...

[转] 韩寒 - 兰州悲剧

作者:airwin 发布时间:January 26, 2010 分类:唠叨

阅读剩余部分...

MyEnTunnel 3.4.2

作者:airwin 发布时间:January 25, 2010 分类:LNMP

SSH隧道软件,配合vps翻墙用,很好使

直接下载链接:
unicode版本
MyEnTunnel v3.4.2 (Non-Unicode)

查看 详情

jQuery 1.4 发布 (updated 1.4.1)

作者:airwin 发布时间:January 15, 2010 分类:前端

在jQuery的4岁生日之时,jQuery开发团队很高兴地发布最新的jQuery1.4版本!其他的代码演示、测试、文档的更新也会陆续进行更新发 布。对于jQuery发烧友来说,jQuery1.4的发布也是一个大新闻!下面是来自于jQuery的官方网站翻译(英语高手请勿拍砖!): 在jQuery的4岁生日之时,jQuery开发团队很高兴地发布最新的jQuery1.4版本!其他的代码演示、测试、文档的更新也会陆续进行更新发布。



此外,谷歌已经提供了jQuery1.4副本,jquery团队上传到了Google服务器托管服务中。这jQuery1.4的版本是自动minified和gzip 的,地址为:
http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js




下面请看jQuery1.4在DOM上与1.3.2版本和其他框架的比较吧, 性能提升还是很大的~


jQuery1.4.1 - TaskSpeed

php 使用 curl 发送 post 数据的问题

作者:airwin 发布时间:January 15, 2010 分类:LNMP

windows平台, nginx + php-fastcgi 模式

PHP Version 5.2.10
cURL Information libcurl/7.19.4 OpenSSL/0.9.8k zlib/1.2.3

测试代码

1
2
3
4
5
6
7
8
9
10
11
$url = 'http://localhost/x.php';
$post_data = array('a'=>'b');
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);

这些代码耗时竟然2秒多
同样的操作用socket方式操作则正常,在毫秒级别

调试发现原因在这句

1
2
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//注意这句, 传入的第三个参数是数组

改为:
1
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));

后,执行时间恢复正常.

手册 上的介绍

CURLOPT_POSTFIELDS:
The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. This can either be passed as a urlencoded string like 'para1=val1¶2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data.

然后我用socket模拟发送multipart/form-data头,但是并无延时现象,看来是php / curl 的问题, 查看php5.2.12的changelog, 并没有类似这个问题的bug.

暂时没有时间去研究源码, 结论就是

CURLOPT_POSTFIELDS 不要为省事传数组, http_build_query 一下!

php 访问本地后台的奇怪问题

作者:airwin 发布时间:January 8, 2010 分类:LNMP

php无论使用curl,还是socket,向本地的虚拟主机某php post数据时,无论php输出什么,这个post的请求总是会以超时结束, 但是经检查该php确实已经收到post过来的数据写入数据库, 这个问题只出现在本地向本地post的情况, 本地向外网域名操作正常,立刻就能返回。不知道这是否是我本地的问题, 还是curl的问题。记录一下

  1. 1