Wild China

推荐一部影片《Wild China》,中文名:《美丽中国》,由BBC和CCTV合作拍摄。不同于我们常看到的官方版本的、从大处着眼的纪录片,本片从细微处出发,用细腻的画面(高清)和优美的音乐描绘出一个普通人所熟悉的人与自然间的和谐社会…

http://www.bbc.co.uk/sn/tvradio/programmes/wildchina/

http://www.imdb.com/title/tt0884762/

[ad]

西单女孩

89年出生的她
来北京唱歌已经有四年的时间
上天给了她一副好嗓子
但也给了她一个不幸的家庭
让她经历了不同寻常的心酸

http://tinyurl.com/yz9e49h
http://tinyurl.com/czzbfz

娱乐一下

一个搞笑的小孩,到处都是国庆报道,看看下面的视频,放松一下

[ad]

使用PHProxy访问受限网站

PHProxy(http://sourceforge.net/projects/poxy/),是一款PHP代理程序,它的好处是:让你在受限网络环境下,访问被禁止的网站,它的典型使用情况如下:

  • 如果你的公司禁止员工在上班时间上一些SNS、财经网站等,通过这个程序,可以让你绕过限制
  • 如果你想访问墙外的网站,比如Twitter、Facebook等一些人不想让你看的网站,请用PHProxy(这个是本文存在的目的)

当然不是每个人都可以使用它的,前提是:

  • 你必须有自己的web站点
  • 你的空间提供商允许你做proxy服务,坏消息是大部分空间提供商都禁止用户安装代理程序,比如我的空间商,明确规定:

Anonymous Proxies. HostMonster.Com does not allow the use of anonymous proxy scripts on its servers. They can be very abusive to the server resources, affecting all users on that server.

  • 如果你想访问墙外的网站,即使你符合上面两点也是不行的,你的网站必须位于墙外,且你必须修改一下这个程序的代码,请看下面的介绍:

安装PHProxy后,我发现,用它来访问普通网站,是没有问题的,你无需修改它的代码,但是如果你用来访问被GFW墙掉的网站,就不行了。比如:http://www.twitter.com

为什么呢?因为PHProxy首先会将你访问的网站URL,缺省进行一次Base64编码,所以twitter的URL就变成了aHR0cDovL3d3dy50d2l0dGVyLmNvbQ==,然后才进行一次URLEncode编码,变成了aHR0cDovL3d3dy50d2l0dGVyLmNvbQ%3D%3D,而这个字符串大概已经上了GFW的黑名单,不信的话,你用Google搜索下:aHR0cDovL3d3dy50d2l0dGVyLmNvbQ%3D%3D,你的浏览器立刻被重置。

知道原因就简单了,我们只要修改PHProxy,在URL->Base64 Encoder->URL Encoder这个过程后,再加上一道自己定义的编码即可,比如,你把每个字符都加1,解码的时候,再反过来做即可。GFW只会把这些知名站点的URL的用缺省编码加入黑名单,不可能把你新方法加工后的字符串也加入黑名单,因为太多了。

下面做个实际的例子,比如我们可以在编码URL后,将前2位调换到尾部,解码的时候做相反的操作:

else if ($_flags['base64_encode'])
{
    function encode_url($url)
    {
        $tmp = rawurlencode(base64_encode($url));   
        $head = substr($tmp, 0, 2);
        $tail = substr($tmp, 2);
        return $tail.$head;

        // return rawurlencode(base64_encode($url));    
    }
    function decode_url($url)
    {
        $head = substr($url, -2);
        $tail = substr($url, 0, strlen($url) -2);
        $url = $head.$tail;
       
        return str_replace(array(‘&’, ‘&’), ‘&’, base64_decode(rawurldecode($url)));
    }
}

上面的代码,我已经验证,可以逃过GFW的封锁。你可以用你自己的喜欢的方式,替换绿色的部分。

注:PHProxy还可以使用ROT13编码,但同样也被屏蔽了,请做同样的Hack。

[ad]

Benchmarking Metrics for MySQL Data Purge

MySQL是个非常优秀的免费数据库,下面是我周末做Data Purge的部分记录,可以用做将来的参考之用:

硬件:AMD Opteron 265 1.8G(Cache 1M), RAM:1G, HD: 350G,算是配置比较差的一台服务器。请注意,下面所提到的数据和您的服务器性能有很大的关系。

// Delete Data
2009-09-03 19:45:45 Start…
Row Count: 46500394(46M)
DELETE FROM atedata WHERE DATE < ’2009-06-01 00:00:00′
Row Count: 22699749(22M)
2009-09-03 21:18:06 End…

从上面可以看出,删除数据是比较慢的操作,46M条的数据,删除到22M条,总共用了大概93分钟,大概255,921rows/min。删除操作所需时间主要和将要删除的数据量是成正比的,删除的记录数越多,所用的时间也越多。

// Optimize Table
2009-09-04 21:33:54 Start…
Row Count: 23051455(23M) – 7.1GiB
optimize table atedata
Row Count: 23051455(23M) – 3.4GiB
2009-09-04 22:15:37 End…

对于数据量比较大的表,比如超过1G,如果只是简单的用DELETE删除了数据,这些数据所占据的磁盘空间并没有被释放,在MySQL里我们称之为:Overhead。只有对表做了OPTIMIZE操作,才能真正的释放它。

从上面的数据可以看出,优化前,表大小是7.1G,优化后表大小为3.4G,表的记录数没有变化,用时42分钟,平均88MiB每分钟。该操作耗时大致和(Table Size – Overhead)的差成正比。对于那种比较大的表,千万不要删除了几百条记录就做Optimize操作,因为它太耗费时间了,我们可以累积到一定数量再做。

Optimize命令执行后,MySQL会生产一个临时的.TMD文件,MySQL的状态显示Repair by sorting,它其实就是优化后的表。这个过程很漫长,做完后,还有一步是重建索引,MySQL状态显示Repair with Keycache,结束的时候会有个.TMM的临时文件生成,它可能就是.MYI文件的拷贝,不过官方文档没有说明,只是猜测。

在创建索引文件的过程中(Repair with Keycache),它的耗时和表的索引多少有很大的关系,我没有验证,但我们可以猜测:索引越多,这个过程就越长

由于在表很大的情况下,做类似DELETE、OPTIMIZE、ALTER等操作,都是非常的耗时间,所以我们在设计系统的时候就需要提前考虑到:

  1. 保存数据的时间长度
  2. 做Data Purge的周期、方法策略
  3. 数据备份的策略
  4. Data Purge的过程中,系统该如何应对(以上操作都会造成MySQL被锁定,数据库无法使用
  5. 等等

如果数据量不大的话,另当别论。

[ad]

集成Twitter到你的网站

如果你常用Twitter,想把tweets显示在你的网站或者Blog上,该怎么办?最简单的方式是用Twitter官方的一个JavaScript,可由于功夫网的缘故,在中国的用户无法使用它,如果你有自己的网站或者Blog,且位于墙外,下面的一段PHP代码可以达到你的目的:

// 读取Twitter的函数
function twitter_process($url)
{
    $ch = curl_init($url);

    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_USERAGENT, 'super_man');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

    $response = curl_exec($ch);
    $response_info = curl_getinfo($ch);
    curl_close($ch);

    switch(intval($response_info['http_code']))
    {
        case 200:
        $json = json_decode($response);
        if ($json)
        return $json;
            return $response;
        case 401:
        default:
        // NOOP
    }
}

// 显示tweets在你的网站
$o = twitter_process("http://twitter.com/statuses/user_timeline/charry.json?count=5");

for ($i = 0; $i &lt; count($o); $i++)
{
    $item = $o[$i];

    echo "<li>";
    echo $item->{‘text’};
    echo " – ".$item->{‘created_at’};
    echo "</li>";
}

[ad]

身为屠刀,我如何放下屠刀

最近在看《家园》,一部描述地球,这个人类赖以生存的蓝色星球的纪录片。片中描述了人类文明的诞生与发展,导演用华丽的画面来控诉近几十年来人类对环境的破坏,而这些几乎不可逆转的破坏,使得我们的家园危机重重。

这是一部你值得关注的影片,据说北京最近有免费的公映,有机会的朋友可以去观摩一下,顺便给自己敲一个警钟。

有网友写影评如是:身为屠刀,我如何放下屠刀,请注意第一行字,别误解了作者。

另外:

我注意到一个和本片主题不太相关的内容:美国有农民300万,而生产的粮食可以养活20亿。不知道是否是真的如此,假如是:我们政府经常宣传的,7%的土地养活了22%的人口,实在是不值得一提。况且Google一下,似乎很多人对这个表述有所怀疑。

[ad]

Create your own public profile on Google

My Profile: http://www.google.com/profiles/charry.tar.gz

image

Bad news is: I can’t access this special link with Chrome, I got the following:

image 

[ad]

公务猿呼啸下江南

(因此贴在facebook上被同事,也是我的老木反的老木反的老木反看见,MSG我,不知道我发的是什么,请我翻译下,遂追加英文翻译,由于帖子涉及很多背景知识,很难聊聊数句说个明白,不求信达雅,只是一个注解,公务猿的故事,老外岂能弄的明白)
«
周末无事,遂前往苏州博物馆游玩避暑,刚出博物馆门口,只见一行4辆车呼啸而来,此呼啸并非比喻等其他修饰手法,乃写实的陈述。车队由一辆警车开路,并且鸣着笛。不用说,是他们来了,除此,我想没有人敢在景点前的石板路上开车开的那么飞快,否则撞到人就会惹来一身麻烦。
At this weekend, I hang around at Suzhou Museum(located at the downtown of Suzhou City, near by the Zhuozheng Garden). When I tried to go back home, 4 vehicle pulled over by me, actually they were speeding at the footpath. it’s not a highway, but they drove at the speed of 40km/h roughly.The first one is a police car, horning(the police car is warning other vehicle to get out the way all the way).
« 
If you’re a local ppl, you know what happened, apparently they’re gov’t officers and they’re traveling in the Suzhou Garden.
上图:四辆车的车队(4 Vehicle pulled over at the entrance to the Garden)
«
« 
上图:第一辆警车(The first one is a police car)
«
«

上图:第二辆车(the 2nd vehicle)
«
请注意,此车的车牌为苏A0002,有这么拉风的车牌,如果开的不拉风,还真对不起这个号码。我一直以为靠前的车牌都是高级轿车,原来也有客车。
Take a look at the license plate: A0002, in China, only the gov’t can use this special number. that’s why I said they’re the gov’t officers. and it’s a political corruption. they use the taxpayer’s money for their own purpose.
上图:第一辆客车的侧照(The left side of the 1st tour bus)
«
«
上图:第一辆的尾照(The rear of the 1st tour bus)
«
«
上图:第二辆车的前照(the front of the 2nd tour bus)
«
上图是比较有意思的,请仔细看,你找到了它的车牌号了吗?原来被一个纸板样的东西给挡了起来,这么神秘的车,让人不免联想,难道这个就是传说中的微服私访?请有车的朋友千万不要模仿,否则交警会让你好看。
Where is the license plate? hmmm, interesting:), it’s covered by something, how come they did this way? I guess they don’t want the public know who they are. because it’s a famous scenic spot in China, not a office. they’re not supposed to be there.
«
这辆车的后面的牌照也被挡住了,如下图:
They also cover the rear license plate.
上图:第二辆车的后照(The rear of the 2nd tour bus)
«
«
上图:第三辆车前照(The front of 3rd tour bus)
«
«
上图:第三辆的侧照(The left side of 3rd tour bus)
«
«
上图:第三辆车的后照(The rear of 3rd tour bus)
«
我很纳闷,为什么这辆车的前面的车牌没有被挡住,而后面的却被遮挡住了?公务员的思维方式与常人不同,我等想破脑袋也想不通。
I don’t get why they cover the front license plate on purpose, leaving rear license plate uncovered, they forgot it?
«
上图只是本人偶遇,随便拍拍,分享给大家。

Outlook Tips For You

Rule is powerful tool to help you organize your email in Outlook, but sometimes, it still doesn’t meet your expectation, so anything else you could do? just wait Microsoft to add more features in next release of Outlook? I guess this isn’t what you expected. If you’re familiar with VBA, use Macro instead of Rule, because of the flexibility of VBA, you can hack it and custom it as you wish, I believe you’ll find out more advanced features of Outlook, even if you’re a newbie of VBA, it’s okay, VBA is not designed for geeks in the first place, you could get how to use it in several minutes, below is an example:

Sub BackupSentMail()
    Set OutApp = CreateObject("Outlook.Application")
    Set NmSpace = OutApp.GetNamespace("MAPI")
    Set BackupSent = NmSpace.Folders("Sent").Folders("ALL")
    Set DefaultSent = NmSpace.GetDefaultFolder(5)
    For intX = DefaultSent.Items.Count To 1 Step -1
        Set objMessage = DefaultSent.Items.Item(intX)
        objMessage.Move BackupSent
    Next

    Set OutApp = Nothing
    Set NmSpace = Nothing
    Set BackupSent = Nothing
    Set DefaultSent = Nothing
End Sub

Sub CustomMailMessageRule(Item As Outlook.MailItem)
    Set OutApp = CreateObject("Outlook.Application")
    Set NmSpace = OutApp.GetNamespace("MAPI")
    Set folderOnlyToMe = NmSpace.Folders("Main").Folders("OnlyToMe")
    Set folderTrash = NmSpace.Folders("Main").Folders("Trash")
    Set folderSWS = NmSpace.Folders("SWS").Folders("ALL")
    Set folderIntegration = NmSpace.Folders("Integration").Folders("ALL")
    Set folderIntegrationDev = NmSpace.Folders("Integration").Folders("Dev.")
    Set folderIncoming = NmSpace.Folders("Main").Folders("Incoming")
    ”””””””””””””””’
    ‘ Set Flag
    ”””””””””””””””’
    ‘ Sent by bosses
    If Item.SenderName = "Gates, Bill" Or _
        Item.SenderName = "Jackson, Michael" Or _
        Item.SenderName = "Jong, John" Then
        Item.FlagStatus = olFlagMarked
        Item.FlagIcon = olOrangeFlagIcon
        Item.Save
        MsgBox Item.Subject, vbInformation, "Here comes a new msg"
    End If
    ”””””””””””””””’
    ‘ Trash Filter
    ”””””””””””””””’
    If Item.SenderEmailAddress = "hqadmin@antispam.charry.org" Or _
        Item.SenderEmailAddress = "OPN_validation_system@antispam.charry.org" Or _
        Item.SenderEmailAddress = "MES_AUTO_LOT_HOLD@antispam.charry.org" Or _
        Item.SenderEmailAddress = "MTEPP_Detection_System@antispam.charry.org" Or _
        Item.SenderEmailAddress = "szcpp113@antispam.charry.org" Or _
        Item.SenderEmailAddress = "szcpp111@antispam.charry.org" Or _
        Item.SenderEmailAddress = "szcpp233@antispam.charry.org" Or _
        Item.SenderEmailAddress = "szcpp231@antispam.charry.org" Or _
        Item.SenderEmailAddress = "yammer@yammer.com" Or _
        Item.SenderEmailAddress = "Unfuse_units_detection_system@antispam.charry.org" Then
        Item.Move folderTrash
        GoTo CleanUp
    End If
    If Item.To = "fbdaemon@szasptgh101.amd.com" Then
        Item.Move folderTrash
        GoTo CleanUp
    End If
    ‘ SVN_INTDEV
    If InStr(Item.SenderEmailAddress, "@soulcutter.amd.com") > 0 Then
        Item.Move folderTrash
        GoTo CleanUp
    End If
    ‘ EDA Daily Report
    If Item.SenderEmailAddress = "The_Software_Services_Team@antispam.charry.org" Then
        Item.Move NmSpace.Folders("Misc").Folders("EDA Report")
        GoTo CleanUp
    End If
    ‘ Title Filter
    If InStr(Item.Subject, "ex-factory utilization report") > 0 Then
        Item.Move folderTrash
        GoTo CleanUp
    End If
    ”””””””””””””””’
    ‘ Normal Filter
    ”””””””””””””””’
    ‘ to me
    MyPos = InStr(Item.To, "Charry")
    If MyPos > 0 Then
        Item.Move folderOnlyToMe
        GoTo CleanUp
    End If
    ‘ cc me
    MyPos = InStr(Item.CC, "Charry")
    If MyPos > 0 Then
        Item.Move folderOnlyToMe
        GoTo CleanUp
    End If
    ‘ to dl.suz_sws
    MyPos = InStr(Item.To, "dl.suz_sws")
    If MyPos > 0 Then
        Item.Move folderSWS
        GoTo CleanUp
    End If
    ‘ cc dl.suz_sws
    MyPos = InStr(Item.CC, "dl.suz_sws")
    If MyPos > 0 Then
        Item.Move folderSWS
        GoTo CleanUp
    End If
    ‘ GMail
    If Item.To = "hi@antispamp.charry.org" Or Item.To = "charrywong@ggggggmail.com" Then
        Item.Move NmSpace.Folders("Misc").Folders("charry.org")
        GoTo CleanUp
    End If
    Item.Move folderIncoming
CleanUp:
    Set OutApp = Nothing
    Set NmSpace = Nothing
    Set folderOnlyToMe = Nothing
    Set folderTrash = Nothing
    Set folderSWS = Nothing
    Set folderIntegration = Nothing
End Sub

Sub CustomMeetingRequestRule(Item As Outlook.MeetingItem)
   MsgBox "Meeting request arrived: " & Item.Subject
End Sub

How do we activate the code above? first of all, you should create a macro in Visual Basic Editor(press ALT+F11 to call this editor), afterwards, paste the code above to the editor and save, then you need to create a rule and make the rule applies to all emails(there’s a time span option in wizard, you could set the new rule for all email received before year 2099), then you’ll see an option to let you run a script when you received an email, the following steps are straightforward.

The code snippet I posted here is just a reference, Google VBA+Outlook, you will get more examples. Focus on the email itself rather than organizing email. See, you’re just one step away from an effective and efficient working way.

[ad]

Page 5 of 21« First...34567...1020...Last »

Switch to our mobile site