Adding and subtracting
*CTRL-A*
CTRL-A Add [count] to the number or alphabetic character at
or after the cursor. {not in Vi}
*CTRL-X*
CTRL-X Subtract [count] from the number or alphabetic
character at or after the cursor. {not in Vi}
The CTRL-A and CTRL-X commands work for (signed) decimal numbers, unsigned
octal and hexadecimal numbers and alphabetic characters. This depends on the
'nrformats' option.
- When 'nrformats' includes "alpha", Vim will change the alphabetic character
under or after the cursor. This is useful to make lists with an alphabetic
index.
- When 'nrformats' includes "hex", Vim assumes numbers starting with '0x' or
'0X' are hexadecimal. The case of the rightmost letter in the number
determines the case of the resulting hexadecimal number. If there is no
letter in the current number, Vim uses the previously detected case.
- When 'nrformats' includes "octal", Vim considers numbers starting with a '0'
to be octal. Other numbers are decimal and may have a preceding minus sign.
If the cursor is on a number, the commands apply to that number; otherwise
Vim uses the number to the right of the cursor.
For numbers with leading zeros (including all octal and hexadecimal numbers),
Vim preserves the number of characters in the number when possible. CTRL-A on
"0077" results in "0100", CTRL-X on "0x100" results in "0x0ff". Note that
when 'nrformats' includes "octal", decimal numbers with leading zeros are
impossible because they are indistinguishable from octal numbers.
The CTRL-A command is very useful in a macro. Example: Use the following
steps to make a numbered list.
1. Create the first list entry, make sure it starts with a number.
2. qa - start recording into buffer 'a'
3. Y - yank the entry
4. p - put a copy of the entry below the first one
5. CTRL-A - increment the number
6. q - stop recording
7.@a - repeat the yank, put and increment times
2008/12/18
VIM is so cool
2008/12/11
Mapping remote TCP port to local via HTTPS Proxy
上次说的Perl代码供大家参考
功能:把远端的应用服务端口通过HTTPS代理服务器映射成本地端口。这对于那些不支持HTTPS代理的TCP应用还有点儿小用处! :D
#!/usr/bin/env perl
#
# Use remote HTTPS PROXY to tunnel the remote service to local!
# Author: Yi Zhao
# Blog: linuxyz.blogspot.com
#
# Based on original "ssltunnel.pl" by Alex Hornby <alex@hornby.org.uk>
# $Id: ssltunnel.pl,v 1.17 2003/06/10 14:54:16 alex Exp $
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
package httpsproxy;
use strict;
my $VERSION=1.0;
use IO::File;
use IO::Select;
use IO::Socket;
use Net::SSL;
use Getopt::Long;
use MIME::Base64;
my %options = (
proxyport=>443,
reproxyport=>8080,
localaddr=>"127.0.0.1",
localport=>8080,
);
sub usage
{
print STDERR <<EOF;
usage: perl httpsproxy.pl [options] [remote-host:port]
Tunnels a TCP/IP connection through an http proxy using SSL.
WARNING: Only use this if you have the proxy administrator\'s permission
WARNING: The authors of this package offer no warranty
options:
--help This help
--proxyhost 1.2.3.4 Mandatory proxy host port (default 443)
--proxyport 443 Optional proxy host port (default 443)
--proxyuser <username> Optional proxy user name
--proxypasswd pass Optional proxy pass word
--useragent agent Optional user agent name
--reproxyhost 1.2.3.4 Optional intermediate http proxy host
--reproxyport 123 Optional intermediate http proxy host port (default 8080)
--reproxyuser <username> Optional intermediate http proxy user name
--reproxypasswd pass Optional intermediate http proxy pass word
--localaddr 1.2.3.4 Optional local addr to listen on (default 127.0.0.1)
--localport 123 Optional local port to listen on (default 8080)
e.g. To run a local http proxy to the remote HTTPS proxy
./httpsproxy.pl --proxyhost 10.1.1.80 \
--proxyport 443 --localport 80 www.abc.com:80
EOF
exit(1);
}
# Parse command line arguments
sub parseArgs
{
GetOptions(\%options, qw/dumpfile=s
proxyhost=s proxyport=i proxyuser=s proxypasswd=s useragent=s
reproxyhost=s reproxyport=i reproxyuser=s reproxypasswd=s reuseragent=s
localaddr=s localport=i
debug! help!
log-file=s pidfile=s/);
if ( $options{help} ) {
usage();
}
for (@ARGV) {
if (m/^([^:]*):(.*)$/) {
$options{desthost} = $1;
$options{destport} = int($2) || getservbyname($2, 'tcp') || die "unknown port";
print "Mapping $options{desthost}:$options{destport} as $options{localaddr}:$options{localport}\n";
}
}
if ( !defined($options{proxyhost}) ) {
print STDERR "error: You must give a proxyhost\n";
usage();
}
}
# This is really inefficient, but we only use it for reading the proxy response
# so that does not really matter.
sub xgetline($)
{
my $proxy = shift;
my $val="";
my $buf;
do {
$proxy->read($buf, 1);
$val .= $buf;
} until ($buf eq "\n");
$val;
}
sub httpProxy
{
my ( $proxy, $desthost, $destport, $proxyuser, $proxypasswd ) = @_;
# Force flushing of socket buffers
# The actual connect
$proxy->print("CONNECT " . $desthost . ":" .
$destport . " HTTP/1.0\r\n");
if ( $options{debug} ) {
print STDERR "CONNECT " . $desthost . ":" .
$destport . " HTTP/1.0\n";
}
# Basic auth if needed
if ( $proxyuser ) {
my $auth = encode_base64(
$proxyuser . ":" . $proxypasswd);
$proxy->print("Proxy-authorization: Basic $auth\r\n");
if ( $options{debug} ) {
print STDERR "Proxy-authorization: Basic $auth"
}
}
# User agent name if needed
if ( $options{useragent} ) {
$proxy->print("User-Agent: " . $options{useragent} . "\r\n");
if ( $options{debug} ) {
print STDERR "User-Agent: " . $options{useragent} . "\n";
}
}
# end of headers
$proxy->print("\r\n");
my $status;
# Wait for HTTP status code, bail out if you don't get back a 2xx code.
#$_ = $proxy->getline();
#$_ = $proxy->getchunk();
$_ = xgetline($proxy);
next if /^[\r]*$/;
($status) = (split())[1];
die("Received a bad status code \"$status\" from proxy server\n$_")
if ( int($status/100) != 2 );
while($_ = xgetline($proxy)) {
chomp; # Strip <LF>
last if /^[\r]*$/; # Empty line or a single <CR> left
if ( $options{debug} ) {
print STDERR "Got extra data [$_]\n";
}
}
return $status;
}
sub connectProxy
{
if ( $options{reproxyhost} ) {
# proxy support
$ENV{HTTPS_PROXY} = qq(http://$options{reproxyhost}:$options{reproxyport});
# proxy_basic_auth
$ENV{HTTPS_PROXY_USERNAME} = $options{reproxyuser} if $options{reproxyuser};
$ENV{HTTPS_PROXY_PASSWORD} = $options{reproxypass} if $options{reproxypass};
}
# debugging (SSL diagnostics)
$ENV{HTTPS_DEBUG} = $options{debug} ? 1 : 0;
my $proxy = new Net::SSL (
PeerAddr => $options{proxyhost},
PeerPort => $options{proxyport},
Proto => 'tcp',
);
die "Error connecting to proxy host $options{proxyhost} " .
"port $options{proxyport}: $!\n" unless $proxy;
# Force flushing of socket buffers
$proxy->autoflush(1);
# only if the remote host are speficied
httpProxy($proxy, $options{desthost}, $options{destport},
$options{proxyuser}, $options{proxypasswd} )
if ( $options{desthost} );
return $proxy;
}
sub connectLocal
{
my $listen = new IO::Socket::INET (
Listen=> 5,
LocalAddr => $options{localaddr},
LocalPort => $options{localport},
Proto => 'tcp',
Reuse => 1,
);
die "can't listen on " . $options{localaddr} . ":"
. $options{localport} unless $listen;
print STDERR "Accepting network clients on " .
$options{localaddr} . ":" .$options{localport} . "\n";
my %client2proxy;
my %proxy2client;
my $s = IO::Select->new();
$s->add($listen);
my $dumpfh;
if ( $options{dumpfile} ) {
$dumpfh = new IO::File($options{dumpfile}, "w")
or die "could not open dump file $_";
$dumpfh->autoflush(1);
}
while ( 1 ) {
my @res = IO::Select::select($s, undef, undef, 3600);
if ( @res == 0 ) {
print STDERR "got select error\n";
last;
}
my ($read, $write, $error) = @res;
# Check for disconnect
for my $fh ( @$error ) {
print STDERR "socket $fh is in error\n";
$s->remove($fh);
exit();
}
# Process handles ready to read;
for my $fh ( @$read ) {
if ( $fh == $listen ) {
my $client = $listen->accept();
$client->autoflush(1);
$s->add($client);
my $proxy = connectProxy();
$s->add($proxy);
print STDERR "New connection from " . $client->peerhost() . "\n";
$client2proxy{$client} = $proxy;
$proxy2client{$proxy} = $client;
} else {
my $destfh;
my $isclient = 0;
if ( exists( $client2proxy{$fh} ) ) {
$destfh = $client2proxy{$fh};
$isclient = 1;
} elsif ( exists( $proxy2client{$fh} ) ) {
$destfh = $proxy2client{$fh};
}
my $num = sysread($fh, $_, 4096);
if ( $num) {
syswrite($destfh, $_, $num);
# Optional dump of traffic
if ( $dumpfh ) {
if ($isclient) {
$dumpfh->print("client[$_]\n");
} else {
$dumpfh->print("proxy[$_]\n");
}
}
} else {
$s->remove($fh);
$s->remove($destfh);
if ( $isclient ) {
print STDERR "client disconnected\n";
delete($client2proxy{$fh});
delete($proxy2client{$destfh});
} else {
print STDERR "proxy disconnected\n";
delete($client2proxy{$destfh});
delete($proxy2client{$fh});
}
close($fh);
close($destfh);
if(%proxy2client == 0 ) {
print STDERR "last client disconnected\n";
}
}
}
}
}
}
parseArgs();
connectLocal();
0;
__END__
copy and paste in VIM
I forgot there is another register *, it is as same as the system clipboard. So you can yank some text into register *, it will be in the system clipboard also. :D"{a-zA-Z0-9.%#:-"} Use register {a-zA-Z0-9.%#:-"} for next delete, yank
or put (use uppercase character to append with
delete and yank) ({.%#:} only work with put).
:reg[isters] Display the contents of all numbered and named
registers. {not in Vi}
:reg[isters] {arg} Display the contents of the numbered and named
registers that are mentioned in {arg}. For example:
["x]y{motion} Yank {motion} text [into register x]. When no
characters are to be yanked (e.g., "y0" in column 1),
this is an error when 'cpoptions' includes the 'E'
flag.
["x]p Put the text [from register x] after the cursor
[count] times. {Vi: no count}
2008/12/04
Apache HTTPD as Proxy server
为此,用Apache自建了一个HTTPS代理,这样就能够利用这个二次代理做一些其他的应用。
Apache HTTPD 真是强悍啊!首先在 httpd.conf 打开mod_proxy;
ProxyRequests On
AllowCONNECT 21 22 23 80 443再试,Working... 高喊:“Apache 太强悍了~~~”
2008/10/08
健康饮食
怎么才能活的好?健康饮食最重要。
一日三餐都要吃,早餐万万别省掉!
少吃主食多吃菜,精肉蛋奶不能少,
少食多餐勤运动,零食一定要戒掉。
饮食起居有规律,利国利民身体好!
附食物结构金字塔一个
2008/09/27
关于Google Chrome以及Android
Google Chrome的感觉有些奇怪,浏览器领域在此之前基本已经尘埃落定,IE保持老大地位,firefox作为老而保持sexy的形象,老三大量的IE内核的克隆产品,然后是Opera以及Safari。从本质上来说,Google应该是不关心浏览器的,但是Microsoft开始进入Google的领域,说实话,谁都要提防Microsoft自说字画的搞乱浏览器市场。Google培育Mozilla就是这样的目的,可以说只要Mozilla没有走到绝对优势的地位,Google就不会停止对Mozilla的支持。当然了这次Google自己赤膊上阵恐怕也抱着同样的目的,那就是:在浏览器市场纠缠Microsoft,增加话语权,同时让Microsoft走到W3C的标准圈子内,不论是Microsoft的Silverlight,还是Adobe的Flash/Flex/Air。 对Google来说,都不是他想看到的,对于Google这种Internet信息服务提供者来说,最好在客户端领域是群雄争霸,决不能一枝独秀。另一方面Chrome真正目的应该是成为Google的桌面应用平台,看看Chrome强调的JavaScript速度,独立进程管理,哪个都像是在给桌面应用开发作准备。
总的来说,Google作为后来者,她要做的就是不断搞出新的东西,不断进入新的Internet或者信息服务相关的外延领域。不论成功或失败,总要在别人的家里打仗才好。
2008/09/26
VIM Tips
That's simple, put this line into your vimrc file
set guifont=Bitstream\ Vera\ Sans\ Mono:h10:cANSIVIM will be using NSimSun to display the Chinese characters. :)
set guifontwide=NSimSun:h11:cGB2312
And "Bitstream Vera Sans Mono" to be used for ANSI characters.
Indeed this option can be set locally for each individual files by using the VIM modeline
vim:ts=4:sw=4:expandtab:enc=utf8All the VIM option can be changed locally. Don't forget to put this modeline into the comments :D
VIM is fantastic cool~~~
2008/09/23
强力推荐JavaScript 高级教程
Learning Advanced JavaScript
1) Our Goal
2) Defining Functions
3) Named Functions
4) Functions as Objects
5) Context
6) Instantiation
7) Flexible Arguments
8) Closures
9) Temporary Scope
10) Function Prototypes
11) Instance Type
12) Inheritance
13) Built-in Prototypes
14) Enforcing Function Context
15) Bonus: Function Length
2008/08/28
Web 2.0
一般而言,谈论WEB2.0时,我们的概念基本上是,1、用户贡献的内容。2、方便的交互环境。和以前的网站概念不同,WEB2.0主要是依靠用户的参 与。用户的直接参与和内容提供,这是大家都能看到的WEB2.0的核心要素。好的WEB2.0,是在于能够有比较清楚的定位,吸引特定的人群,并在技术上 方便用户的参与。比如MYSPACE更注重社交功能,三教九流,五花八门都可以找到或者建立自己的朋友圈子,内容并不重要。从这个意义上说,digg.com del.icio.us 才有那么点儿Web2.0的意思。 :)
2008/08/25
重温 shell 编程的 变量操作
特别是有正则表达式
The character $ is used to introduce substitutable parameters.
${parameter}
The shell reads all the characters from ${ to the matching } as part of the same word even if it contains braces or metacharacters. The value, if any, of the parameter is substituted. The braces are required when parameter is followed by a letter, digit, or underscore that is not to be interpreted as part of its name, when the variable name contains a .. The braces are also required when a variable is subscripted unless it is part of an Arithmetic Expression or a Conditional Expression. If parameter is one or more digits then it is a positional parameter. A positional parameter of more than one digit must be enclosed in braces. If parameter is * or @, then all the positional parameters, starting with $1, are substituted (separated by a field separator character). If an array vname with subscript * or @ is used, then the value for each of the elements is substituted, separated by the first character of the value of IFS.
${#parameter}
If parameter is * or @, the number of positional parameters is substituted. Otherwise, the length of the value of the parameter is substituted.
${#vname[*]}
${#vname[@]}
The number of elements in the array vname is substituted.
${!vname}
Expands to the name of the variable referred to by vname. This will be vname except when vname is a name reference.
${!vname[subscript]}
Expands to name of the subscript unless subscript is * or @. When subscript is *, the list of array subscripts for vname is generated. For a variable that is not an array, the value is 0 if the variable is set. Otherwise it is null. When subscript is @, same as above, except that when used in double quotes, each array subscript yields a separate argument.
${!prefix*}
Expands to the names of the variables whose names begin with prefix.
${parameter:-word}
If parameter is set and is non-null then substitute its value; otherwise substitute word.
${parameter:=word}
If parameter is not set or is null then set it to word; the value of the parameter is then substituted. Positional parameters may not be assigned to in this way.
${parameter:?word}
If parameter is set and is non-null then substitute its value; otherwise, print word and exit from the shell (if not interactive). If word is omitted then a standard message is printed.
${parameter:+word}
If parameter is set and is non-null then substitute word; otherwise substitute nothing.
In the above, word is not evaluated unless it is to be used as the substituted string, so that, in the following example, pwd is executed only if d is not set or is null:
print ${d:-$(pwd)}
If the colon ( : ) is omitted from the above expressions, then the shell only checks whether parameter is set or not.
${parameter:offset:length}
${parameter:offset}
Expands to the portion of the value of parameter starting at the character (counting from 0) determined by expanding offset as an arithmetic expression and consisting of the number of characters determined by the arithmetic expression defined by length. In the second form, the remainder of the value is used. If A negative offset counts backwards from the end of parameter.
Note that one or more blanks is required in front of a minus sign to prevent the shell from interpreting the operator as :-. If parameter is * or @, or is an array name indexed by * or @, then offset and length refer to the array index and number of elements respectively. A negative offset is taken relative to one greater than the highest subscript for indexed arrays. The order for associate arrays is unspecified.
${parameter#pattern}
${parameter##pattern}
If the shell pattern matches the beginning of the value of parameter, then the value of this expansion is the value of the parameter with the matched portion deleted; otherwise the value of this parameter is substituted. In the first form the smallest matching pattern is deleted and in the second form the largest matching pattern is deleted. When parameter is @, *, or an array variable with subscript @ or *, the substring operation is applied to each element in turn.
${parameter%pattern}
${parameter%%pattern}
If the shell pattern matches the end of the value of parameter, then the value of this expansion is the value of the parameter with the matched part deleted; otherwise substitute the value of parameter. In the first form the smallest matching pattern is deleted and in the second form the largest matching pattern is deleted. When parameter is @, *, or an array variable with subscript @ or *, the substring operation is applied to each element in turn.
${parameter/pattern/string}
${parameter//pattern/string}
${parameter/#pattern/string}
${parameter/%pattern/string}
Expands parameter and replaces the longest match of pattern with the given string. Each occurrence of \n in string is replaced by the portion of parameter that matches the n-th sub-pattern. In the first form, only the first occurrence of pattern is replaced. In the second form, each match for pattern is replaced by the given string. The third form restricts the pat-
tern match to the beginning of the string while the fourth form restricts the pattern match to the end of the string. When string is null, the pattern will be deleted and the / in front
of string may be omitted. When parameter is @, *, or an array variable with subscript @ or *, the substitution operation is applied to each element in turn. In this case, the string portion of word will be re-evaluated for each element.
2008/08/24
香农极限 带宽计算公式
不禁要感慨这人太牛了。给我们呈现了一种物理学中简单的美~~~
- If S/N >> 1, then
-
- where
-
- Similarly, if S/N <<>
- In this low-SNR approximation, capacity is independent of bandwidth if the noise is white, of spectral density N0 watts per hertz, in which case the total noise power is
.
2008/08/21
苏联笑话
话说列宁,斯大林,赫鲁晓夫,勃列日涅夫,戈尔巴乔夫五人同坐一列社会主义号火车前进, 突然火车停了,车长过来报告,前面铁路断了,列宁:"说发动一次星期六义务劳动把它修好",斯大林一瞪眼:"一定有阶级敌人搞破坏,抓起来枪毙",赫若有 所思 "前面不通,就倒车吧",勃列日涅夫:"找几个人下车摇火车就行了,乘客感到车在动就以为在前进",只有戈尔巴桥夫最绝:"把火车拆了,每人扛一件零件前 进, 到有铁轨的地方再装起来"于是拆了火车, ...
斯大林的烟斗
斯大林喜欢夜间工作,有一次他凌晨 3点迷迷糊糊就睡着了,把最喜欢的烟斗忘在了沙发缝里。第二天早上起来发现找不到烟斗了,就让贝利亚去处理这件事。第二天贝利亚揭露出了一个“利用偷烟斗 进行暗杀活动的托洛茨基组织”,10多名罪犯全被枪决,但是还是没找到那个烟斗。最后是苏斯洛夫坐这个沙发觉得塥的慌,打开一看才找到的。
赫鲁晓夫与猪
赫 鲁晓夫喜欢以农业专家自居。一次参观某集体农庄养猪场,发现一头病歪歪的小猪。农庄主席解释说这猪从小营养不良,养僵了。赫鲁晓夫当即说,把这猪抱到我 家,保证两个月养肥还给你们。赫氏回家怎么摆弄那猪也不长。情急下决定把猪处理掉。他在傍晚时分将猪放入婴儿车,准备推到莫斯科河边抛掉。谁知半路上偏偏 遇上米高扬。 “赫鲁晓夫同志,散步哪。” “啊……出来走走……” “这是谁啊?” “哦,是我……小外孙。” “我看看。哦,多好的孩子,长得真像他外祖父!”
赫鲁哓夫视察
赫鲁哓夫有一次视察农场,在参观到猪圈时,记者拍了照。回到报社后,想以赫鲁哓夫同志和猪的标题发表在真理报上。苏斯洛夫说这样会影响领导形象。结果,第二天,苏联人民手里拿到的真理报上的标题是:赫鲁哓夫同志视察农场(左起等三位为赫鲁哓夫同志)。
当时你再干什么
赫鲁晓夫在苏共二十大揭露斯大林的暴行时,台下有人递条子上去。赫鲁晓夫当场宣读了条子的内容:“当时你在干什么?”。然後问道:“这是谁写的,请站出来!”。连问三次,台下一直没有人站出来。于是赫鲁晓夫说:“现在让我来回答你吧,当时我就坐在你的位置上。”
两面派
原 苏联共产党中央第一书记赫鲁晓夫(1891--1971年)在愤怒遣责联合国阻挠苏调停刚果战后独立危机的行为不久,又向联合国秘书长哈马金尔德发去一封 礼节性的邀请书,请他参加苏联的国宴。赫鲁晓夫非常热情地欢迎哈马金尔德的到来。有人问他,为什么对前不久遣责过的人表现得如此热忱。赫鲁晓夫反问道: “你知道我国高加索地区人民的传统习惯吗?敌人在你家里作客,与你分享面包和食盐时,你要殷勤款待;一旦敌人跨出了你的家门,你就可以豁断他的喉管。”
勃列日涅夫的糊涂母亲
勃列日涅夫偏爱住非常豪华的住房,在郊外有好几处很奢侈的别墅。有一次,他把他的老妈接到城里来,骄傲地把自己的别墅展示给她看。谁知他的老妈一点也不高兴。勃列日涅夫很奇怪,问为什么。他妈答道:孩子,你住这么好的房子,要是共产党执政,你可怎么办呀……
勃列日涅夫论苏联民主
勃 列日涅夫当政时期,美国总统尼克松访问苏联。在记者招待会上,尼克松想借机宣扬美国式的民主,于是说:“在我们美国言论自由,任何人都可以在白宫前,大 骂:‘尼 克松是王八蛋!’肯定没有警察来抓他。” 勃列日涅夫不动声色平静的说:“在苏联同样也是言论自由,任何人也都可以在克里 姆林宫前大骂:‘尼克松是王八蛋’同样也没有警察来抓他!”
马克思主义者勃烈日捏夫
斯大林逝世后的 苏联,一直由精通马列的苏斯洛夫做意识形态的最高权威。搬倒赫鲁晓夫不久,地位还不是很稳固。苏斯洛夫为勃烈日捏夫写好了一片苏共中央全会的发言稿,其中 有几段引用的马克思的经典语句,但是在勃烈日捏夫在会上读时却跳过这些段落,让苏斯洛夫一脑子问号。会后去勃烈日捏夫家做客时才有机会问,勃烈日捏夫说 “你说他们会相信我读过马克思的书吗?如果我能引用出马克思话,柯锡金、谢列平他们都会笑的”
勃列日涅夫穿鞋
勃列日涅夫上班秘书对他说:“列昂尼德·伊利奇,您的皮鞋一只是棕色的,一只是红色的” 勃列日涅夫:这有什么奇怪,我家里还有一双也是这样的。
2008/08/15
Open Souce 的版权终于得以正名
Jacobsen v. Katzer:开源运动的一个重大胜利 http://www.cnbeta.com/articles/62360.htm
Jacobsen v. Katzer 的诉讼 http://en.wikipedia.org/wiki/Jacobsen_v._Katzer
案件大致情况是:
2006年,Bob Jacobsen起诉Matt Katzer,声称后者的软件没有遵守开源协议,标明源代码的出处和作者,要求法院认定这是侵犯著作权行为。但是,当时的旧金山联邦地区法院驳回了这个请 求,认为这只是“违反契约”(a breach of the licensing agreement),而不是“侵犯著作权”(copyright infringement)。 在美国通常“违法契约”诉讼人只能申请经济上的补偿, 而“侵犯著作权”则可以申请禁止令要求侵权人停止损害。
2008年8月,美国联邦上诉法院(Court of Appeals for the Federal Circuit)判决:“‘开源协议’ 是一种著作权协议,违反协议就是侵权行为。” 法官还表示 "Open source licensing has become a widely used method of creative collaboration that serves to advance the arts and sciences in a manner and at a pace that few could have imagined just a few decades ago,"
对于实行判例法系的美国,这将是法律体系对开源版权的确认!
PC Magazine 的报道: http://www.pcmag.com/article2/0,2817,2328027,00.asp
研究的精神
2008/08/14
低价 PC or 低功耗 PC
特别是下面的这段文字:
“Intel每年销售1亿多片CPU,销售额为350-400亿美元,平均每片价格为200多美元,毛利润150美元以上。假设Intel为低成本电脑推 出价格为20美元左右的CPU,毛利润为每片5美元左右,每年销售2亿片,销售额为40亿美元,毛利润为10亿美元。如果这2亿片低成本芯片的销售不影响 原来的1亿多片的芯片销售,则Intel是愿意做的;但如果由于这2亿片低成本芯片的销售使得其他处理器的销售减少了2000万片,则Intel销售额减 少40亿美元,利润减少30亿美元。”(《龙芯之火,可以燎原》,2007年12月)市场经济,利益至上 Intel Atom 的低功耗,低廉的价格,低下的性能都是Intel所期望的! Intel从一开始就没有打算用 Atom 来作为低价PC的CPU来销售,她的目标是低功耗PC。以至于Atom在这个领域内热卖的时候,Intel不但没有增加产量,而是控制产量提高售价,因为Intel比谁都清楚Atom的毛利太低,卖的太多不赚钱,既然它热卖那就索性提价提高毛利!
AMD也有他自己的应对策略。AMD比不了Intel,她没有太多的研发实验室,没有太多的工厂,不能像Intel那样同时搞很多的不同设计,既然不能用新的对应的产品和你比,那就用已经有的老产品改头换面来跟你比,反正最终的效果是一样的。 当然了,不是在低价PC,AMD的价格已经够低了; 只能在低功耗方面做文章, 这个Mini-780G就是一个不错的模式!
“功耗吗确实是你Intel Atom低,但是我的总功耗也不高,也就是个70/80W(比Atom高30W),但是性能比你强1倍,1080p完全没问题,不像你720p都吭吭哧哧的!为了看高清又有谁会在乎多点这一个灯泡呢?”博弈啊!!!
2008/08/07
How to Write a Good Technical Documentation
DO:
- Fully understand the situation, and know the 5 W's:
"Who, What, Where, When, and Why". - KISS: Keep It Simple and Stupid
- Write agenda before you start
- Keep the technical integrity
- Add reference links for all the shared knowledge
- Use diagram to show the complex logical
- Use table to show the structured information
- Compare the different design alternatives
- Use bulletin and numbered list to express the idea
- Write a good looking document
- Have a good template
- Use named style to control the format
- Always do spelling/grammar check
- Tidy your documentation
- Ask for comments from others
- Track changes between the reversions
DON'T:
- Write long sentence or paragraph
- Be afraid to delete some pieces
- Be afraid to reconstruct sections
- Be afraid to spend more time
Miscellanea:
- Ask for others' help, and help others
- Eats your own dog food
Read it once more when you feel it were finished
2008/07/15
The smallest C program to print the biggest prime number
这个世界上,令人敬仰的人太多了~~~~ Fabrice Bellard 就是一个这个就是他的小程序,用来计算目前已知的最大质数的程序一共只有475字节,是一个一行程序。
可以通过任何C编译器编译。
int m=754974721,N,t[1<<24],a,*p,i,e=16804127,j,s,c,U;f(d){for(s=1<<24;s/=2;d=d*1
LL*d%m)if(s<N)for(p=t;p<t+N;p+=s)for(i=s,c=1;i;i--)a=*p+p[s],p[s]=(m+*p-p[s])*1L
L*c%m,*p++=a%m,c=c*1LL*d%m;for(j=0;i<N-1;){for(s=N/2;!((j^=s)&s);s/=2);if(++i<j)
a=t[i],t[i]=t[j],t[j]=a;}}main(){*t=2;U=N=1;while(e/=2){N*=2;U=U*1LL*(m+1)/2%m;f
(362);for(p=t;p<t+N;p++)*p=*p*1LL**p%m*U%m;f(415027540);for(a=0,p=t;p<t+N;)a+=*p
<<(e&1),*p++=a%10,a/=10;}while(!*--p);t[0]--;while(p>=t)printf("%d",*p--);}
格式化之后,它看起来这样:
#include <stdio.h>
#include <stdlib.h>
int m=754974721,N,t[1<<24],a,*p,i,e=16804127,j,s,c,U;
f(int d){
for(s=1<<24;s/=2;d=d*1LL*d%m)
if(s<N)
for(p=t;p<t+N;p+=s)
for(i=s,c=1;i;i--)
a=*p+p[s],p[s]=(m+*p-p[s])*1LL*c%m,*p++=a%m,c=c*1LL*d%m;
for(j=0;i<N-1;){
for(s=N/2;!((j^=s)&s);s/=2);
if(++i<j)
a=t[i],t[i]=t[j],t[j]=a;
}
}
main(){
*t=2;
U=N=1;
while(e/=2){
N*=2;
U=U*1LL*(m+1)/2%m;
f(362);
for(p=t;p<t+N;p++) *p=*p*1LL**p%m*U%m;
f(415027540);
for(a=0,p=t;p<t+N;) a+=*p<<(e&1),*p++=a%10,a/=10;
}
while(!*--p);
t[0]--;
while(p>=t)printf("%d",*p--);
}
计算输出的结果有 9M 之巨。
另外说一句,这个哥哥 72年出生,今年36岁。
2008/06/27
RPC forever / 永远的 RPC
When the computer networks born in 1970s, distribution computing was coming in the vision, from that time to now. Variety of RPC/IPC mechanism were invited into the world. I think at least some of them are very familiar with you:
- BSD Socket
- telnet
- FTP
- SMTP/POP3/IMAP
- NNTP
- RSH/RLOGIN
- ONC-RPC / DEC-RPC
- NFS
- HTTP
- XMPP
- SSH
- CORBA/IIOP/GIOP
- DCOM/COM
- Java/RMI
- SOAP/Web Service
- XML-RPC
- JSON
Because the IT industry always need the fresh blood!!!
Something else changed, you also want to change yours. :)
人都是喜新厌旧的!
2008/06/10
iPhone 3G is coming! 智能手机们都该洗洗睡了
看看这次 Steve Jobs 给我们带来了什么? 8G内存的版本价格为 $199 = ¥1400 : 3G UMTS, Wifi, Apple's design.
我看所有高高在上智能手机都该洗洗睡了!
Apple 打得起这个价格战, 早就有分析人士估计过 iPhone的成本价格, 不过一百多刀。 那还是市面上的元器件价格, 就凭Apple的议价能力,还有进一步的利润空间。 即便保持当前的这个价格水平, Apple 仍旧能有 40%左右的毛利。 而iPhone 的研发成本早就通过第一批 iPhone $499 的暴利赚个八九不离十。 目前Apple要做的就是铆足力气,甩开所有潜在的竞争对手, 进而利用 iPhone 这个平台展开其他的增值业务。 最直接的说就是进入企业应用市场,iPhone 直接支持Microsoft Exchange Server, 支持iChat, BlackBerry 这次真的危了!
但从所谓高端智能手机这个层面来说,$199 的价格,不但让 Nokia, BlackBerry, SonyEricsson, Samsung, Motorola, LG 等厂商汗颜,恐怕就连那些国内的黑手机,山寨兄弟们也要卧倒一大片了。
市场规律就是这样, 技术优势总是属于后来者的, 就看你能不能把握了!
2008/06/05
不得不说的 Safari + WebKit
感觉上 Safari 本身并没有什么特别之处, 从应用程序框架的角度来说远不如 Mozilla Firefox 来的灵活。但是 WebKit 引擎确实不得不让人刮目相看。简单来说,WebKit 有如下的优势:
1, 浏览速度快
特别是 SquirrelFish 的 JavaScript 引擎发布之后,Safari简直跟飞一样。 而且下载的速度也巨快!
2,字体渲染效果好
所有的字体显示都采用了 anti-aliasing, 当然不是所有人都喜欢这样的字体效果,八成会说它显示的模糊。不过目前来说确实能够和内嵌点阵字体的SimSun一争高下。
3, 标准
当前的 Safari 3.1.1 + WebKit r34367 可以顺利通过所有的 acidtests, 特别是 Acidtest3 这个高难度动作, WebKit 不但可以全部完成而且运行飞快:< 2s 令人惊叹啊!
4, 超炫的 Web Inspector
Safari 内置的 Inspector 简直就是一个综合的 Web 应用集成开发工具。
不过也有些缺点:
1, Plugin 支持的问题还比较多
基本能工作,但是不稳定!
2,第三方应用太少
3, Safari 的 tab 功能一般
2008/05/29
2008/05/13
Using :vimgrep inside VIM
Using `:vimgrep` is fairly easy, just in command mode, type in
:vim[grep][!] /{pattern}/[g][j] {file} ...The `grep` result will be put into the `quickfix` list. The `:cnext`, and `:cprevious` can be used to navigate the `quickfix` list.
Let's do something to help us! Put this into your ~/.vimrc file.
" We can navigate the list by using theand
map <F3> :cnext
map <S-F3> :cprevious
After that, you will be able to use the <F3> and <shift>-<F3> navigate the `quickfix` list easily. :D
2008/05/09
Tip for trouble shooting the VIM syntax highlight
Here is a small tip can help you a little bit.
put this into your ".vimrc" file
" display the syntax name under the cursor
map <F12> :echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "name")
For the next time, when you met some syntax highlight error, you can key in <F12> at the error place, VIM will tell you "what kind syntax ID that it is thing under the given position".
Keep fun! :)
2008/04/08
必须了解的"时间管理"原则
2、错误的感觉。管理者的时间很少花费在他自己想要花费的地方。这种想法捉弄了时间的所有者,使他错误地认为,他的时间正用于该用的地方。
3、时间分析。每日活动记录至少持续一周,每过15分钟填写一次,这作为有效时间分析的基础是必要的。这种活动至少每半年应该重复一次,以免回复低劣的时间管理方式。
4、预料。事先有所准备的活动一般来说比事后补救的活动更为有效。小洞不补,大洞吃苦。避免发生以外的最好办法就是预料可能发生的以外事件,并为其制订应急措施。我们假定,如果事情要出错,那就无法避免。
5、计划。绝大多数难题都是由未经认真考虑的行动引起的。在制定有效的计划中每花费一小时,在实施计划中就可能节省3-4小时,并会得到更好的结果。如果你没有认真作计划,那么实际上你正计划着失败。
6、每日计划。每日计划对于有效地利用个人时间是必不可少的,它应该于前一天下午或当天开始时制订出来,并与近期的目标和活动相一致。
7、目标。较有效的结果一般是通过对既定目标的刻意追求来达到的,而不是依靠机会。目标管理的基本概念就来源于这个已被证实的原则。
8、优先次序。应该按照优先次序对各项任务进行时间预算或分配。不同的是很多管理人员花费时间的数量往往与他们任务的重要性成反比。
9、最后时限。给自己规定最后时限并实行自我约束,持之以恒就能帮助管理者克服优柔寡断、犹豫不决和拖延的弊病。
10、集中。在人们有组织的努力中,少数关键性的努力(大约20%)通常能够产生绝大多数结果(大约80%)。这条原则也称为“20/80定律”。有效的管理人员,总是把他们的努力集中在能够产生重大结果的那些“关键性的少数活动上”。
11、效能与效率。假如执行的是错误任务的话,或者把任务放在错误的时间里去执行,以及毫无目的的行动,无论效率怎样高,最终都将导致无效的结果。效率可以理解为正确地做工作。效能可以理解为正确地做正确的工作。所谓有效的活动,就是指用最少的资源,包括时间,来得到最大的效果。
12、活动与效果。管理人员往往忽视目标,或者忘记预期的效果,而把精力完全集中在活动上。终日忙忙碌碌渐渐成为他们的目标。这些管理人员趋向于活动型而不是效果型。他们不是去支配工作,而是往往被工作所左右。他们把动机误作成就,把活动误作效果。
13、最佳效果。用最小的努力获得最大的收益,这就是最佳效果。
14、不切实际的时间预算。管理人员往往对完成任务所需要的时间抱乐观态度。他们也往往希望别人能够更快地完成任务。所以有了墨菲的第二定律“每件事情做起来都比原来想象的要多花时间”。可见,管理人员更倾向于自己接受和期望别人做出不切实际的时间预算。
15、实现的可能性。预期事件出现的可能性直接伴随实现它的有计划的努力而增加。
16、紧急任务专制。管理人员常常处于紧急任务与重要任务互相推挤的状态中。紧急任务要求立即行动,就使得他们没有时间来考虑重要任务。管理人员就是这样不知不觉地被紧急任务所左右,并承受着时间的无休无止的重压,这使他们忽视了搁置重要任务所带来的更为严重的长期的后果。
17、危机管理(反应过度)。管理人员往往低估问题,不善预料问题的复杂性,或者遇到所有问题都反应过度,彷佛碰到危机。这种危机管理和消防式工作的倾向往往造成过分忧虑,削弱判断力,导致仓促决策和浪费时间精力。
18、选择忽略(有限反应)。对各种问题和需求的反应要切合实际,并要受制于情况的需要。有些问题如果你置之不理,他们消失了。通过有选择地忽略那些可以自行解决的问题,大量的时间和精力就可以保存起来,用于更有用的工作。
19、机动性。安排个人时间的程度上应有机动性,以便于应付个人无法控制的力量。总之,时间安排不要过满,也不要过松。
20、问题分析。不区分问题的原因和现象,结果必然丢失实质性问题,而把时间和精力耗费在表面问题上。
2008/04/07
Intel Atom
Atom 处理器与 XScale 处理器不同,XScale 是一个基于ARM5 的高端智能手机以及PDA的处理器,它是一颗基于ARM架构的RISC处理器,在这单生意中 Intel 不过是一个购买了 ARM Ltd. 公司专利的生产商。而 Atom 的则是 Intel 自家的x86架构,在x86架构占据统治地位的PC领域,Intel可谓顺风顺水!这一次 Intel 利用自己 45nm的先进生产工艺, 把x86带入了 Mobile Internet Devices (MIDs) 领域。
于此相呼应的, Microsoft 已经延长了 Windows XP 的支持时间到 2010年, 这纯粹是为了 x86 的 MID 设备加料啊~~~
看看 Intel Atom 都带了些啥:
• Supports Hyper-Threading Technology 2-threads
• Support for IA 32-bit architecture
• Intel® Virtualization Technology (Intel® VT)
• Intel® Streaming SIMD Extensions 2 and 3 (Intel® SSE2 and Intel® SSE3) and Supplemental Streaming SIMD Extensions 3 (SSSE3) support
俨然是一个 Pentium4!
2008/04/02
Wireshark 1.0 released
2008/01/08
Oracle Database PL/SQL User's Guide and Reference
下回打印一份随身携带阅读!
BlockChain 相关电子书
@copyright of Sam Chadwick - https://thehub.thomsonreuters.com/groups/bitcoin/blog/2017/09/10/blockchain-paper Blockchain Papers A c...