php-excel是一个PHP导出excel文件的类库。导出的是XML文件,用office2003,openoffice3都可以正常打开。
官方网站:
http://code.google.com/p/php-excel/
简单的例子:
<?php
// load library
require ‘php-excel.class.php’;
// create a simple 2-dimensional array
$data = array(
1 => array (‘Name’, ‘呵呵’),
array(‘Schwarz’, ‘Oliver’),
array(‘Test’, ‘Peter’)
);
// generate file (constructor parameters are optional)
$xls = new Excel_XML(‘GB2312′, true, ‘My Test Sheet’);
$xls->addArray($data);
$xls->generateXML(‘my-test’);
?>
在新笔记本,迁移到UTF-8环境下,mrxvt不支持UTF-8,中文显示乱码。只有换成rxvt-unicode了。支持UTF-8,中文输入。
配置文件:
$ cat ~/.Xresources
Xft.dpi:96
! Color setting
!URxvt.geometry: 200×53
URxvt.cursorColor:green
URxvt.foreground:black
URxvt.background:lightyellow
! transparent setting
URxvt.inheritPixmap:false
URxvt.tintColor:lightyellow
URxvt.shading:-80
! normal setting
URxvt.termName:rxvt
URxvt.cursorBlink:true
URxvt.saveLines:65535
URxvt.scrollBar_right:true
URxvt.scrollTtyKeypress:true
URxvt.scrollWithBuffer:false
!URxvt.font:xft:serif:pixelsize=13:antialias=false
!URxvt.font: 9x15bold,\
! -misc-fixed-bold-r-normal–15-140-75-75-c-90-iso10646-1,\
! -misc-fixed-medium-r-normal–15-140-75-75-c-90-iso10646-1,\
! [codeset=cp936]xft:serif:antialias=false, \
! xft:simsun:antialias=false
URxvt.font: -*-fixed-medium-r-*–14-*-*-*-*-*-iso10646-1,\
xft:simsun:pixelsize=14:antialias=false
! test modify ALT key value
!URxvt.insecure:true
!URxvt.modifier:alt
!URxvt.meta8:true
!XTerm*VT100*metaSendsEscape:true
urxvt*font:xft:SimSun:pixelsize=16
urxvt*imFont: -misc-simsun-medium-r-normal-0-0-0-0-p-0-iso10646-1
urxvt*inputMethod:SCIM
urxvt*preeditType: OverTheSpot
urxvt*multichar_encoding:noenc
今天发现一个好玩的东东,可以将shell脚本编译一下。
http://www.datsi.fi.upm.es/~frosal/sources/shc.html
文档:
Manpage for shc(1)
NAME
shc - Generic shell script compiler
SYNOPSIS
shc [ -e date ] [ -m addr ] [ -i iopt ] [ -x cmnd ]
[ -l lopt ] [ -ACDhTv ] -f script
DESCRIPTION
shc creates a stripped binary executable version of the
script specified with -f on the command line.
The binary version will get a .x extension appended and will
usually be a bit larger in size than the original ascii
code. Generated C source code is saved in a file with the
extension .x.c
If you supply an expiration date with the -e option the com-
piled binary will refuse to run after the date specified.
The message "Please contact your provider" will be displayed
instead. This message can be changed with the -m option.
You can compile any kind of shell script, but you need to
supply valid -i, -x and -l options.
The compiled binary will still be dependent on the shell
specified in the first line of the shell code (i.e.
#!/bin/sh), thus shc does not create completely independent
binaries.
shc itself is not a compiler such as cc, it rather encodes
and encrypts a shell script and generates C source code with
the added expiration capability. It then uses the system
compiler to compile a stripped binary which behaves exactly
like the original script. Upon execution, the compiled
binary will decrypt and execute the code with the shell -c
option. Unfortunatelly, it will not give you any speed
improvement as a real C program would.
shc's main purpose is to protect your shell scripts from
modification or inspection. You can use it if you wish to
distribute your scripts but don't want them to be easily
readable by other people.
OPTIONS
The command line options are:
-e date
Expiration date in dd/mm/yyyy format [none]
-m message
message to display upon expiration ["Please contact
your provider"]
-f script_name
File name of the script to compile
-i inline_option
Inline option for the shell interpreter i.e: -e
-x comand
eXec command, as a printf format i.e:
exec(\\'%s\\',@ARGV);
-l last_option
Last shell option i.e: --
-r Relax security. Make a redistributable binary which
executes on different systems running the same operat-
ing system.
-v Verbose compilation
-D Switch on debug exec calls
-T Allow binary to be traceable (using strace, ptrace,
truss, etc.)
-C Display license and exit
-A Display abstract and exit
-h Display help and exit
ENVIRONMENT VARIABLES
CC C compiler command [cc]
CFLAGS
C compiler flags [none]
EXAMPLES
Compile a script which can be run on other systems with the
trace option enabled:
example% shc -v -r -T -f myscript
BUGS
The maximum size of the script that could be executed once com�
piled is limited by the operating system configuration parameter
_SC_ARG_MAX (see sysconf(2))
AUTHOR
Francisco Rosales <frosal@fi.upm.es>
REPORT BUGS TO
the author.
1993年在巴西里约热内卢天主教大学(Pontifical Catholic University of Rio de Janeiro in Brazil)诞生了一门编程语言,发明者是该校的三位研究人员,他们给这门语言取了个浪漫的名字——Lua,在葡萄牙语里代表美丽的月亮。事实证明她没 有糟蹋这个优美的单词,Lua语言正如它名字所预示的那样成长为一门简洁、优雅且富有乐趣的语言。
Lua从一开始就是作为一门方便嵌入(其它应用程序)并可扩展的轻量级脚本语言来设计的,因此她一直遵从着简单、小巧、可移植、快速的原则,官 方实现完全采用ANSI C编写,能以C程序库的形式嵌入到宿主程序中。Lua的每个版本都保持着开放源码的传统,不过各版采用的许可协议并不相同,自5.0版(最新版是5.1) 开始她采用的是著名的MIT许可协议。正由于上述特点,所以Lua在游戏开发、机器人控制、分布式应用、图像处理、生物信息学等各种各样的领域中得到了越 来越广泛的应用。其中尤以游戏开发为最,许多著名的游戏,比如Escape from Monkey Island、World of Warcraft、大话西游,都采用了Lua来配合引擎完成数据描述、配置管理和逻辑控制等任务。
作为一门过程型动态语言,Lua有着如下的特性:
1、变量名没有类型,值才有类型,变量名在运行时可与任何类型的值绑定;
2、语言只提供唯一一种数据结构,称为表(table),它类似key-value关联数组,可以用任何类型的值作为key和value。提供 了一致且富有表达力的表构造语法,使得Lua很适合描述复杂的数据;
3、函数是一等类型,支持匿名函数和正则尾递归(proper tail recursion);
4、支持词法定界(lexical scoping)和闭包(closure);
5、提供thread类型和结构化的协程(coroutine)机制,在此基础上可方便实现协作式多任务;
6、运行期能编译字符串形式的程序文本并载入虚拟机执行;
7、通过元表(metatable)和元方法(metamethod)提供动态元机制(dynamic meta-mechanism),从而允许程序运行时根据需要改变或扩充语法设施的内定语义;
8、能方便地利用表和动态元机制实现基于原型(prototype-based)的面向对象模型;
9、从5.1版开始提供了完善的模块机制,从而更好地支持开发大型的应用程序;
Lua的语法类似PASCAL和Modula但更加简洁,所有的语法产生式规则(EBNF)不过才60几个。熟悉C和PASCAL的程序员一般 只需半个小时便可将其完全掌握。而在语义上Lua则与Scheme极为相似,她们完全共享上述的1、3、4、6点特性, Scheme的continuation与协程也基本相同只是自由度更高。最引人注目的是,两种语言都只提供唯一一种数据结构:Lua的表和Scheme 的列表(list)。正因为如此,有人甚至称Lua为“只用表的Scheme”。 阅读全文…
使用PHP来生成条码,找到了一个开源的程序php-barcode。
网站首页: http://www.ashberg.de/php-barcode/index.php
下载地址: http://www.ashberg.de/php-barcode/download/
需要安装barcode 和genbarcode。我是在FreeBSD下安装的。barcode就直接在ports里安装了。
安装barcode:
# cd /usr/ports/graphics/barcode
# make install clean
安装genbarcode:
# tar -zxf genbarcode-0.4.tar.gz
# cd genbarcode-0.4
# gmake
# gmake install
安装php-barcode:
在WEB目录下:
# tar -zxf php-barcode-0.3pl1.tar.gz
# mv php-barcode-0.3pl1 phpbarcode
# chmod -R 755 phpbarcode
访问:
* http://localhost/barcode.php?code=012345678901
* http://localhost/barcode.php?code=012345678901&encoding=EAN&scale=4&mode=png

条码图
php-fpm的freebsd ports只到5.2.11就没有更新了。但是其他php的扩展都升级到了5.2.12。调试程序的时候出现异常情况。就自己动手修改了php-fpm的ports配置文件。
Makefile 补丁:
— ../php5-fpm/Makefile 2009-10-13 05:53:43.000000000 +0800
+++ Makefile 2010-04-02 21:08:21.000000000 +0800
@@ -7,7 +7,7 @@
PORTNAME= php5-fpm
PORTVERSION= ${PHP_VERSION}
-PHP_VERSION= 5.2.11
+PHP_VERSION= 5.2.12
PHPFPM_VERSION= 0.6.3
PORTREVISION?= 0
CATEGORIES?= lang devel www
distinfo补丁:
— ../php5-fpm/distinfo 2009-10-13 05:41:42.000000000 +0800
+++ distinfo 2010-04-02 21:13:46.000000000 +0800
@@ -1,12 +1,12 @@
-MD5 (php-5.2.11.tar.bz2) = 286bf34630f5643c25ebcedfec5e0a09
-SHA256 (php-5.2.11.tar.bz2) = 9bcd14ceda2b4bd7abcc7eb59bd74bae490d9335e4207580de783b48aa7e8f23
-SIZE (php-5.2.11.tar.bz2) = 9030787
+MD5 (php-5.2.12.tar.bz2) = 5b7077e366c7eeab34da31dd860a1923
+SHA256 (php-5.2.12.tar.bz2) = e65756a8412726a491ca48da1e0693eaeb3f38f19fb6cbc8f53005cab1f2491a
+SIZE (php-5.2.12.tar.bz2) = 9075161
MD5 (php-fpm-0.6.3.tar.bz2) = be0d67a73474f2273b8d90447d057fc2
SHA256 (php-fpm-0.6.3.tar.bz2) = 1233ce7b19c90e159474af13548541617ceead85887b201f752bc1bbbe3e4905
SIZE (php-fpm-0.6.3.tar.bz2) = 1909302
-MD5 (suhosin-patch-5.2.11-0.9.7.patch.gz) = 8f9de4d97fae6eba163cf3699509a260
-SHA256 (suhosin-patch-5.2.11-0.9.7.patch.gz) = 392f10c9b7d9c47f30e989fb7775cc46d36153b933bf7ac9ccd8826b2954584b
-SIZE (suhosin-patch-5.2.11-0.9.7.patch.gz) = 23050
+MD5 (suhosin-patch-5.2.12-0.9.7.patch.gz) = 40be1b05ad893a01778d7fb323dd8872
+SHA256 (suhosin-patch-5.2.12-0.9.7.patch.gz) = f324cf09cb83826fb35308c890ca06e14d64e5d65129f3ba8f3e61953e442366
+SIZE (suhosin-patch-5.2.11-0.9.7.patch.gz) = 23062
MD5 (php-5.2.10-mail-header.patch) = 7f73682e78d32e22989c3fb3678d668b
SHA256 (php-5.2.10-mail-header.patch) = a61d50540f4aae32390118453845c380fe935b6d1e46cef6819c8561946e942f
SIZE (php-5.2.10-mail-header.patch) = 3383
在编译安装的过程中,会报libevent错误:
../libevent/.libs/libevent.a: could not read symbols: File format not recognized
*** Error code 1
Stop in /usr/ports/lang/php5-fpm/work/php-fpm-0.6.3/src.
*** Error code 1
Stop in /usr/ports/lang/php5-fpm/work/php-fpm-0.6.3/src.
*** Error code 1
Stop in /usr/ports/lang/php5-fpm/work/php-fpm-0.6.3/src.
*** Error code 1
Stop in /usr/ports/lang/php5-fpm/work/php-fpm-0.6.3.
*** Error code 1
解决办法:
# cd work/php-fpm-0.6.3/libevent/
# make clean
# cd ../../../
# make install clean
最近两天在学习nginx,顺便也学习了下libevent。将相关的一些技术文章地址摘录如下:
http://night9.cn/category/nginx
http://amix.dk/blog/viewEntry/19414
http://www.igvita.com/2008/02/11/nginx-and-memcached-a-400-boost/
http://wiki.nginx.org/Nginx3rdPartyModules
http://code.google.com/p/php-redis/
http://blog.sina.com.cn/iyangjian
如何写nginx module
http://timyang.net/web/nginx-module/
http://code.google.com/p/redis/
另外,计划使用libevent改写扫描和发送报警引擎。
最新评论