Compare Date with PERL

Posted in Uncategorized on January 28th, 2008 by Adam

(This is one of my English Diary, just for exercise.)
I haven’t touch PERL for a long time, feel so tired to debug script error on page with “Internal Server Error”, that’s the reason I don’t like it. But the reason I still use it is because CPAN, it’s a huge library for PERL Archive. You can easily find any function you can imagine. Here’s a example to Compare Date.
[code lang="per"]
#!/usr/bin/perl
print "Content-type: text/html\n\n";

# you need three packages: Date::Parse, Time::Local, Time::Zone;
# http://search.cpan.org/perldoc?Date::Parse
# http://search.cpan.org/perldoc?Time::Local
# http://search.cpan.org/perldoc?Time::Zone
use Date::Parse;
my $secs = str2time("2008-02-14");
my $now=time();
# check we got something useful back
unless (defined $secs){
die "Can't parse '$time' as a time or date\n";
}
print "End as:\n", "'$secs' (".gmtime($secs).")
\n";
print "Now as:\n", "'$now' (".gmtime($now).")
\n";
if($now >= $secs){
print "It's time to go now.";
}else{
print "Don't worry, still have time.";
}

[/code]

Tags: , , ,

Google催生更多千万、亿万富翁

Posted in Google与Idea on January 25th, 2008 by Adam

(据CNET报道)如果你突然有了1000万美元或者1亿美元,你会做什么?不要误会,这不是笑话,只是这个问题也不是问你,而是问给那些在Google工作过或正在工作的手中拥有巨额股票期权的IT幸运儿。短短几年Google创造了互联网上的财富神话,股票从2004年当初的85美元涨到现在的600美元左右,造就的百万富翁也从04年的900多名一下扩充到现在的成千上万名。目前为止,Google员工手上拥有的股票价值44.8亿美元,Google的创始人之一Larry Page,持有价值188.5亿美元的股票,另一创始人Sergey Brin持有价值也达到188.1亿美元。在拥有如此惊人的财富的情况下,很多人都会很好奇他们究竟有什么打算啊?退休,环球旅行,追求自己的梦想还是继续呆在Google呢?

根据银行资料,早期的500名Google员工已经有三分之一离开了公司。而到目前为止估计有2200多名拥有首次公开招股前的员工也正计划,当他们拿到股票就会退出Google。在这些离开的千万、亿万富翁之中,有人环球旅行和家人享受天伦之乐(这就是传说中的睡觉睡到自然醒,数钱数到手抽筋),也有的再次创业努力追寻自己的理想。其中大家比较熟悉就是Twitter的创始人之一也是来自Google。

对这些富翁来说,很多普通人一辈子追求的目标都已经达到,而且他们还非常年轻,之后他们要走的将是一段非常惬意的自由自在的任意发挥的光明之路。然而这些对于我们这些普通人,还在对两斗米而折腰的打工者来说,这又是一些我们可以看见的,实实在在的未来版畅想曲。无论未来是否会变得富有,我想我都应该好好想想人这一辈到底想要做什么,想要追求什么?怎么样人才活得有价值?^_^

Tags: ,

SQL Server管理小技巧

Posted in windows on January 18th, 2008 by Adam

1. 批量修改table所有者为’dbo’

EXEC sp_MSforeachtable ‘exec sp_changeobjectowner ”?”,”dbo” ‘

2. 快速导入导出image类型字段的方法: TEXTCOPY.exe
在企业管理启里面类似image等这样的Binary字段无法直接查看,TEXTCOPY.exe可以帮助我们轻松解决这个问题。SQL Server会将大于8k的二进制数据分段保存,所以用程序获取image字段的时候需要注意将分段的合并,所以在处理大量图片的时候,会出现效率上的问题。TEXTCOPY.exe是一个很好的快速高效工具,它可以帮助你快速存储和获取image字段,进行跨数据库的操作,而且免去了频繁使用用户名密码登录的麻烦和安全问题。你可以在SQL server的安装目录/MSSQL/Binn下找到它,其用法如下:

TEXTCOPY [/S [sqlserver] ] [/U [login] ] [/P [password] ] [/D [database] ] [/T table] [/C column] [/W "where clause"] [/F file] [{/I /O}] [/K chunksize] [/Z] [/?]
/S sqlserver : SQL Server 服务器,通常用(local)
/U login : 用户名
/P password
/D database : 数据库名
/T table : 数据表名
/C column : 字段为text或image的列名
/W “where clause” : 条件判断语句
/F file : 要存储或是导入源的文件名
/I : 表示插入数据
/O : 表示输出数据
/K : 分块数据段的大小,最小1024字节数,默认4096
/Z : 现实调试信息
/? : 帮助

Tags:

用PHP分析GIF动画图片

Posted in PHP on January 9th, 2008 by Adam

walkingcoder.gif
Phpclasses有一个生成GIF动态图片的Class当下来试试,很好用。

gift89a.gif

看了看源代码,只是实现了GIF图片的简单叠加,而如果要想做到分析GIF动态图片,做到将GIF动态图片拆分,甚至修改后重新生成新的GIF动态图片。看来还是要从分析GIF89a规范入手。在了解GIF89a的编码规则以后,还需要了解LZW,因为GIF采用的是这种LZW的无损压缩的算法。
这是我总结的GIF89a规则,希望有时间好好研究一下:

=========================
The Definition of the GIF Format allows for a Data Stream to contain:

* Header
Signature: 'GIF' => 3 bytes: 0x47 0x49 0x46
Version: '89a' => 3 bytes: 0x38 0x39 0x61
* the Logical Screen Descriptor
Logical Screen Width: unsigned 2 bytes
Logical Screen Height: unsigned 2 bytes
Packed Fields:
Global Color Table Flag 1 Bit
Color Resolution 3 Bits
Sort Flag 1 Bit
Size of Global Color Table 3 Bits
Background Color Index: 1 byte
Pixel Aspect Ratio: 1 byte (Aspect Ratio = (Pixel Aspect Ratio + 15) / 64)
* a Global Color Table
size: 3 x 2^(Size of Global Color Table+1).
* Image Descriptor
Image Separator: 1 byte => 0x2C
Image Left Position: unsigned 2 bytes
Image Top Position: unsigned 2 bytes
Image Width: unsigned 2 bytes
Image Height: unsigned 2 bytes
Packed Fields:
Local Color Table Flag 1 Bit (if 1, follow immediately after this Image Descriptor.)
Interlace Flag 1 Bit
Sort Flag 1 Bit
Reserved 2 Bits
Size of Local Color Table 3 Bits
* Table Based Image Data
LZW Minimum Code Size: 1 byte
Image Data (Data Sub-blocks)

//////////Animated Control Start
* Graphic Control Extension.
Extension Introducer: 1 byte => 0x21
Graphic Control Label: 1 byte => 0xF9
Block Size: 1 byte
Packed Fields:
Reserved 3 Bits
Disposal Method 3 Bits (Recommendations: 0)
User Input Flag 1 Bit (Recommendations: 0)
Transparent Color Flag 1 Bit
Delay Time: unsigned 2 bytes
Transparent Color Index: 1 byte
Block Terminator: 1 byte
//////////Animated Control End

* Comment Extension.
Extension Introducer: 1 byte => 0x21
Comment Label: 1 byte => 0xFE
Comment Data (Data Sub-blocks): using the 7-bit ASCII character set
(each of size at most 255 bytes and at least 1 byte)
do not interfere with Control or Data blocks
Block Terminator: 1 byte => 0x00
* Plain Text Extension (Skip)
* Application Extension (Skip)
* Trailer: 1 byte => 0x3B

===========================

Tags: , ,

Google开始应用图像辨认文字的专利技术

Posted in Google与Idea on January 8th, 2008 by Adam

今天从informationweek看到Google已经开始将图像辨认文字的专利技术应用到Google Map中的街道预览(Street View)和图书搜索(Book Search)中。通过这项从图像中辨认出文字的专利技术,Google可以更方便的从图片、视频中提取相关文字信息,以求更快、更准确的搜索出相关内容的图像、视频或其他多媒体内容。可以说这标志着搜索读图时代的到来。该项专利申请是早在2007年6月就由Google向世界知识产权组织提出申请。

看看自己做的东西,还在使用CAPTCHAS(因防垃圾信息而设置的图片验证功能,要求用户提交信息的时候,填写程序生成的图片中的文字符号)来防止SPAM垃圾内容的提交。这让我不得不担心,SPAMMer获得这项技术后的情景。随着电脑技术的不断发展,用程序来模拟internet用户的行为越来越难以判断和被检测。如何判断网络上的动作是由一个真实的人所发出的行为成为从事网站开发所要仔细考虑的一个问题。而与反垃圾信息(Anti-Spam)的斗争也将任重道远。

Tags: , ,
RSS Feed