curl_setopt($hCurl, CURLOPT_STDERR, fopen(‘php://output’, ‘w+’));
curl_setopt($hCurl, CURLOPT_VERBOSE, 1);
Ref: http://projectivemotion.com/2012/07/30/print-curl-verbose-info-web-browser-php/
curl_setopt($hCurl, CURLOPT_STDERR, fopen(‘php://output’, ‘w+’));
curl_setopt($hCurl, CURLOPT_VERBOSE, 1);
Ref: http://projectivemotion.com/2012/07/30/print-curl-verbose-info-web-browser-php/
convert “animation.gif[0]” file.jpg
Ref: http://devblog.bluefuton.com/post/2976224441/capture-first-frame-animated-gif-imagemagick
1. open /etc/default/grub
2. then change anything you want
今天一个同事问道缓存设置0然后判断永不过期的实现机制是怎么样子的,当时猜想可能是设置了一个比较大的值(比如十年),不过对此不确定。
兴起去pull了memcached的源码来看:
git pull https://github.com/memcached/memcached.git
memcached.c 文件 3314 行:
/*
If exptime is zero realtime() would return zero too, and
realtime(exptime) – 1 would overflow to the max unsigned
value. So we process exptime == 0 the same way we do when
no delay is given at all.
*/
if (exptime > 0)
settings.oldest_live = realtime(exptime) – 1;
else /* exptime == 0 */
settings.oldest_live = current_time – 1;
原来是用了无符号整数的溢出。。。
在厦门PHPer群里看到的。
这个玩意儿比较好的地方就是可以跟操作系统解耦。
其中用到了redis作为队列处理,依赖还是较强,处理量不大的话,用sqlite来替代会不会更好?。
里面的几个思路跟我自己在cron脚本的一些处理上蛮像,殊途同归,LOL。
Resque: https://github.com/defunkt/resque
PHP的clone:https://github.com/chrisboulton/php-resque
Ref: http://avnpc.com/pages/run-background-task-by-php-resque