python开启简单http服务器

Written by baobaodaren on 2012年01月13日 Categories: python


python -m SimpleHTTPServer

简单一句,可以用于系统调试,比如负载均衡测试,网络测试等.

评论暂缺

日月昭昭,唯我大明——明代国旗

Written by baobaodaren on 2012年01月7日 Categories: 未分类

关于日月旗最早的由来是元末明初反抗当时统治者的人民在中秋节日悬挂来表示反元的标志。这种日月旗就是后来明朝国旗。

日月旗是明朝的国旗,由明朝的国号“明”字的意义演化而来,明朝最初没有国旗,隆庆开关以后,由于对外贸易的迅速发展,明朝船只按照国际上的标准悬挂了一种旗帜以区别于葡萄牙、荷兰等国船只的国旗,成为当时事实上的中国国旗。近年来,南洋一些明代船只被打捞,这种旗帜也重新面世。

日月旗的象征和含义:

这面旗叫日月旗。中间的黄色象征月亮,后面的光芒象征太阳,偏紫的蓝色的天象徵开放的明朝。

取日月重叠之意义(日在后,月在前) 日月即是明。

旗帜由红日、黄月重叠的图案和蓝底组成。蓝底代表青天,象征着我大汉民族光明磊落、崇高伟大的人格和志气。

  日月重叠即是“明”字,代表大明,位于旗帜的正中不偏不倚,是取中国位于四方之中之意。

  旗帜中央的黄色又代表着汉人的肤色,象征着大明是汉族人建立和统治的国家,黄色位于中央,意指大明将汉族的利益视为核心利益。

  红色的光芒是太阳的光芒,又象征大明属于火德,亦指统治大明的朱姓皇族。十二道光芒即指一天十二个时辰,一年十二个月,光芒位于青天之上,表示大明光辉时刻都在普照万方。

红色光芒中四个尖锐的大角,分指上下左右四个方向,即“际天极地,罔不臣妾”之意,又表示着礼义廉耻,国之四维,是大明世代遵守的道德规范。

中国道教的象征是阴阳图,“阴阳”去掉“β”就是“日月”

这面旗帜无疑是设计非常到位的,让人可以无穷联想。

日月旗的演进

  日月旗使用之初,底色采用玄色,图案为正方形,因为玄色自古以来是象征汉族的颜色。但因为玄色太暗不易看清,故改为蓝色。后来又根据国际惯例,将旗帜的形状改为大多数国家通行的长方形,成为我们现在见到的样子。

日月旗的使用

  以反清复明为宗旨的洪门,曾经使用过日月旗,反抗清廷。洪门中有《大明旗诗》云:“日月旗中第一枝,会合洪英创洪基。为人须要存忠义,不可外头说是非。”

相关官方新闻:http://news.sina.com.cn/c/2005-08-22/01576746251s.shtml

评论暂缺

IE6-7-8 无法显示CMYK模式JPEG图片的问题

Written by baobaodaren on 2011年12月29日 Categories: 未分类

由于CMYK模式保存的JPEG图片无法在IE6,IE7,IE8中显示,需要做转码处理
但是在目前非IE核心浏览器如 firefox chrome 可以打开
这是因为IE6,IE7,IE8不支持CMYK模式的jpeg图片
而非IE核心的可以正常打开浏览
其实解决这个问题很简单,
可以在用photoshop打开图片,在窗口会显示图片名和模式,依次点击菜单栏——图像——RGB模式就行了,
然后保存替换,重新上传到服务器也可以。用acdsee 转换也是可以。
geek们可以用convert加一个 -colorspace RGB 参数就可以解决这个问题,原因去翻文档吧。。。

这里附上2张图
RGB:

CMYK:

如何找出目录里面有的CMYK模式的图片,可以试试下面这个脚本:

此脚本需要imagemagick库支持
#!/bin/bash

if [ ! -d "$1" ]
then
        echo "Script to look for JPEG files in the CMYK colorspace."
        echo "Usage: $0 directory"
        exit 1
fi
find "$1" -type f | while read filename
do
        filetype=$(file -b "$filename" |awk '{print $1}')
        if [ $filetype == 'JPEG' ]
        then
                colorspace=$(identify -verbose "$filename" |grep " Colorspace:" |awk '{print $2}')
                if [ $colorspace == 'CMYK' ]
                then
                        echo "$filename"
                fi
        fi
done

在python中如何判断CMYK
用PiL来判断
debian下安装PiL:
sudo apt-get install python-imaging

import Image
im = Image.open('./test/CMYK.jpg')
print im.mode
评论暂缺

squid 日志统计–请求域名的排序

Written by baobaodaren on 2011年12月28日 Categories: squid
##日志为combined模式
cat /usr/local/squid/var/logs/access.log |awk '{print $7}'|awk -F '/'  '{print $3}'|sort| uniq -c| sort -k 1 -n -r
###
评论暂缺

shell单行脚本

Written by baobaodaren on  Categories: shell Tags: 
for ((n=0;n<10;n++));do CMD; done
评论暂缺

㸚叕㠭㗊

Written by baobaodaren on 2011年12月5日 Categories: 未分类

㸚(音:「里」) lǐ
叕(音:「辍」) zhuó
㠭(音:「展」) zhǎn
㗊(音:「吉」) jí

㸚叕㠭㗊

叕 多音字,可以念zhui,zhuo,yi,jue

3 条评论

debian6上安装lnmp平台

Written by baobaodaren on 2011年12月1日 Categories: Linux

最近要为监控系统写点php页面,所以开始现学php,当然要建立一个php的开发环境了,
系统当然选择debian了,重新在vbox里面装了虚拟机debian6,新的vbox4.1.6 支持了图形界面的端口转发,设置端口转发更方便了
步骤是 选择虚机,设置,网络,点击Port Forwording 设置几个,比vbox3.0 用命令设置方便多了。

debian6上安装lnmp平台
1.安装nginx:
下载nginx:

安装nginx:

cd nginx-1.1.8/
./configure --prefix=/usr/local/nginx --with-http_realip_module  --with-http_sub_module --with-http_flv_module --with-http_dav_module --with-http_gzip_static_module --with-http_stub_status_module
make install
make
cd ../

3.安装mysql
mysql 还是不编译算了
直接apt-get
apt-get install mysql-server

3.安装php:
php-fpm已经被php收编
在最新的php5.3版本中就可以使用了

wget http://cn2.php.net/distributions/php-5.3.7.tar.gz
tar zxvf php-5.3.7.tar.gz
cd php-5.3.7/
./buildconf --force

先查看autoconf版本够不?

apt-get install autoconf2.13

再安装一些依赖关系:

apt-get install libxslt1-dev libmcrypt-dev
 aptitude install libtidy-dev curl libcurl4-openssl-dev libcurl3 libcurl3-gnutls zlib1g zlib1g-dev libxslt1-dev libzip-dev libzip1 libxml2 libsnmp-base libsnmp15 libxml2-dev libsnmp-dev libjpeg62 libjpeg62-dev libpng12-0 libpng12-dev zlib1g zlib1g-dev libfreetype6 libfreetype6-dev libbz2-dev libxpm-dev libmcrypt-dev libmcrypt4 sqlite3 bzip2 build-essential libreadline5-dev libedit-dev
 ./configure  --prefix=/usr/local/php   --with-config-file-path=/usr/local/php/etc  --with-config-file-scan-dir=/usr/local/php/etc/conf.d  --enable-fpm       --with-curl       --with-pear       --with-gd   --with-jpeg-dir     --with-png-dir       --with-zlib       --with-xpm-dir       --with-freetype-dir       --with-mcrypt       --with-mhash       --with-mysql       --with-mysqli       --with-pdo-mysql       --with-openssl       --with-xmlrpc       --with-xsl       --with-bz2       --with-gettext       --disable-debug       --enable-fpm       --enable-exif       --enable-wddx       --enable-zip       --enable-bcmath       --enable-calendar       --enable-ftp       --enable-mbstring       --enable-soap       --enable-sockets       --enable-sqlite-utf8   --enable-shmop  --enable-dba  --enable-sysvsem   --enable-sysvshm       --enable-sysvmsg

 make
 make test
 make install
 cp  php.ini-production /usr/local/php/etc/
 cp  php.ini-production /usr/local/php/etc/php.ini

4.配置php 和php-fpm
vi /usr/local/php/etc/php.ini

 [PHP]
engine = On
short_open_tag = Off
asp_tags = Off
precision = 14
y2k_compliance = On
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
unserialize_callback_func =
serialize_precision = 17
allow_call_time_pass_reference = Off
safe_mode = Off
safe_mode_gid = Off
safe_mode_include_dir =
safe_mode_exec_dir =
safe_mode_allowed_env_vars = PHP_
safe_mode_protected_env_vars = LD_LIBRARY_PATH
disable_functions =
disable_classes =
expose_php = On
max_execution_time = 30
max_input_time = 60
memory_limit = 128M
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = On
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
ignore_repeated_errors = Off
ignore_repeated_source = Off
report_memleaks = On
track_errors = Off
html_errors = Off
variables_order = "GPCS"
request_order = "GP"
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
auto_globals_jit = On
post_max_size = 8M
magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
doc_root =
user_dir =
enable_dl = Off
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
[Date]
[filter]
[iconv]
[intl]
[sqlite]
[sqlite3]
[Pcre]
[Pdo]
[Pdo_mysql]
pdo_mysql.cache_size = 2000
pdo_mysql.default_socket=
[Phar]
[Syslog]
define_syslog_variables  = Off
[mail function]
SMTP = localhost
smtp_port = 25
mail.add_x_header = On
[SQL]
sql.safe_mode = Off
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQL]
mysql.allow_local_infile = On
mysql.allow_persistent = On
mysql.cache_size = 2000
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.default_socket =
mysql.default_host =
mysql.default_user =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = Off
[MySQLi]
mysqli.max_persistent = -1
mysqli.allow_persistent = On
mysqli.max_links = -1
mysqli.cache_size = 2000
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off
[mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = Off
[OCI8]
[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0
[Sybase-CT]
sybct.allow_persistent = On
sybct.max_persistent = -1
sybct.max_links = -1
sybct.min_server_severity = 10
sybct.min_client_severity = 10
[bcmath]
bcmath.scale = 0
[browscap]
[Session]
session.save_handler = files
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.bug_compat_42 = Off
session.bug_compat_warn = Off
session.referer_check =
session.entropy_length = 0
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[MSSQL]
mssql.allow_persistent = On
mssql.max_persistent = -1
mssql.max_links = -1
mssql.min_error_severity = 10
mssql.min_message_severity = 10
mssql.compatability_mode = Off
mssql.secure_connection = Off
[Assertion]
[COM]
[mbstring]
[gd]
[exif]
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
[mcrypt]
[dba]

vi /usr/local/php/etc/php-fpm.conf

[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = notice
[www]
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
listen.owner = nobody
listen.group = nobody
listen.mode = 0666
user = nobody
group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

vi /etc/init.d/php-fpm

#!/bin/sh

    ### BEGIN INIT INFO
    # Provides:          php-fpm
    # Required-Start:    $remote_fs $network
    # Required-Stop:     $remote_fs $network
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts php-fpm
    # Description:       starts the PHP FastCGI Process Manager daemon
    ### END INIT INFO

    prefix=/usr/local/php
    exec_prefix=${prefix}

    php_fpm_BIN=${exec_prefix}/sbin/php-fpm
    php_fpm_CONF=${prefix}/etc/php-fpm.conf
    php_fpm_PID=${prefix}/var/run/php-fpm.pid

    php_opts="--fpm-config $php_fpm_CONF"

    wait_for_pid () {
        try=0

        while test $try -lt 35 ; do

            case "$1" in
                'created')
                if [ -f "$2" ] ; then
                    try=''
                    break
                fi
                ;;

                'removed')
                if [ ! -f "$2" ] ; then
                    try=''
                    break
                fi
                ;;
            esac

            echo -n .
            try=`expr $try + 1`
            sleep 1

        done

    }

    case "$1" in
        start)
            echo -n "Starting php-fpm "

            $php_fpm_BIN $php_opts

            if [ "$?" != 0 ] ; then
                echo " failed"
                exit 1
            fi

            wait_for_pid created $php_fpm_PID

            if [ -n "$try" ] ; then
                echo " failed"
                exit 1
            else
                echo " done"
            fi
        ;;

        stop)
            echo -n "Gracefully shutting down php-fpm "

            if [ ! -r $php_fpm_PID ] ; then
                echo "warning, no pid file found - php-fpm is not running ?"
                exit 1
            fi

            kill -QUIT `cat $php_fpm_PID`

            wait_for_pid removed $php_fpm_PID

            if [ -n "$try" ] ; then
                echo " failed. Use force-exit"
                exit 1
            else
                echo " done"
            fi
        ;;

        force-quit)
            echo -n "Terminating php-fpm "

            if [ ! -r $php_fpm_PID ] ; then
                echo "warning, no pid file found - php-fpm is not running ?"
                exit 1
            fi

            kill -TERM `cat $php_fpm_PID`

            wait_for_pid removed $php_fpm_PID

            if [ -n "$try" ] ; then
                echo " failed"
                exit 1
            else
                echo " done"
            fi
        ;;

        restart)
            $0 stop
            $0 start
        ;;

        reload)

            echo -n "Reload service php-fpm "

            if [ ! -r $php_fpm_PID ] ; then
                echo "warning, no pid file found - php-fpm is not running ?"
                exit 1
            fi

            kill -USR2 `cat $php_fpm_PID`

            echo " done"
        ;;

        *)
            echo "Usage: $0 {start|stop|force-quit|restart|reload}"
            exit 1
        ;;

    esac
 

/etc/init.d/php-fpm start

可能会报错
nobody 用户组问题
groupadd nobody

5.配置nginx+php-fpm
配置nginx:

worker_processes  4;
error_log  logs/error.log  info;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  logs/access.log  main;
    sendfile        on;
    keepalive_timeout  65;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    gzip  on;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /path/to/dev/php_dev;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /path/to/dev/php_dev$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
}

在/path/to/dev/php_dev下
编辑phpinfo.php

<?php
    phpinfo();
?>

浏览器测试。。。。。。

评论暂缺

debian 设置vi为crontab的默认编辑器

Written by baobaodaren on 2011年09月6日 Categories: Linux

debian中设置vi为crontab的默认编辑器,debian中原本默认编辑器是nano,这个nano是个很残的编辑器,

只需要下面的命令,然后选择vim.basic 即可(debian5.x debian6.x 中实验通过):

xu:~# update-alternatives --config editor

There are 4 alternatives which provide `editor'.

  Selection    Alternative
-----------------------------------------------
          1    /bin/ed
*+        2    /bin/nano
          3    /usr/bin/vim.tiny
          4    /usr/bin/vim.basic

Press enter to keep the default[*], or type selection number: 4
评论暂缺

用xen-center安装debian

Written by baobaodaren on 2011年08月18日 Categories: Linux

用xen-center安装debian

用xen-center安装debian太搞人了
试了debian的3种iso文件 都不行
最后试了网络安装 最后终于成功

评论暂缺

debian初始安装没有killall命令?

Written by baobaodaren on  Categories: Linux

debian初始安装没有killall命令?

今天用xen-center安装了 一枚debian-lenny用作公司网站网页加载测试(基于python pyqt webkit)
进入系统发现没有killall命令
search 一下发现:
pageload:~# apt-cache search killall
psmisc – Utilities that use the proc filesystem
sysvinit-utils – System-V-like utilities

应该是psmisc

pageload:~# apt-get install psmisc

bingo 搞定.

评论暂缺
普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress