DIY爱好者必看的网站

我这里说的DIY可不仅仅是电脑阿,什么都有。
如果你喜欢动手制作东西,看看这个网站吧:
http://www.instructables.com/

图文并茂,手把手的教你,包会阿。

比较酷的几个:

用废旧主板做手链:

用废旧主板做手链

太阳能罐,可以把太阳光储存起来,晚上发光哦
太阳能罐

可发光的戒指:

可发光的戒指

Spawn PHP5/4 fastcgi on mac osx

下面是我使用的脚本,用于启动php5/4的fastcgi daemon,和linux 上使用的版本基本一样:


#!/bin/bash
#PID for SPAWN Process
PID=/tmp/php5-fcgi.pid
## ABSOLUTE path to the spawn-fcgi binary
SPAWNFCGI="/usr/local/bin/spawn-fcgi"

## ABSOLUTE path to the PHP binary
FCGIPROGRAM="/usr/local/php5/bin/php5"
#FCGIPROGRAM="/usr/local/bin/php"

## TCP port to which to bind on localhost
FCGIPORT="1026"
FCGISOCKET=/tmp/php5.socket
## number of PHP children to spawn
PHP_FCGI_CHILDREN=2

## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=1000

## IP addresses from which PHP should access server connections
FCGI_WEB_SERVER_ADDRS="127.0.0.1,192.168.2.10,192.168.80.108"

# php.ini
PHPRC=/usr/local/php5/etc/php.ini

# allowed environment variables, separated by spaces
ALLOWED_ENV="ORACLE_HOME PATH USER"

## if this script is run as root, switch to the following user
USERID=www
GROUPID=www

ICE_HOME=/opt/Ice-3.2.0
export ICE_HOME
export DYLD_LIBRARY_PATH=$ICE_HOME/lib:$DYLD_LIBRARY_PATH
################## no config below this line

if test x$PHP_FCGI_CHILDREN = x; then
  PHP_FCGI_CHILDREN=5
fi

export PHP_FCGI_MAX_REQUESTS
export FCGI_WEB_SERVER_ADDRS
export PHPRC

ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS PHPRC ICE_HOME DYLD_LIBRARY_PATH"

if test x$UID = x0; then
  if test x$FCGISOCKET = x; then
  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN -P $PID"
  else
  EX="$SPAWNFCGI -s $FCGISOCKET -f $FCGIPROGRAM -u $USERID -g $GROUPID -C $PHP_FCGI_CHILDREN -P $PID "
  fi
else
  if test x$FCGISOCKET = x; then
  EX="$SPAWNFCGI -p $FCGIPORT -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN -P $PID "
  else
  EX="$SPAWNFCGI  -s $FCGISOCKET -f $FCGIPROGRAM -C $PHP_FCGI_CHILDREN -P $PID"
  fi
fi

# copy the allowed environment variables
E=

for i in $ALLOWED_ENV; do
  E="$E $i=${!i}"
done

# clean the environment and set up a new one
start(){
    if [ -f $PID ];then
        echo "PHP is running already.";
        exit 1;
    fi
   env - $E $EX
}
stop(){
    if test -f $PID;then
        killall `basename $FCGIPROGRAM`
        rm -f $PID
    else
        echo "PHP is not running"
    fi
}

#Main################
case "$1" in
    'start')
    start
    ;;
    'stop')
    stop
    ;;
    'restart')
    stop
    start
    ;;
    *)
    echo "usage: $0 {start|stop|restart}"
    ;;
esac
exit 1

IcePHP导致PHP5 Crash

IcePHP3.2编译成功后就没有仔细看,昨天才发现,PHP5 FastCGI daemon不能启动,crash记录中显示:


Library not loaded: ../../lib/libIce.3.2.0.dylib
  Referenced from: /opt/IcePHP-3.2.0/lib/IcePHP.so
  Reason: image not found

应该是Ice的动态库无法找到,但是在bashrc中指定了libpath了。
今天又仔细看了一下,发现是在spawn-php5.sh中的问题,我使用了一个脚本来启动php5,
但是其中环境变量没有传递给php,虽然spawn-fcgi可以获得,但是php无法知道。
修改了一下这几行:

 ICE_HOME=/opt/Ice-3.2.0
 export ICE_HOME
 export DYLD_LIBRARY_PATH=$ICE_HOME/lib:$DYLD_LIBRARY_PATH
ALLOWED_ENV="$ALLOWED_ENV PHP_FCGI_MAX_REQUESTS FCGI_WEB_SERVER_ADDRS PHPRC ICE_HOME DYLD_LIBRARY_PATH"

重新启动Php5,正常。

很想有个无线的Mighty Mouse

看着眼馋啊,攒钱。。。


还有iPhone,不知道什么时候能在中国用?一直忍着难用的dopod585,就为它呢。。。

WWDC2007开幕,Leopard太令人期待了

盼望着,盼望着,WWDC2007开始了….

Apple的网站也改版了。
很欣赏spotlight风格的搜索栏,还有download的tab切换风格。

Safari3开始公测,开始有了Windows版本,不过中文字体有问题,mac版本非常好,速度的确比2要快不少。

看了Jobs的Keynote,不过网络太慢,不爽。

最令人兴奋的是Leopard最新功能的演示。

Apple就是牛啊,相比之下,Vista太小儿科了,和Leopard简直没法比。
我不会为xp升级到vista,用盗版好了呵呵。
但是愿意掏钱为我的macbook pro从tiger升级到Leopard,值!

NASA说,WWDC后应该可以很快下载Leopard的最新测试版,这些天要关注一下mac developer,
看看是否有新的消息。

刚才注册了.mac, 可以试用3个月,很棒。
以前曾经说过,google如果能够把服务整合成.mac那样就太牛了,
虽然通过firefox已经实现了一小部分,但是和.mac比还是有不小的差距。

Compile IcePHP 3.2 with PHP 5.2.3 on Mac Osx

IcePHP在Linux和Windows上似乎都很好编译,但是非常不幸,我用的是Macbook Pro :(
按照帮助配置了config/Make.rules, make 立刻报错,缺少Make.rules.Darwin, 晕啊,Zeroc似乎
不喜欢osx啊,还好发现Ice的源码中有Make.rules.Darwin,在Zeroc的forum上,有人直接复制了
过来,成功编译了IceRuby。以为可以,但是不幸的是,link的时候仍然报了一大堆错误。
看来没戏了,我想去forum发个贴问问,因为3.1还支持osx呢,3.2怎么就突然不支持了呢?
而且奇怪的是,3.1用phpize来autoconf的,但是3.2,则用了手写的Makefile。
ZeroC的forum真是难注册,竟然还需要人工审核才能发言。我等了1天,结果告知我没有被通过,
说是关于本人和使用项目的描述不清,让我重新注册。要被气死,求人不如求己,一气之下
自己写了一个compile.sh,直接用g++编译,管他什么Makefile,竟然link成功,嗯。
看来问题不大,应该是Make.rules.Darwin的问题。既然能用了,就不那么郁闷了,重新审视了
这个配置,嗯,由于是编译Ice使用的,直接用来编译PHP的shared module的确有问题,改了
几处地方,一切都ok了。

你可以在这里下载Makefile.rules.Darwin.

If you want build IcePHP 3.2 with PHP 5.2.x on Mac osx, you should need this file Make.rules.Darwin,
save into config dir under IcePHP source direcotry, then make again.

Make.rules.Darwin (compile IcePHP-3.2 on mac osx)

Icc 9 compile script for PHP5.2.3 on x86_64

默认的php脚本是无法在x86_64上面编译的。
此脚本适用于php5.2.x.

flags="-cxxlib-icc -i-static -unroll2 -O3 -no-prec-div -xP " \
CC=icc \
CXX=icpc \
CFLAGS="$flags" \
CXXFLAGS="$flags" \
./configure \
--prefix=/usr/local/php5  \
--with-libdir=lib64 \
--enable-force-cgi-redirect \
--enable-fastcgi \
--enable-ftp \
--enable-calendar \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-mbregex \
--enable-shmod \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-inline-optimization \
--disable-ipv6 \
--disable-debug \
--with-config-file-path=/usr/local/php5/etc \
--with-config-file-scan-dir=/usr/local/php5/etc/php.d \
--with-zlib \
--with-curl \
--with-dom \
--with-dom-xslt \
--with-gd=/usr \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-gettext \
--with-openssl=shared \
--with-mysql \
--with-freetype-dir=/usr \
--with-mysqli \
--with-iconv  \
--with-gettext \
--with-xml \
--with-kerberos \
--with-pcre-regex \
--with-mime-magic=/usr/share/file/magic.mime
make clean
make

Php4/Php5 compile script on mac osx

我的编译脚本:

PHP4:

PATH=/usr/local/bin:/sw/bin:/usr/local/mysql/bin:/usr/bin:/bin ./configure \
--prefix=/usr/local/php4  \
--enable-force-cgi-redirect \
--enable-fastcgi \
--enable-ftp \
--enable-calendar \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-mbregex \
--enable-shmod \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-inline-optimization \
--disable-ipv6 \
--disable-debug \
--with-config-file-path=/usr/local/php4/etc \
--with-config-file-scan-dir=/usr/local/php4/etc/php.d \
--with-zlib \
--with-curl \
--with-dom \
--with-dom-xslt \
--with-gd=/sw \
--enable-gd-native-ttf \
--with-jpeg-dir=/sw \
--with-png-dir=/sw \
--with-gettext \
--with-openssl=shared \
--with-mysql=/usr/local/mysql \
--with-freetype-dir=/usr/X11R6 \
--with-iconv=/usr  \
--with-gettext=/sw \
--with-xml \
--with-kerberos \
--with-pcre-regex \
--with-mime-magic=/usr/share/file/magic.mime
make clean
make
make test && make install

PHP5:

PATH=/usr/local/bin:/sw/bin:/usr/local/mysql/bin:/usr/bin:/bin ./configure \
--prefix=/usr/local/php5  \
--enable-force-cgi-redirect \
--enable-fastcgi \
--enable-ftp \
--enable-calendar \
--enable-gd-native-ttf \
--enable-mbstring \
--enable-mbstr-enc-trans \
--enable-mbregex \
--enable-shmod \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-inline-optimization \
--disable-ipv6 \
--disable-debug \
--with-config-file-path=/usr/local/php5/etc \
--with-config-file-scan-dir=/usr/local/php5/etc/php.d \
--with-zlib \
--with-curl \
--with-dom \
--with-dom-xslt \
--with-gd=/sw \
--enable-gd-native-ttf \
--with-jpeg-dir=/sw \
--with-png-dir=/sw \
--with-gettext \
--with-openssl=shared \
--with-mysql=/usr/local/mysql \
--with-mysqli \
--with-freetype-dir=/usr/X11R6 \
--with-iconv=/usr  \
--with-gettext=/sw \
--with-xml \
--with-kerberos \
--with-pcre-regex \
--with-mime-magic=/usr/share/file/magic.mime 

make clean
make test && make install

Lighttpd php4/php5 conf:


$HTTP["url"] =~ "\.php$" {
    proxy-core.balancer = "round-robin"
    proxy-core.protocol = "fastcgi"
    proxy-core.allow-x-sendfile = "enable"
  #  proxy-core.backends = ( "unix:/tmp/php4.socket" )
    proxy-core.backends = ( "unix:/tmp/php5.socket" )
    proxy-core.max-pool-size = 2
    proxy-core.rewrite-request=(
            "_pathinfo"=>("\.php(/.*)" =>"$1" )
    )
}

note:如果没有rewrite则无法支持path_info

Google gears

http://gears.google.com/
http://code.google.com/apis/gears/

Google gears 可以让你离线状态下使用web 程序,比如google reader,notebook,
原先的web程序可以通过gears api读取、存储数据到本地,并且存储的内容是一个数据库,可以检索的,
同时完全支持异步执行操作。

当安装gears扩展后,在使用支持的程序比如 google reader时,会出现一个绿色的小箭头,点击会进入脱机
模式,此时gear会自动下载相应的数据和代码。无需网络,你也可以查看你订阅的rss了。
gears的发布,感觉google越发挑战ms的地位,当即便脱机也可以使用google的office产品,还需要安装ms office吗?

对于我们开发者来说,gears可以和applo联合使用,或者直接应用在你的web程序中,很快,你的web app可以支持offline了,我会近期尝试一下。gears可以让你的web应用直接扩展到桌面,听起来很酷啊。