( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484224{main}( ).../index.php:0
20.0000484576require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.10864342072require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.10974371392include( '/var/www/html/wp-content/themes/twentyfifteen/archive.php ).../template-loader.php:125
50.10974371392get_header( $name = ???, $args = ??? ).../archive.php:19
60.10974371608locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.10974371704load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.10974372248require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.10994379656wp_head( ).../header.php:18
100.10994379656do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.10994379872WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.10994379872WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.11014501640wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.11014501640do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.11014501856WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.11014501856WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.11024509376twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.11034510896wp_style_add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.php:440
190.11034510896WP_Styles->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../functions.wp-styles.php:245
200.11034510896WP_Dependencies->add_data( $handle = 'twentyfifteen-ie', $key = 'conditional', $value = 'lt IE 9' ).../class-wp-styles.php:385
210.11034510896_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.11034511216wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.11044511968trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

( ! ) Deprecated: Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers. in /var/www/html/wp-includes/functions.php on line 6131
Call Stack
#TimeMemoryFunctionLocation
10.0000484224{main}( ).../index.php:0
20.0000484576require( '/var/www/html/wp-blog-header.php ).../index.php:17
30.10864342072require_once( '/var/www/html/wp-includes/template-loader.php ).../wp-blog-header.php:19
40.10974371392include( '/var/www/html/wp-content/themes/twentyfifteen/archive.php ).../template-loader.php:125
50.10974371392get_header( $name = ???, $args = ??? ).../archive.php:19
60.10974371608locate_template( $template_names = [0 => 'header.php'], $load = TRUE, $load_once = TRUE, $args = [] ).../general-template.php:48
70.10974371704load_template( $_template_file = '/var/www/html/wp-content/themes/twentyfifteen/header.php', $load_once = TRUE, $args = [] ).../template.php:749
80.10974372248require_once( '/var/www/html/wp-content/themes/twentyfifteen/header.php ).../template.php:814
90.10994379656wp_head( ).../header.php:18
100.10994379656do_action( $hook_name = 'wp_head' ).../general-template.php:3197
110.10994379872WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
120.10994379872WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
130.11014501640wp_enqueue_scripts( '' ).../class-wp-hook.php:341
140.11014501640do_action( $hook_name = 'wp_enqueue_scripts' ).../script-loader.php:2311
150.11014501856WP_Hook->do_action( $args = [0 => ''] ).../plugin.php:522
160.11014501856WP_Hook->apply_filters( $value = '', $args = [0 => ''] ).../class-wp-hook.php:365
170.11024509376twentyfifteen_scripts( '' ).../class-wp-hook.php:341
180.13814513072wp_style_add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.php:444
190.13814513072WP_Styles->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../functions.wp-styles.php:245
200.13814513072WP_Dependencies->add_data( $handle = 'twentyfifteen-ie7', $key = 'conditional', $value = 'lt IE 8' ).../class-wp-styles.php:385
210.13814513072_deprecated_argument( $function_name = 'WP_Dependencies->add_data()', $version = '6.9.0', $message = 'IE conditional comments are ignored by all supported browsers.' ).../class-wp-dependencies.php:317
220.13814513392wp_trigger_error( $function_name = '', $message = 'Function WP_Dependencies->add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:5925
230.13824513616trigger_error( $message = 'Function WP_Dependencies-&gt;add_data() was called with an argument that is <strong>deprecated</strong> since version 6.9.0! IE conditional comments are ignored by all supported browsers.', $error_level = 16384 ).../functions.php:6131

配置mongodb分片群集(sharding cluster)

 

Sharding cluster介绍

这是一种可以水平扩展的模式,在数据量很大时特给力,实际大规模应用一般会采用这种架构去构建monodb系统。

要构建一个 MongoDB Sharding Cluster,需要三种角色:

Shard Server: mongod 实例,用于存储实际的数据块,实际生产环境中一个shard server角色可由几台机器组个一个relica set承担,防止主机单点故障

Config Server: mongod 实例,存储了整个 Cluster Metadata,其中包括 chunk 信息。

Route Server: mongos 实例,前端路由,客户端由此接入,且让整个集群看上去像单一数据库,前端应用可以透明使用。

Sharding架构图:

本例实际环境架构

本例架构示例图:

  1. 分别在3台机器运行一个mongod实例(称为mongod shard11,mongod shard12,mongod shard13)组织replica set1,作为cluster的shard1
  2. 分别在3台机器运行一个mongod实例(称为mongod shard21,mongod shard22,mongod shard23)组织replica set2,作为cluster的shard2
  3. 每台机器运行一个mongod实例,作为3个config server
  4. 每台机器运行一个mongs进程,用于客户端连接

 

主机 IP 端口信息
Server1 10.1.1.1 mongod shard11:27017
mongod shard12:27018
mongod config1:20000
mongs1:30000
Server2 10.1.1.2 mongod shard12:27017
mongod shard22:27018
mongod config2:20000
mongs2:30000
Server3 10.1.1.3 mongod shard13:27017
mongod shard23:27018
mongod config3:20000
mongs3:30000

 

软件准备

软件准备
1. 创建用户
groupadd -g 20001 mongodb
useradd -u 20001 -g mongodb mongodb
passwd mongodb

2. 安装monodb软件
su – mongodb
tar zxvf mongodb-linux-x86_64-1.7.2.tar
安装好后,目录结构如下:
$ tree mongodb-linux-x86_64-1.7.2
mongodb-linux-x86_64-1.7.2
|– GNU-AGPL-3.0
|– README
|– THIRD-PARTY-NOTICES
`– bin
|– bsondump
|– mongo
|– mongod
|– mongodump
|– mongoexport
|– mongofiles
|– mongoimport
|– mongorestore
|– mongos
|– mongosniff
`– mongostat
1 directory, 14 files

3. 创建数据目录
根据本例sharding架构图所示,在各台sever上创建shard数据文件目录
Server1:
su – monodb
cd /home/monodb
mkdir -p data/shard11
mkdir -p data/shard21
Server2:
su – monodb
cd /home/monodb
mkdir -p data/shard11
mkdir -p data/shard22
Server3:
su – monodb
cd /home/monodb
mkdir -p data/shard13
mkdir -p data/shard23

配置relica sets

1. 配置shard1所用到的replica sets:
Server1:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard1 –port 27017 –dbpath /home/mongodb/data/shard11 –oplogSize 100 –logpath /home/mongodb/data/shard11.log –logappend –fork

Server2:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard1 –port 27017 –dbpath /home/mongodb/data/shard12 –oplogSize 100 –logpath /home/mongodb/data/shard12.log –logappend –fork

Server3:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard1 –port 27017 –dbpath /home/mongodb/data/shard13 –oplogSize 100 –logpath /home/mongodb/data/shard13.log –logappend –fork

初始化replica set
用mongo连接其中一个mongod,执行:
> config = {_id: ’shard1′, members: [
{_id: 0, host: ‘10.1.1.1:27017’},
{_id: 1, host: ‘10.1.1.2:27017’},
{_id: 2, host: ‘10.1.1.3:27017’}]
}

> rs.initiate(config);

同样方法,配置shard2用到的replica sets:
server1:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/mongodb/data/shard21 –oplogSize 100 –logpath /home/mongodb/data/shard21.log –logappend –fork

server2:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/mongodb/data/shard22 –oplogSize 100 –logpath /home/mongodb/data/shard22.log –logappend –fork

server3:
cd /home/mongodb/mongodb-linux-x86_64-1.7.2/bin
./mongod –shardsvr –replSet shard2 –port 27018 –dbpath /home/mongodb/data/shard23 –oplogSize 100 –logpath /home/mongodb/data/shard23.log –logappend –fork

初始化replica set
用mongo连接其中一个mongod,执行:
> config = {_id: ’shard2′, members: [
{_id: 0, host: ‘10.1.1.1:27018’},
{_id: 1, host: ‘10.1.1.2:27018’},
{_id: 2, host: ‘10.1.1.3:27018’}]
}

> rs.initiate(config);

到此就配置好了二个replica sets,也就是准备好了二个shards

配置三台config server

Server1:
mkdir -p /home/mongodb/data/config
./mongod –configsvr –dbpath /home/mongodb/data/config –port 20000 –logpath /home/mongodb/data/config.log –logappend –fork   #config server也需要dbpath

Server2:
mkdir -p /home/mongodb/data/config
./mongod –configsvr –dbpath /home/mongodb/data/config –port 20000 –logpath /home/mongodb/data/config.log –logappend –fork

Server3:
mkdir -p /home/mongodb/data/config
./mongod –configsvr –dbpath /home/mongodb/data/config –port 20000 –logpath /home/mongodb/data/config.log –logappend –fork

配置mongs

在server1,server2,server3上分别执行:
./mongos –configdb 10.1.1.1:20000,10.1.1.2:20000,10.1.1.3:20000 –port 30000 –chunkSize 5 –logpath /home/mongodb/data/mongos.log –logappend –fork
#mongs不需要dbpath

Configuring the Shard Cluster

连接到其中一个mongos进程,并切换到admin数据库做以下配置
1. 连接到mongs,并切换到admin
./mongo 10.1.1.1:30000/admin
>db
Admin
2. 加入shards
如里shard是单台服务器,用>db.runCommand( { addshard : “<serverhostname>[:<port>]” } )这样的命令加入,如果shard是replica sets,用replicaSetName/<serverhostname>[:port][,serverhostname2[:port],…]这样的格式表示,例如本例执行:
>db.runCommand( { addshard : “shard1/10.1.1.1:27017,10.1.1.2:27017,10.1.1.3:27017″,name:”s1″,maxsize:20480} );
>db.runCommand( { addshard : “shard2/10.1.1.1:27018,10.1.1.2:27018,10.1.1.3:27018″,name:”s2″,maxsize:20480} );
注意:在添加第二个shard时,出现error:test database 已经存在的错误,这里用mongo命令连接到第二个replica set,用db.dropDatabase()命令把test数据库给删除然后就可加入

3. 可选参数
Name:用于指定每个shard的名字,不指定的话系统将自动分配
maxSize:指定各个shard可使用的最大磁盘空间,单位megabytes

4. Listing shards
>db.runCommand( { listshards : 1 } )
如果列出了以上二个你加的shards,表示shards已经配置成功

5. 激活数据库分片
命令:
> db.runCommand( { enablesharding : “<dbname>” } );
通过执行以上命令,可以让数据库跨shard,如果不执行这步,数据库只会存放在一个shard,一旦激活数据库分片,数据库中不同的collection将被存放在不同的shard上,但一个collection仍旧存放在同一个shard上,要使单个collection也分片,还需单独对collection作些操作

Collecton分片

要使单个collection也分片存储,需要给collection指定一个分片key,通过以下命令操作:
> db.runCommand( { shardcollection : “<namespace>”,key : <shardkeypatternobject> });
注:
a. 分片的collection系统会自动创建一个索引(也可用户提前创建好)
b. 分片的collection只能有一个在分片key上的唯一索引,其它唯一索引不被允许
One note: a sharded collection can have only one unique index, which must exist on the shard key. No other unique indexes can exist on the collection.

分片collection例子

>db.runCommand( { shardcollection : “test.c1″,key : {id: 1} } )
>for (var i = 1; i <= 200003; i++) db.c1.save({id:i,value1:”1234567890″,value2:”1234567890″,value3:”1234567890″,value4:”1234567890″});
> db.c1.stats()
{
“sharded” : true,
“ns” : “test.c1″,
“count” : 200003,
“size” : 25600384,
“avgObjSize” : 128,
“storageSize” : 44509696,
“nindexes” : 2,
“nchunks” : 15,
“shards” : {
“s1″ : {
“ns” : “test.c1″,
“count” : 141941,
“size” : 18168448,
“avgObjSize” : 128,
“storageSize” : 33327616,
“numExtents” : 8,
“nindexes” : 2,
“lastExtentSize” : 12079360,
“paddingFactor” : 1,
“flags” : 1,
“totalIndexSize” : 11157504,
“indexSizes” : {
“_id_” : 5898240,
“id_1″ : 5259264
},
“ok” : 1
},
“s2″ : {
“ns” : “test.c1″,
“count” : 58062,
“size” : 7431936,
“avgObjSize” : 128,
“storageSize” : 11182080,
“numExtents” : 6,
“nindexes” : 2,
“lastExtentSize” : 8388608,
“paddingFactor” : 1,
“flags” : 1,
“totalIndexSize” : 4579328,
“indexSizes” : {
“_id_” : 2416640,
“id_1″ : 2162688
},
“ok” : 1
}
},
“ok” : 1
}

 

调查服务器响应时间的利器 tcprstat

我们在做服务器程序的时候,经常要知道一个请求的响应时间,借以优化或者定位问题。 通常的做法是在代码里面加入日志计算时间,这个方法有问题,时间不准确。因为数据从网卡到应用程序,从应用到网卡的时间没有被计算在内。 而且这个时间随着系统的负载有很大的变化。
那同学说,我wireshark, tcpdump抓包人肉统计不行吗。 可以的,只不过我会很同情你,此举需要耐心且不具可持续性。 所以我们希望有个工具能够最少费力的做这个事情。

这时候来自percona的tcprstat来救助了! 这个工具原本开发用来调查mysqld的性能问题,所以不要奇怪它的默认端口是3306, 但是我们可以用这个工具来调查典型的request->response类型的服务器。

什么是tcprstat:

tcprstat is a free, open-source TCP analysis tool that watches network traffic and computes the delay between requests and responses. From this it derives response-time statistics and prints them out. The output is similar to other Unix -stat tools such as vmstat, iostat, and mpstat. The tool can optionally watch traffic to only a specified port, which makes it practical for timing requests and responses to a single daemon process such as mysqld, httpd, memcached, or any of a variety of other server processes.

文档很详细: 请参考: http://www.percona.com/docs/wiki/tcprstat:start

不愿意编译的同学直接从这里下载64位系统的编译好的二进制:http://github.com/downloads/Lowercases/tcprstat/tcprstat-static.v0.3.1.x86_64

源码编译也挺容易的: 由于它自带libpcap包, 这个包有可能在configure的时候没认识好netlink, 只要把config.h里面的netlink那个define注释掉就好。

编译好了, 典型使用很简单:

# tcprstat -p 3306 -t 1 -n 5
timestamp count max min avg med stddev 95_max 95_avg 95_std 99_max 99_avg 99_std
1283261499 1870 559009 39 883 153 13306 1267 201 150 6792 323 685
1283261500 1865 25704 29 578 142 2755 889 175 107 23630 333 1331
1283261501 1887 26908 33 583 148 2761 714 176 94 23391 339 1340
1283261502 2015 304965 35 624 151 7204 564 171 79 8615 237 507
1283261503 1650 289087 35 462 146 7133 834 184 120 3565 244 358

但是这个tcprstat在bonding的网卡下有点问题:

# /sbin/ifconfig
bond0 Link encap:Ethernet HWaddr A4:BA:DB:28:B5:AB
inet addr:10.232.31.19 Bcast:10.232.31.255 Mask:255.255.255.0
inet6 addr: fe80::a6ba:dbff:fe28:b5ab/64 Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1
RX packets:19451951688 errors:0 dropped:4512 overruns:0 frame:0
TX packets:26522074966 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:6634368171533 (6.0 TiB) TX bytes:32576206882863 (29.6 TiB)

# tcprstat -p 3306 -t 1 -n 5
pcap: SIOCGIFFLAGS: bonding_masters: No such device

解决方案是:

# sudo tcprstat -p 3306 -t 1 -n 0 -l `/sbin/ifconfig | grep ‘addr:[^ ]\+’ -o | cut -f 2 -d : | xargs echo | sed -e ’s/ /,/g’`

在典型满负载的mysql服务器上抓包的开销是:

26163 root 18 0 104m 5304 4696 S 18.3 0.0 49:47.58 tcprstat

用IP方式,而不是网络接口方式搞定。

祝大家玩的开心。

 

HP电脑又黑屏了….今次决定自己整!!!(第一次拆手提电脑)

部hp又黑屏了…唉…第四次黑屏了.之前去电脑城整要260元/次。

第三次黑屏个阵,去咗HP维修点,话我系境外机,无得保修,要换主板1500+250,我马上SAY NO。走人。

 

今次系第四次黑屏了,唔想再去电脑城整,上YOUTUBE一搜,发现咗个好简单嘅方法。

 

我都系第一次拆手提电脑咋,有好多嘢系摸下摸下。。。后面有写要注意D乜。

 

HP黑屏原因我唔讲了。讲起9把火!!自己上网搜。不过,如果你的HP黑屏,10有8,9系呢个问题。

 

第一步:拆机,揾到张显卡。

就系佢,中间下面位置。。

重要工具A:防风打火机。(今日跑了置禾、壹加壹、假日、大信都揾唔到,最后系沙岗墟12蚊买到,沙岗墟很给力啊!)

重要工具B:锡纸。安照显卡蕊片的size,桔穿佢,用处就系集中火力,保险其它元件。

旭手啦,套住佢,用打火机狂烧佢,为咗防止烧坏个蕊片,火力不能集中在同一个位置,要不段左右,上下移动。使蕊片均匀受热。。一般情况下,烧2分钟就可以。每烧30秒,就要用力压下个蕊片(不能用手)。

终于搞掂,下面系解决这个系列手提电脑的一个大BUG。散热片与蕊片竟然有2MM空隙。HP的QA很不给力。。。

 

下面系一个港币1毫子,黄铜合金,当然有纯铜就最好啦。据说葡币的1毫是纯铜的。用沙纸礳平两面。

 

涂上散热圭脂,再黏上个蕊片上面。注意铜片不能太厚,否则CPU就会出现散热问题。

整完。开机!!!!

哈哈。。两日无见嘅XP login窗口。。。

开个监控软件睇睇。温度比之前抵了一些,遟D看下电影测试下,或者上下QQ农场。

第一次拆手提电脑,有2点需要注意:

1,电线要有顺序咁摆好,咪时唔记得边条打边条。

2,个螺丝都系,要分开摆放,好似我咁,按照原来未拆出来个位置,摆一个盘上面,等下装机个阵就唔怕乱啦。

 

终于搞翻好了。哈哈哈。。。

电脑整要260蚊,自己整??

12蚊+3+0.1 = 15.1元。

奸商真多。HP维修点还要1750元。TMD。。。。

 

一进入2011年,我就黑仔昨日,好彩2月开始转运。。希望好运继续来。。哈哈哈。。。

 

新版twitter背后的技术

果要评2010最牛逼的网站改版,除了豆瓣就是Twitter了(开个玩笑)。那天看了新版twitter的介绍视频,相当兴奋,那种感觉就像04年看到gmail。面对未知的新时代,一部分人在畅想,一部分人在抵触,只有小部分人在行动。Twitter很快交出了他们的答卷。

今天看到Twitter官方发表的博文“The Tech Behind the New Twitter.com”,总结了新版twitter背后的技术,值得一读。(下面的内容不是翻译,是我的理解)

API客户端
新版背后的一个重要的架构上的改变是像其它第三方客户端一样,Twitter自己也开始基于API开发,唯一不同是他们可以使用更多资源。同时对访问API做了诸多优化,原文提到的“highly optimized JSON fragment cache”。

评论:这种方式是很多技术团队都想实现的,但碍于原有架构的历史问题,下不了决心彻底改变它。但未来要满足各种终端上各种形式应用的开发需求,这种架构是最灵活的。

The Javascript API
对应后端的API架构,前端自然需要一个很给力的Javascript库实现和后端的数据交互。Twitter内部用到一个库叫@anywhere (http://platform.twitter.com/js-api.html),它提供的功能:
1. 负责和API交换数据。文档里可以看到提供了丰富的接囗。
2. 提供一个客户端的缓存策略(保存在本地的内存和localStorage中)。@ded不久前写的“JavaScript Cache Provider”其实透露了一些细节。
3. 提供一个事件通知机制,当UI发生变化,相应处理组件能够立即响应。

评论:从中可以看到Twitter前端架构的设计思路,跟后端充分对接,建立业务级的通用接囗层,提供通用处理机制解藕,保持代码的模块化。这个路子很对,很值得借鉴。

页面管理
新版的一个项目目标就是让页面导航更简单更快。它是利用URL hash建立一套浏览器端的页面路由系统。这个具体要等到用上新版后看一看。

评论:像GMail那种,用URL hash做页面切换,管理起来还是很复杂的。等用上新版后要好好分析一下代码。

渲染堆栈(The Rendering Stack)
新版Twitter的页面都是在前端渲染的,但在不支持Javascript的情况下,后端也需要一个渲染系统。他们前后端用的模板系统都是Mustache,这样前后端可以保持一致,利用Mustache将API对象转成HTML代码。另外,针对DOM操作还做了诸多优化,如事件处理都是用事件代理机制实现,提高组件的重用性,尽可能减小repaint提高页面渲染性能等。

评化:Mustache是开源的模板系统,支持各种语言。我原来认为它有点重,并没有在项目中用过它。但如果真要做一个所有页面切换都是Ajax的应用,Mustache是首选。

内联媒体(Inline Media)
新版Twitter整合了很多第三方内容,从URL中判断如果是像kiva,vimeo这样的合作方,会利用基于oEmbed标准的JSON-P方式,从合作方的接囗中抓取内容。如果判断是来自TwitPic的图片或来自Youtube的视频,就直接显示出来。从视频中可以看到,交互方式很酷。

开源
Twitter的前端开发大量用到开源技术,像jQuery, Mustache, LABjs, Modernizr和大量jQuery插件。这么做的好处是一方面可以将重心放在前端应用的创新上,另一方面对开源社区的发展也是一种推动。自己在项目中积累的一些技术也会开源。

评论:我非常赞同这样。不要重复造轮子,尤其像浏览器级的基础功能库,jQuery,YUI已经做的很成熟了,需要做的应该是在没有或没有成熟的开源技术解决的领域上,通常更多在应用层面上需要建立适合自己产品的各种功能库和框架机制。

Twitter前端团队成员,可以关注一下:
Ben Cherry
@bcherry

http://www.adequatelygood.com/

Marcus Phillips
@mracus

http://marcusphillips.com/

Dustin Diaz
@ded

http://www.dustindiaz.com/

 

CouchDB了解(-) 特性及实现


概述

CouchDB,大家或多或少都听说过。它到底有什么特性,适合哪些应用场景,和我们常用的关系型数据库有什么区别? 这些问题,可能我们心里都不是非常清楚。在以前的Blog中(PS,不是在javaeye哦),我提及了几次CouchDB,但是仅仅 限于编译,安装这些浮在水面上的工作。今天抽出时间把最近关于CouchDB的一些了解整理一下。

 

CouchDB是什么

CouchDB一种半结构化面向文档的分布式,高容错的数据库系统,其提供RESTFul HTTP/JSON接口。其拥有MVCC特性,用户可以通过自定义Map/Reduce函数生成对应的View。

在CouchDB中,数据是以JSON字符的方式存储在文件中。

 

特性

  • RESTFul API:HTTP GET/PUT/POST/DELETE + JSON
  • 基于文档存储,数据之间没有关系范式要求
  • 每个数据库对应单个个文件(以JSON保存),Hot backup
  • MVCC(Multi-Version-Concurrency-Control),读写均不锁定数据库
  • 用户自定义View
  • 内建备份机制
  • 支持附件
  • 使用Erlang开发(更多的特性)

应用场景 在我们的生活中,有很多document,比如信件,账单,笔记等,他们只是简单的信息,没有关系的需求,我们可能仅仅需要存储这些数据。 这样的情况下,CouchDB应该是很好的选择。当然其他使用关系型数据库的环境,也可以使用CouchDB来解决。

 

根据CouchDB的特性,在某些偶 尔连接网络的应用中,我们可以用CouchDB暂存数据,随后进行同步。也可以在Cloud环境中,作为分布式的数据存储。CouchDB提供给予 HTTP的API,这样所有的常见语言都可以使用CouchDB。

 

使用CouchDB,意味着我们不需要在像使用RMDBS一样,在设计应用前首先设计负责数据Table。我们的开发更加快速,灵活。

 

实现

 

在CouchDB中,Database表示一个数据库,每个Database对应一个”Storage”(后缀为.couch)以及多个View Index(用来存储View结果支持query)。

 

 

 

Database Storage中可以存储任意的Document,用户可以在Database中自定义View,方便对数据进行查询, View 默认使用JavaScript进行定义,定义好的相关函数保存在 design document中,而View对应的具体数据是保存在View Index文件中。我们可以通过HTTP API请求Database,Document,View,可以进行简单的Query,以及其他各种系统相关的信息。

 

Storage File结构

数据库文件的后缀为.couch,由Header和Body组成。

Header
包含两个完全相同的Header信息,每个Header的Size为2048
Header中前4字节为magic code:$g, $m, $k, 0
随后为header的payload,通过term_to_binary(db_header_record)产生
接下来是填充padding
最后是16字节的摘要信息(md5(payload+padding)产生)
Header总长度为:单个Header * 2 = 2048
Body
由两个B+Tree组成,其中一个B+Tree根据Document id进行组织,另一个B+Tree以 seqnum(CouchDB内部使用的序号,用来指示最新Revision的文档)为key。
  • fulldocinfo_by_id_btree

    使用Document id作为key,常用来根据id来查找对应的document,full_doc_info中包含对应document的所有的Revision信息,通过这些信息,我们可以获取指定Revision的document

  • docinfo_by_seq_btree

    使用seq作为key,当document被更新时,对应的seq会增加。 具体的document数据(json格式),以及B+Tree混合存储与这个.couch文件之中。通过B+Tree,我们可以快速的定位到指定的document。

文件结构示意图

 

所有的更新操作(包括document的创建,修改和删除)都是以在couch文件尾部追加的方式(即Append方式)进行。我们进行更新时,首 先拷贝原有的数据信息(仅仅针对修改,如果是Create那么就没有copy可言了),随后将其追加到文件的结尾,这个时候就激发B+Tree从leaf 到root的更新过程,更新的Node信息也是采用Append的方式写入到文件的结尾,到达根节点时,我们将根节点信息写入到Header中。这样一次 更新操作涉及1次数据写入,以及LogN次节点更新,所以其复杂度为O(logN)

 

因此采用追加的方式,所以在数据库运行一段时间后,我们需要对其进行“瘦身”,情理那些旧的Document数据。这个过程成为 Compaction。在Compation的过程,数据库仍然可用,只是请注意,在Compation的时候,是通过遍历DBName.couch文 件,将最新的数据拷贝到一个DBName.compat文件中,因此这个过程可能会耗费很大的存储空间,如果您在系统繁忙(主要是write)的情况下进 行Compation,可能会导致你的硬盘空间耗尽,一定注意哦!

 

ACID

CouchDB支持ACID特性。Document的更新(add,edit,delete)是顺序进行的,但是Database的read为并发 执行,其不必等待任何其他的read,write的完成。这样的特性与CouchDB存储文件的Append增加方式关系密切。

当CouchDB的文档更新时,为了保证数据的一致性,Commit分为以下两步:

  1. Document数据和index数据首先写入到disk数据库文件
  2. 生成两个连续的头信息(4kb),随后写入数据库文件

在上面两个过程中,如果在过程1,发生异常(系统崩溃或断电),那么couch文件的头信息没有发生变化,那么所有Append的数据都会被忽略; 如果在过程2发生异常,此时Header可能会发生损坏,我们验证第一个Header和第二个Header,如果任意一个Header可用,那么数据库文 件可用。如果两个Header都不可用,则对应数据库文件损坏,抛出异常。

 

一些数据库系统,为了实现 Atomic Commit ,提交数据前,将内容写入到一个rollback log文件,等提交完成后,删除log文件。

 

View Server

除了存储数据,我们还需要依据我们的要求展现数据,乃至一些统计,因此CouchDB中引入了View的概念。View的引入让CouchDB从一个有趣的文件存储系统,步入了数据库的殿堂。也使CouchDB能够融入到真正的应用环境中。

 

CouchDB中所有的Document都可以具有自己不同的结构,数据,这和关系型数据库中,严格的表结构,严格的关联完全不同。这样的特点对于数据的备份同步却非常有好处!

View Model

通过用户自定义View,我们可以汇集,统计数据,采用一个类似Map/Reduce的过程。这里的Map将原始的Document进行映射处理,Reduce将Map的中间结果进行重新归并统计,总而生成最终结果。这里和并行计算中的Map/Reduce有些不同。

 

CouchDB的View针对每个Database,但是其与Database关联性不是很大,View是一些用户自定义函数,处理从数据库的 Document输入,产生中间数据(如果没有reduce过程则为最终数据),然后再通过Reduce处理中间输出,产生最终结果。同样的View可以 使用在不同的Database上。

 

View存储在design Document中,请注意这里design Document和View Index是不同的。design Document保存的是view的定义,View Index保存的是针对某个Database进行View操作,产生的结果。

JavaScript View Function

CouchDB内部默认使用JavaScript作为View的编写语言,之所以采用Javascript,是和CouchDB面向Web开发相关 的。CouchDB使用Mozilla的spidermonkey作为JavaScript的解析运行平台,为了和Erlang进行交互,其使用c书写了 一个Port程序couchjs,/server/main.js作为View Server服务器。

在启动CouchDB时,通过Command:couchjs main.js即可启动基于JavaScript的View Server。

View中包含两个函数:

(map函数,必须)
function(doc) {
  emit(null, doc);
}
(reduce函数,可选)
function (key, values, rereduce) {
   return sum(values);
}

doc ,为我们数据库对应的Document,因为我们采用JSON格式存储数据,所以Document在 JavaScript中转化为Object。`emit(null, doc)`用来生成map的中间结果,其中第一个参数null表示结果的key,第二个参数为结果的value,上面的例子中我们的结果为:

null, value1
...
null, valueN

function (key, values, rereduce)中,根据rereduce变量不同这里有两种情况:

  1. rereduce为false
  • key为array,element为:[key,id],key为map function产生的key,id为Document对应id
  • values为array,elements为map function产生的结果
  • 比如 reduce([ [key1,id1], [key2,id2], [key3,id3] ], [value1,value2,value3], false)
  1. rereduce为true
  • key为null
  • values为array,element为前一次reduce返回的结果
  • 比如reduce(null, [intermediate1,intermediate2,intermediate3], true)

很多时候,我们一次调用reduce就可以生成最终结果,我们会忽略rereduce参数。

 

 

 

resin-pro-3.1.8破解下载

resin-pro-3.1.8在11月18号已经正式发布,这次有点慢了,主要是不知道这个版本已经发布了,以后有新版本发布时,请及时通知作者( dingl.com (At) gmail.com )。

破解下载 :

Resin Change Log

我会及时破解Resin的最新版本!

resin-pro-3.1.8.zip
resin-pro-3.1.8.tar.gz

原文:http://www.dingl.com/blog/archives/49

linux下使用nload查看网卡实时流量

linux下使用nload查看网卡实时流量


nload是一个网络流量统计工具,当前版本为0.7.2。
下载地址:http://sourceforge.net/project/showfiles.php?group_id=35865


使用yum 安装也可以。


yum install nload


使用源码方式安装到/usr/local/nload,将/usr/local/nload/bin目录加入/etc/profile。


重新登陆ssh后,直接输入nload即可查看网卡的当前流量情况。
nload eth0 — 查看名叫eth0网卡的流量


可查看当前、平均、最小、最大、总共等的流量情况,单位为bit,详细的使用说明请参见:
http://www.debuntu.org/2006/07/14/74-nload-a-network-traffic-analyser


Resin 3.2.1 破解文件 crack keygen

resin3.2.1 的破解文件,仅供学习所用,不得用于商业用途.

把附件里的文件覆盖${resin_home}\lib里的pro.jar 即可
没用用户的可以用test/test 下载
如果你的版本不是是resin3.2.1,如果覆盖不能用时,可以试一下,把附件里的pro.jar里的 \com\caucho\license 目录覆盖你的pro里相应目录

The Best Java Tools You Never Knew Existed


I was at an awesome presentation at JavaOne of the long tail of Java tools that not many people have come across, which I had to share. So, in no particular order, and with my own emotive comments:



  • Apache Abdera – work easily with Atom feeds. See also Rome.

  • Antlr – this parser generator can look daunting, but it’s pretty easy once you get your head around it. Can be used to parse things like complex URLs where regexps are not up to the job.

  • ApacheDS – Java LDAP and Kerberos server, very easy to embed and great for testing your directory code. Now under the Apache Directory project which has heaps of other good stuff.

  • ASM – small, efficient bytecode manipulation

  • CGLIB – built on ASM, it works at a higher level and makes the former look like Assembler by comparison. Only downside is that it’s not well documented

  • JEXL – easily embeddable expression language, compares with OGNL

  • DisplayTag – JSP taglib for table formatting and exporting

  • EHCache – easy in-memory caching for everyone. Used this, it’s awesome.

  • Janino – someone took the time to write an embeddable Java compiler! It lets you use Java like a scripting language, eg. allow your users to type Java expressions directly into your GUIs.

  • Jar Jar Links – allows you to overcome namespace/package clashes between different versions of libraries used by your product by repackaging them. Similar to the Minijar Maven plugin that approaches the problem slightly differently by removing unused classes. Can be used to resolve dependency issues (classpath hell).

  • jDBI – substitute for JDBC that doesn’t suck when used directly

  • Jetty – web server/servlet container. Lightweight, yet lightning fast. Great for embedding, drives Grails.

  • Joda Time – date time library that kicks butt over java.util.Calendar. Intuitive (January is month 1!), easy to use and complete – everything that the java.util classes aren’t. Can be used alongside Date and Calendar. Chances are that the JSR based on this will become a part of Java 7, but why wait when you can use it now!

  • JSON-lib – best Java JSON library out there. Has good documentation. See also Jaxen.

  • Commons Math – everything from linear algebra to statistics

  • Mock Javamail – mock test infrastructure for Javamail code. See also Dumpster, Smartster.

  • Not-Yet-Commons-SSL – Nice, easy to use Java wrapper over OpenSSL. Encryption for the masses!

  • Selenium – test your web app interaction! HTML/JS, browser-based test environment – JUnit starts playing with windows :).

  • Selenium IDE – the “IDE” part may be overstating things, but this Firefox plugin generates the basis of your test code for you. See also Canoo Webtest.

  • Selenium Maven plugin – self explanatory

  • Sitemesh – like Tiles, but non-intrusive and heaps better. It hasn’t been updated for ages because it Just Works.

  • Smack – Java Jabber client

  • XStream – objects -> XML -> objects translation. I can’t recommend this one enough, awesome one to have in the toolbox.

  • StringTemplate – like Velocity, but better.

  • Ivy – this Ant plugin means that dependency management is not just for Maven any more. I worked on a big project that used this and it worked a treat.

  • Subetha – a mailing list manager and embeddable mail server. See also James.

  • Scriptella – extract, transform and load (ETL) tool for Java.

Feel free to add any gems that you have come across in the comments!