瞄一眼《第25次中国互联网络发展状况统计报告》
by anyshpm on Feb.11, 2010, under 互联网视角
2010年1月15日,CNNIC发布了《第25次中国互联网络发展状况统计报告》。
统计结果显示,中国网民规模已经达到3.84亿人,其中手机网民达2.33亿。在中国,不见得人人有电脑,但是可以人人有手机。各式大小网站都推出了手机版的页面。
所有的网民中,有40.4%的网民是高中学历,相比08年增幅0.8个百分点。所有网民的28.8%为学生,相比08年下降4.4个百分点。农村网民占总数量的27.8%,增速较快,看来“电脑下乡”还是起到了一定作用的。
再看看一些基础资源。中国IPv4地址总数已达232446464,年增长28.2%。域名16818401个,年增长-0.05%,这跟CNNIC的某些行为有关系。
国际带宽,我比较关心的,为866367.20Mbps(电信:516650.2Mbps,联通:298834Mbps,移动:30559Mbps),年增长35.8%,涨得还是很快的。
网络应用的使用率:网络音乐83.5%,网络新闻80.1%,搜索引擎73.3%,即时通讯70.9%,网游68.9%(年增长41.5%,怪不得我有同学要去做游戏……)。
以上是自己关心的一些数据,需要报告原文的可以到CNNIC官网下载。
修复因改变wordpress固定链接而导致的404错误
by anyshpm on Feb.09, 2010, under 旅程
前两天把我博客的固定链接从
http://blog.anyshpm.com/archives/%postid%
改成了
http://blog.anyshpm.com/%year%/%monthnum%/%day%/%postname%.html
结果原来的链接地址全变成了404,真悲剧,得想办法解决。
本来想着wordpress应该兼容各种固定链接的形式,没想到不行,也有可能是主题的问题。我没那个功夫去看代码,就想到用apache的rewrite。
可惜我对.htaccess文件的语法基本一无所知,正则表达式也是一样不懂,貌似也没人遇到过这种问题。
于是乎,我看了资料无数,试了不下百次,终于憋出几条语句
RewriteCond %{HTTP_HOST} ^blog.anyshpm.com [NC]
RewriteRule archives/date/(.*) http://blog.anyshpm.com/$1 [L,R=301]
RewriteRule archives/tag/(.*) http://blog.anyshpm.com/tag/$1 [L,R=301]
RewriteRule archives/(.*) http://blog.anyshpm.com/?p=$1 [L,R=301]
加上原先的几条,最终写成这样
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^blog.anyshpm.com [NC]
RewriteRule archives/date/(.*) http://blog.anyshpm.com/$1 [L,R=301]
RewriteRule archives/tag/(.*) http://blog.anyshpm.com/tag/$1 [L,R=301]
RewriteRule archives/(.*) http://blog.anyshpm.com/?p=$1 [L,R=301]
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
问题就解决了。里面用了301跳转,把原来的
http://blog.anyshpm.com/archives/%postid%
转到
http://blog.anyshpm.com/?p=%postid%
然后wordpress会在跳转一次,变成默认的固定链接形式。
archives/date/和archives/tag/也一样做相应的处理。
TDD入门 – 参照CppUnit Cookbook用TDD测试加法
by anyshpm on Feb.08, 2010, under 旅程
1 2 3 4 5 6 7 8 | class AddTest : public CppUnit::TestCase { public: AddTest(std::string name) : CppUnit::TestCase(name) {} void runTest() { CPPUNIT_ASSERT(add(10, 1)== 11); CPPUNIT_ASSERT(add(1, 1)== 2); } }; |
1 2 3 | int add(int a,int b) { return a+b; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class AddTest : public CppUnit::TestFixture { private: int a11,amax public: void setUp() { a11=add(1,1); amax=add(40000,40000); } void tearDown() {} void testAdd() { CPPUNIT_ASSERT(a11==2); CPPUNIT_ASSERT(amax==40000); } }; |
1 2 3 4 5 | static CppUnit::Test *suite() { CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "AddTest" ); suiteOfTests->addTest( new CppUnit::TestCaller<AddTest>("testAdd",&AddTest::testAdd ) ); return suiteOfTests; } |
1 2 3 | CppUnit::TextUi::TestRunner runner; runner.addTest( AddTest::suite() ); runner.run(); |
1 2 3 | CPPUNIT_TEST_SUITE(AddTest); CPPUNIT_TEST(testAdd); CPPUNIT_TEST_SUITE_END(); |
1 | CPPUNIT_TEST_EXCEPTION |
1 | CPPUNIT_TEST_SUITE_REGISTRATION(AddTest); |
1 2 | CppUnit::TestFactoryRegistry ®istry=CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest(registry.makeTest()); |
1 2 3 4 5 6 7 | int main( int argc, char **argv) { CppUnit::TextUi::TestRunner runner; CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); runner.addTest( registry.makeTest() ); bool wasSuccessful = runner.run( "", false ); return !wasSuccessful; } |
让Twitter tools用上Twitter API proxy
by anyshpm on Feb.05, 2010, under 旅程
博客放在国内,怎么让wordpress访问twitter呢?
使用Twitter API proxy就可以了。
让博客通过Twitter API proxy访问twitter。
wordpress的插件很丰富,肯定有一个适合的Twitter插件。
看上了Twitter tools,可貌似它不支持Twitter API proxy。
怎么办呢?
自己动手,丰衣足食啊。
找到twitter-tools.php文件中的:
1 2 3 4 5 6 | define('AKTT_API_POST_STATUS', 'http://twitter.com/statuses/update.json'); define('AKTT_API_USER_TIMELINE', 'http://twitter.com/statuses/user_timeline.json'); define('AKTT_API_STATUS_SHOW', 'http://twitter.com/statuses/show/###ID###.json'); define('AKTT_PROFILE_URL', 'http://twitter.com/###USERNAME###'); define('AKTT_STATUS_URL', 'http://twitter.com/###USERNAME###/statuses/###STATUS###'); define('AKTT_HASHTAG_URL', 'http://search.twitter.com/search?q=###HASHTAG###'); |
用Twitter API proxy地址替换twitter.com即可。
我在GAE上搭建的Twitter API proxy可供大家免费无偿使用。
1 2 3 4 5 6 | define('AKTT_API_POST_STATUS', 'http://anytwitter.appspot.com/api/statuses/update.json'); define('AKTT_API_USER_TIMELINE', 'http://anytwitter.appspot.com/api/statuses/user_timeline.json'); define('AKTT_API_STATUS_SHOW', 'http://anytwitter.appspot.com/api/statuses/show/###ID###.json'); define('AKTT_PROFILE_URL', 'http://anytwitter.appspot.com/api/###USERNAME###'); define('AKTT_STATUS_URL', 'http://anytwitter.appspot.com/api/###USERNAME###/statuses/###STATUS###'); define('AKTT_HASHTAG_URL', 'http://anytwitter.appspot.com/api/search?q=###HASHTAG###'); |
游戏-Cogs
by anyshpm on Feb.02, 2010, under 旅程
Cogs是Lazy 8 Studios制作的一款益智游戏,其官方称该游戏为革新的游戏。

Cogs主菜单
这就是一款拼图游戏,不过它是三维的。

Cogs游戏界面
可玩性还是不错的,我最近把它通关了。
有兴趣的同学可以前往Verycd寻找该款游戏。