显示标签为“软件技术”的博文。显示所有博文
显示标签为“软件技术”的博文。显示所有博文

4/02/2009

解决Python IDLE启动失败的问题

Python3.1 是3月份刚release的,装在vista上后,报如下错误信息:

IDLE's subprocess didn't make connection.Either IDLE can;t start a subprocess or personal firewall software is blocking the connection

临时解决方式:
在目录C:\Python31\Lib\idlelib下,找到PyShell.py
找到下面这行:
use_subprocess = True
改为:
use_subprocess = False

然后删除同一个目录下的PyShell.py的compile文件.
重新启动后,IDLE顺利打开,但是No SubProcess.

Read more...

4/01/2009

BLOGGING SHOULDN’T BE “A MONOLOGUE" ????

很难改变.第二点很多人都不同意:

1. It's normal one comment per 100 views

2. we can't comment anonymously

3. the content of blogs are not easy to comment :) I mean, if you just say "yeah, it's fine today", then we readers have no comments

4. technology related blogs always get few comments.
but " technology trends" blog which updated frequently will get comments. (you may consider such kind of blog)

5. Maybe internal blog need advertise accors ericsson , most of people in our department even don't know :)

6. telecom blog is hard to get comment, I mean not only in ericsson, blogs that talks about telcom technology throughout the world meet the same problem. This is because of the telecom knowledge, telecom knowledge is not changing as fast as other computer technology. So sometimes not fast changing means "no comments", means " yeah, it is".

7. Internal blog is not attractive, if the blog open to external, I will migrate my blog here too :)
And if it support Wordpress, it's great !

Read more...

Creative Commons

Creative Common 是一个非盈利性的组织. 这个组织免费提供工具给全世界的从事创造性工作的人们.一个类似free software的组织.
已经有很多书用的是 creative common copyright.

Share, Remix, Reuse — Legally

什么是Creative Commons ?
http://creativecommons.org.au/materials/whatiscc.pdf

Read more...

3/29/2009

Big idea

An interesting idea suddenly come into my brain, While I am copy and paste the code.This is an idea about search engine and SNS. I do undoubtedly believe the idea will come ture in the near future as "clound" deployed more widely. Invoation product always means investment and technology, and most important your tough heart.
It's a great opportunity if you can earliest bring innovation product into use. I'd like to work with talent guys on such kind of innovation.

Read more...

3/12/2009

BlogSpot上传模板时bx-****错误的解决方式

1. 打开新模板XML文件

2. 查找所有 widget id

3.把 b:widget id='Anything1' 改成b:widget id='Anything11'
这里 Anything指任何名字。
比如"b:widget id='Header1'" 改成 "b:widget id='Header11'"

记住一定要改成2位数字

4. 然后重新上传模板就可以了

Read more...

2/10/2009

判定是否是素数

最normal的方式:
[coolcode lang="C++" linenum="off"]
int is_prime(int n) {
for (int i=2; i<=(int) sqrt(n); i++) if (n%i == 0) return 0;
return 1;
}
void main() {
int i,count=0;
for (i=1; i<10000; i++) count += is_prime(i);
printf("Total of %d primes\n",count);
}
[/coolcode]

改进一点,只要判断到N的开方:
[coolcode lang="C++" linenum="off"]
int is_prime(int n) {
long lim = (int) sqrt(n);
for (int i=2; i<=lim; i++) if (n%i == 0) return 0; return 1;}
[/coolcode]

调用sqrt()方法不够快速,直接用一下代码replace:
用JAVA做测试,下面这个方法在计算100000内质数时,比上面方法快16毫秒。
我的机器性能可能比较低,但是能说明这个算法确实比上面那种快!
[coolcode lang="C++" linenum="off"]
int is_prime(int n) {
for (int i=2; i*i<=n; i++) if (n%i == 0) return 0;
return 1;
}
[/coolcode]

更快一点,我们不用检测偶数因子:
[coolcode lang="C++" linenum="off"]
int is_prime(int n) {
if (n == 1) return 0; // 1 is NOT a prime
if (n == 2) return 1; // 2 is a prime
if (n%2 == 0) return 0; // NO prime is EVEN, except 2
for (int i=3; i*i<=n; i+=2) // start from 3, jump 2 numbers
if (n%i == 0) // no need to check even numbers
return 0;
return 1;
}
[/coolcode]

最高效的算法,列出L和U之间所有素数:
[coolcode lang="C++" linenum="off"]

void sieve(int L,int U) {
int i,j,d;
d=U-L+1; /* from range L to U, we have d=U-L+1 numbers. */
/* use flag[i] to mark whether (L+i) is a prime number or not. */
bool *flag=new bool[d];
for (i=0;ifor (i=(L%2!=0);i/* sieve by prime factors staring from 3 till sqrt(U) */
for (i=3;i<=sqrt(U);i+=2) {
if (i>L && !flag[i-L]) continue;
/* choose the first number to be sieved -- >=L,
divisible by i, and not i itself! */
j=L/i*i; if (jif (j==i) j+=i; /* if j is a prime number, have to start form next
one */
j-=L; /* change j to the index representing j */
for (;j}
if (L<=1) flag[1-L]=false;
if (L<=2) flag[2-L]=true;
for (i=0;icout << endl;
}
[/coolcode]

Read more...

9/25/2008

Python--回文数

取得大于某个数的最小回文数字:
[coolcode lang="python"]
import sys
def palin(num):
num_int=int(num)
length=len(num)-1
if(num_int ==10**length-1):
num_int=10**length
num=str(num_int)
length=len(num)
max=0
for i in xrange(length):
max+=9*(10**i)
split_index=length/2
a=[]
for t in xrange(num_int,max+1):
t_str=str(t)
for i in xrange(split_index):
a.append(t_str[i]==t_str[length-i-1])
a=filter(None,a)
if(len(a)!=split_index):
a=[]
else:
return t

def main():
n = int(sys.stdin.readline())
a=[None]*n
for i in xrange(n):
num =sys.stdin.readline()
a[i]=num
for i in xrange(n):
para=a[i].replace('\n','')
p=palin_2(para)
print p
main()
[/coolcode]
这个方法的取值范围是int型

Read more...

9/22/2008

python中的list----切片

切片 是一个非常有用的概念,其一般形式为 l[start:end:step],其中 start 和 end 分别是开始和结束索引,step 是在切片时要跨过的条目数量。此外,还可以对结束索引使用负值,即从序列的结尾往回计数。另一个有用的功能是以一种很合适的方式处理错误(如超过序列的长度)。
示例code如下:

Read more...

9/21/2008

Python和JAVA 速度比较一例

接上次的素数判断问题,python的速度令人不敢恭维:
算法:查找1000000内有多少个素数的最“朴素”的算法。
说明:查找1000000内是因为,时间....

Read more...

为什么我的算法超时,而那个算法比我慢还能accepted ?

学习python,写算法熟悉熟悉语法,发现一个问题,百思不得其解.....

题目:
来源:http://www.proj.pl
Problem code: PRIME1

Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers!

Read more...

9/04/2008

软件的盈利模式

软件业飞速发展,但是在一个盗版横行的国度,一些个人或者小团队的软件作者如何才能获得收益呢?本文在网上搜集了一些资料,罗列了一些软件的盈利模式,以供参考。

盘点一:软件盈利,注册先行

模式一:要使用吗,先交费(Come-Pay-Stay)
在过去,“先付钱后使用”曾经是国内软件的主要盈利模式。尽管这种模式方便简单,但它难以理直气壮地成为盈利妙方,因为先付钱后使用,把风险留给了消费者。消费者的购买行为取决于对品牌的认识。
一般来说,这种方式适用于品牌形象好,知名度高的商业软件,如Office系列软件。

模式二:来吧,玩得喜欢再付费(Come-Stay-Pay)
“先试用后付费”,免费给用户下载试用版本,在未付费前,软件有一定的时间、次数、功能等限制。
这种模式源于一个“省钱、懒得费心”的市场推广策略。1982年,两位美国软件作者,开发了一大软件,却不想为软件的推广花费太多的金钱和精力,所以采 取了一种新颖的推销方式,利用BBS发行软件,并允许用户拷贝,但在拷贝过程中需要给软件作者支付费用。于是,“先试用后购买”模式就这样诞生了。先请用户体验,满意了再购买的方式,解决了“先付费后使用”模式如何给用户足够的购买信心问题。这种模式在过去很长一段时间很受欢迎,是软件的主流盈利模式。譬如,在10年前已经非常风靡的软件豪杰超级解霸、Netants、优化大师。 但在国内,与注册收费模式形影相伴的,是数不清的破解和盗版行为,同时受到国内用户购买力匮乏、正版意识不浓等因素的制约,注册收费模式在盈利面前,变得苍白无力。

Read more...

8/26/2008

用JAVA操作ClearCase

本文关注怎么用JAVA处理ClearCase(ClearCase是rational公司开发的配置管理工具,了解详情点这里).在了解了怎么用JAVA.LANG.RUNTIME以后,主要的事情还是输入输出流,同步,以及字符串的处理.
下面这段代码演示了如何调用ClearCase的命令行:
[coolcode,lang="java",linenum="off"]
public String exec(String command) throws IOException {
Process process = Runtime.getRuntime().exec(command);

StringWriter outWriter = new StringWriter();
StringWriter errWriter = new StringWriter();
ProcessOutputReader outReader = new ProcessOutputReader(
process.getInputStream(),
outWriter);
ProcessOutputReader errReader = new ProcessOutputReader(
process.getErrorStream(),
errWriter);

Thread outReaderThread = new Thread(outReader);
Thread errReaderThread = new Thread(errReader);
outReaderThread.start();
errReaderThread.start();

synchronized (outReaderThread) {
if (outReaderThread.isAlive()) {
try {
outReaderThread.wait();
} catch (InterruptedException ie) {}
}
}
synchronized (errReaderThread) {
if (errReaderThread.isAlive()) {
try {
errReaderThread.wait();
} catch (InterruptedException ie) {}
}
}

String out = outWriter.toString();
String err = errWriter.toString();

return out
+(out.length() > 0 && err.length() > 0 ? "\n":"")
+err;
}
[/coolcode]
其中ProcessOutputReader类的定义:
[coolcode,lang="java",linenum="off"]
class ProcessOutputReader implements Runnable {
private InputStream _readFrom;
private Writer _writeTo;
ProcessOutputReader( InputStream readFrom, Writer writeTo) {
_readFrom = readFrom;
_writeTo = writeTo;
}
public void run() {
InputStreamReader bir = new InputStreamReader( _readFrom );
char[] ca = new char[100];
int numRead = 0;while ( numRead != -1 ) {

try {
numRead = bir.read(ca);
if ( numRead > 0 ) {
_writeTo.write(ca, 0, numRead);
}
} catch ( IOException e ) {
numRead = -1;
}
}
}
}
[/coolcode]
调用以上的方法:
[coolcode,lang="java",linenum="off"]
public static void main(String[] args) throws Exception {
RuntimeExec re = new RuntimeExec();
String result = re.exec("cleartool ls -s /XX/XX/XX...");
String result1=re.exec("cleartool lsvtr -g /XX/XX/XX...");
System.out.println(result);
System.out.println(result1);
}
[/coolcode]
上面代码的几点说明:
1.Runtime.getRuntime().exec(command) 通过JAVA提供的Runtime直接运行ClearCase的命令.Runtime是JAVA提供的,用于当前应用程序和运行环境交互,getRuntime()方法返回的就是当前Runtime实例.
2./XX/XX/XX... 代表目标文件夹或者文件.
3.cleartool lsvtr -g这个ClearCase命令可以打开图形界面.

如果想要获得Config Spec(不知道什么是Config Spec?点击这里了解),则应该这样调用:
[coolcode,lang="java",linenum="off"]
String catcs = re.exec("cleartool catcs");
[/coolcode]
在取得Config Spec后,剩下的都是字符串操作.

Read more...

8/07/2008

JAVA项目中常用开源包

本文介绍一些在JAVA项目中几乎必不可少的开源包.包括XML处理,测试,日志等方面.

Read more...

7/25/2008

创意投资方向

美国风险投资机构Y Combinator合伙人、知名天使投资人Paul Graham日前撰文,首次透露了Y Combinator愿意进行投资的30大创意。他的看法或许代表了硅谷风投机构的普遍看法.

1.解决版权纠纷的方法

由索尼和环球提起的音乐版权诉讼不仅给文件共享软件的发展造成障碍,也破坏了自己的业务模型。目前的局面决不是最终的解决方案。除了音乐,电影行业未来也将面临类似问题。

Read more...

7/14/2008

Endo-Testing: Unit Testing with Mock Objects

1.Introduction

Unit testing is a fundamental practice in Extreme Programming , but most nontrivial
code is difficult to test in isolation. You need to make sure that you test one feature at a
time, and you want to be notified as soon as any problem occurs. Normal unit testing is hard
because you are trying to test the code from outside.

Read more...

7/11/2008

XML元数据交换开源工具-------ArgoUML

ArgoUML was conceived as a tool and environment for use in the analysis and design of object-oriented software systems. In this sense it is similar to many of the commercial CASE tools that are sold as tools for modeling software systems. ArgoUML has a number of very important distinctions from many of these tools.

1. It is free.

2. ArgoUML draws on research in cognitive psychology to provide novel features that increase productivity
by supporting the cognitive needs of object-oriented software designers and architects.

3. ArgoUML supports open standards extensively - UML, XMI, SVG, OCL and others.

4. ArgoUML is a 100% pure Java application. This allows ArgoUML to run on all platforms for
which a reliable port of the Java2 platform is available.

5. ArgoUML is an open source project. The availability of the source ensures that a new generation of
software designers and researchers now have a proven framework from which they can drive the
development and evolution of CASE tool technologies.

Read more...

7/09/2008

CruiseControl

CruiseControl is a framework for a continuous build process. It includes, but is not limited to, plugins for email notification, Ant, and various source control tools. A web interface is provided to view the details of the current and previous builds.

CruiseControl is distributed under a BSD-style license and is free for use. CruiseControl adheres to an open source model and therefore makes the source code freely available.

CruiseControl is maintained and developed by a group of dedicated volunteers.

What is Continuous Integration?
Continuous Integration by Martin Fowler and Matthew Foemmel.

An important part of any software development process is getting reliable builds of the software. Despite its importance, we are often surprised when this isn't done. We stress a fully automated and reproducible build, including testing, that runs many times a day. This allows each developer to integrate daily thus reducing integration problems.

Overview
CruiseControl is composed of 3 main modules:

the build loop: core of the system, it triggers build cycles then notifies various listeners (users) using various publishing techniques. The trigger can be internal (scheduled or upon changes in a SCM) or external. It is configured in a xml file which maps the build cycles to certain tasks, thanks to a system of plugins. Depending on configuration, it may produce build artifacts.
the legacy reporting allows the users to browse the results of the builds and access the artifacts
the dashboard provides a visual representation of all project build statuses.
This modularity allows users to install CruiseControl where it will best fit their needs and environment.

Using remoting technologies (HTTP, RMI), it is possible to control and monitor the CruiseControl build loop. Those are turned off by default for obvious security reasons.

CruiseControl can be installed from source, or using the all in one binary installation

Read more...

5/28/2008

四种语言的unicode处理简述

本文讲述了在JAVA, Perl, Python, Ruby语言中,unicode的处理

Read more...

4/23/2008

Sun Tutorial:JAVA中的 I/O 流

这是Sun网站上关于JAVA I/O流的学习指南.



1.Byte streams should only be used for the most primitive I/O.
So why talk about byte streams? Because all other stream types are built on byte streams.All byte stream classes are descended from InputStream and OutputStream.
File I/O byte streams: FileInputStream and FileOutputStream.

2.The Java platform stores character values using Unicode conventions. Character stream I/O automatically translates this internal format to and from the local character set. In Western locales, the local character set is usually an 8-bit superset of ASCII.
[separator]
3.If internationalization isn't a priority, you can simply use the character stream classes without paying much attention to character set issues. Later, if internationalization becomes a priority, your program can be adapted without extensive recoding.

4.All character stream classes are descended from Reader and Writer. As with byte streams, there are character stream classes that specialize in file I/O: FileReader and.

5.Most of the examples we've seen so far use unbuffered I/O. This means each read or write request is handled directly by the underlying OS. This can make a program much less efficient, since each such request often triggers disk access, network activity, or some other operation that is relatively expensive.

6.Buffered input streams read data from a memory area known as a buffer; the native input API is called only when the buffer is empty. Similarly, buffered output streams write data to a buffer, and the native output API is called only when the buffer is full.

7.There are four buffered stream classes used to wrap unbuffered streams: BufferedInputStream and BufferedOutputStream create buffered byte streams, while BufferedReader and BufferedWriter create buffered character streams.

8.It often makes sense to write out a buffer at critical points, without waiting for it to fill. This is known as flushing the buffer. To flush a stream manually, invoke its flush method. The flush method is valid on any output stream, but has no effect unless the stream is buffered.

9.The scanner API breaks input into individual tokens associated with bits of data.By default, a scanner uses white space to separate tokens. The formatting API assembles data into nicely formatted, human-readable form.

10.Scanner also supports tokens for all of the Java language's primitive types (except for char), as well as BigInteger and BigDecimal. Also, numeric values can use thousands separators. Thus, in a US locale, Scanner correctly reads the string "32,767" as representing an integer value.

11.Stream objects that implement formatting are instances of either PrintWriter, a character stream class, and PrintStream, a byte stream class.

12.A program is often run from the command line and interacts with the user in the command line environment. The Java platform supports this kind of interaction in two ways: through the Standard Streams and through the Console.

13.The Java platform supports three Standard Streams: Standard Input, accessed through System.in; Standard Output, accessed through System.out; and Standard Error, accessed through System.err.

14.You might expect the Standard Streams to be character streams, but, for historical reasons, they are byte streams. System.out and System.err are defined as PrintStream objects. Although it is technically a byte stream, PrintStream utilizes an internal character stream object to emulate many of the features of character streams. By contrast, System.in is a byte stream with no character stream features. To use Standard Input as a character stream, wrap System.in in InputStreamReader.

15.A more advanced alternative to the Standard Streams is the Console. This is a single, predefined object of type Console that has most of the features provided by the Standard Streams, and others besides. The Console is particularly useful for secure password entry. The Console object also provides input and output streams that are true character streams, through its reader and writer methods.

Read more...

4/15/2008

在线转换成PDF文件

网站http://www.pdf24.org
可以把各种文本格式转换成pdf格式,并且把转换后的文件发到你的邮箱.

Read more...