2007-01-29
SQL2000不能安装的一个问题
修改注册表项:
到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager 删除PendingFileRenameOperations
这样就解决问题了。
2007-01-25
封闭回来的总结
下面都是我们在封闭的时候,我个人遇到的一些问题,希望大家再编码的时候,不要再遇到同样的错误而浪费精力和时间了。
1。在循环,线程的run方法里面,一定要注意小心使用new。可能出现的错误是:用新的对象覆盖了原来对象的值,所以你在外部代码里可能 得不到你预期的结果。我犯这样的错误,还不止一次啊。
2。在getXXX()方法后面,如果有可能返回null,一定要写if (xxx==null){},很多时候,总是不知道NullPointException从什么地方出来的,而基本都是从这个地方出来的。
3。关于异常,要是不是必须要显示给用户的异常信息,尽量在方法体里面搞定它,否则抛来抛去很是麻烦。选中一块需要处理异常的代码,按下atl + shift + z就可以自己生成了。
4。关于线程的终止。线程终止的stop和terminate都不用了。比较一般的方法是在线程里面设置一个标志表变量flag,在run方法里面可以这样写:if(!flag) { ...}需要退出线程时,给flag的setter设置false就行了。
5。关于初始化,类属性最好都初始化,在使用前判断是否为Null。对于String,最好初始化成""而不是Null,因为:String str = null; System.out.println("str=" + str);的结果不是你想象的空。
6。关于快捷键,建议大家看一下eclipse里面的快捷键,可以有效的提高编码效率,我自己常用的一些:
alt + /:用于自动补全。
例如:syso + alt + /,出来的结果会让你很高兴的。
自己可以在代码模块里面定义一些常用语句,很方便。
alt + shift + z:这个也很好,你不用再想那个红线只的是什么异常了。
alt + shift + j:这个在补注释的时候很有用。
ctrl + shift + f:格式化代码,也很有用。
最后一个不是快捷键,但是很有用:
右键-源代码-生成Getter和Setter。这个不用我多说了吧。
2007-01-22
奇怪的Gmail
Python VS Ruby
pi.rb
k, a, b, a1, b1 = 2, 4, 1, 12, 4
n=10000
time1 = Time.new
while n>0
# Next approximation
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
# Print common digits
d = a / b
d1 = a1 / b1
while d == d1
#print d
#$stdout.flush
a, a1 = 10*(a%b), 10*(a1%b1)
d, d1 = a/b, a1/b1
end
n-=1
end
time2 = Time.new
print (time2-time1).to_f
pi.py
from time import clock
k, a, b, a1, b1 = 2, 4, 1, 12, 4
time = clock()
n=10000
while n>0:
# Next approximation
p, q, k = k*k, 2*k+1, k+1
a, b, a1, b1 = a1, b1, p*a+q*a1, p*b+q*b1
# Print common digits
d = a / b
d1 = a1 / b1
while d == d1:
#print d,
a, a1 = 10*(a%b), 10*(a1%b1)
d, d1 = a/b, a1/b1
n-=1
print clock() - time
为了屏蔽IO操作对效率的影响,注释调了输出语句。
结果如下:
>ruby pi.rb
12.985
>Exit code: 0
>pythonw -u "pi.py"
12.405357027
>Exit code: 0
还是Python略胜一筹。
2007-01-19
初识Python
看ruby的时候,总是觉得难得入门,毕竟它从perl继承了太多的东西,而我对perl又没有接触过,对有些语法和用法总是没有感觉,看了Python,觉得简直是精简版的Java,C++或者C#,简单的语法,很容易入门。
毕竟,这个是Google推崇的第一脚本语言。
如果是简单的脚本工作,用这个做确实不错,相比别的脚本语言,代码简单的多。(那种变态的写代码的方式不算)
下面是我找到的一些资源:
简单Python教程
相对很多step into,快速,入门等教程,这个真的是经典,所以能在半天内使人掌握Python的概况。
开发环境(Eclipse)如果用eclipse,这个不错
EXE版(windows)如果单独使用,推荐这个,功能的确不错,用delphi做的,免费且开源。
有了这些资源,再去下一个Python的发行版,就可以使用了。
violet导出图片问题
为此,昨天又装上了jdk1.5,发现问题解决了。不知道是jdk1.6的问题,还是violet代码的问题。
修改jar文件的打开方式:
>ftype jarfile="C:\Program Files\Java\jdk1.5.0\bin\javaw.exe" -jar "%l" %*
然后问题就解决了。
2007-01-17
养鱼游戏之:Goldfish
Goldfish Family: Cyprinidae, Carps and Minnows view all from this family Description To 16" (41 cm); 3 1/2 lbs (1.6 kg). Robust; usually olive, but can vary to gold, orange, or creamy-white; fins similar color; young may have dark blotches. No barbels. Dorsal fin with 1 heavy, serrated spine, 15-18 branched rays; anal fin with 1 heavy, serrated spine, 5-6 rays; caudal peduncle deep, short. Lateral line complete, 27-31 scales. Related Species Common Carp (Cyprinus carpio )has 2 pairs of barbels on upper lip and 32-39 smaller lateral line scales. Range Introduced in warmer waters of S. Canada, United States, and Mexico. Discussion Goldfishes are native tod China. They tolerate extreme temperatures (0-degrees to 41-degrees C) and low levels of dissolved oxygen, but are usually found in warmer waters where winters are not severe. Goldfish and Common Carp hybridize, making identification difficult. Since large populations of Goldfish can suppress native fishes, they should not be released into the wild. |
养鱼游戏之:Ram Cichlid
Ram Cichlid �C Mikrogeophagus ramirezi
The ram cichlid comes from Venezuela and Columbia. In the wild they prefer slow moving clear plant-rich water.
Maximum Size: The maximum length is 2.0 inches. The female has a crimson belly and the male has longer dorsal fins.
Minimum Tank Size: 10 gallons or larger tank is appropriate.
Care Level: The ram cichlid is a relatively easy fish to maintain. On a scale of 1 �C10, (10 being easy) it would rate a "7".
Tank Conditions: Temperature 79 - 83��F; pH: 4.5 �C 7.5.
Color: The ram cichlid is a good looking freshwater fish. As its picture illustrates the coloration varies with blotches, stripes and colorful specs.
Temperament: The ram cichlid is not aggressive and should be kept in a tank that has similar temperament.
Diet: Omnivore - will take a varied diet of flaked foods, and small live freshwater shrimp, larvae etc. They should be fed 1 time each day. High quality vitamin enriched foods should be fed several times each week.
Habitat: Provide with live plants rocks, roots etc. Keep water movement low since this is a species that prefer quiet water.
Compatibility: Ram cichlid in general can be kept with most other species that can handle the ph and temperature requirements. It is generally a peaceful fish. It is best to keep in at least pairs and or small groups.
Remember that as you look to add more fish to a tank, you will need to increase the tank size. As with all aquarium setups, whether it is fresh or salt, consideration needs to be given to the maintenance of water quality. Too many fish can result in poor water quality that can stress and even kill our fish.
2007-01-16
为Opera添加“Post to delicious”
利用Opera强大的菜单定制功能,实现起来比自己想象的还要容易。
1、找了一个post to delicious的javascript,获得了delicious的api
2、在Opera的用户菜单定制中,写下代码:
Item, "Del.icio.us" = Go to page,"javascript:window.open(' http://del.icio.us/tinylee?v=3&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'');
这样就完成了这个功能的添加。其中tinylee是我在delicious的帐号。
近一段时间google也推广其bookmark服务,感觉起来和本地使用收藏夹一样,方便了不少。可惜网上关于其api的文档不多。
等有了相关的文档,把它也加进去。
另:发现养鱼中最快捷的赚钱方式就是养金鱼,生长快,生育快,而且不打架。现在我只养它了。
2007-01-15
(转)论读书--王佐良 译
读书足以怡情,足以傅彩,足以长才。其怡情也,最见于独处幽居之时;其傅彩也,最见于高谈阔论之中;其长才也,最见于处世判事之际。
练达之士虽能分别处理细事或一一判别枝节,然纵观统筹,全局策划,则舍好学深思者莫属。读书费时过多易惰,文采藻饰太盛则矫,全凭条文断事乃学究故态。
读书补天然之不足,经验又补读书之不足,盖天生才干犹如自然花草,读书然后知如何修剪移接,而书中所示,如不以经验范之,则又大而无当。
有一技之长者鄙读书,无知者羡读书,唯明智之士用读书,然书并不以用处告人,用书之智不在书中,而在书外,全凭观察得之。
读书时不可存心诘难读者,不可尽信书上所言,亦不可只为寻章摘句,而应推敲细思。
书有可浅尝者,有可吞食者,少数则须咀嚼消化。换言之,有只需读其部分者,有只须大体涉猎者,少数则须全读,读时须全神贯注,孜孜不倦。书亦可请人代读,取其所作摘要,但只限题材较次或价值不高者,否则书经提炼犹如水经蒸馏,淡而无味。
读书使人充实,讨论使人机智,笔记使人准确。因此不常做笔记者须记忆力特强,不常讨论者须天生聪颖,不常读书者须欺世有术,始能无知而显有知。
读史使人明智,读诗使人灵秀,数学使人周密,科学使人深刻,伦理学使人庄重,逻辑修辞之学使人善辩;凡有所学,皆成性格。
人之才智但有滞碍,无不可读适当之书使之顺畅,一如身体百病,皆可借相宜之运动除之。滚球利睾肾,射箭利胸肺,慢步利肠胃,骑术利头脑,诸如此类。如智力不集中,可令读数学,盖演题需全神贯注,稍有分散即须重演;如不能辩异,可令读经院哲学,盖是辈皆吹毛求疵之人;如不善求同,不善以一物阐证另一物,可令读律师之案卷。如此头脑中凡有缺陷,皆有特效可医。
Opera的一个小游戏
需要注意的是,只有两种同样的鱼才可以生小鱼。而且,越好的环境,生小鱼的速度越快。当然,搭建那个环境的费用也越高。下面是我的水族箱的截屏:好多金鱼啊。
我的鱼缸
2007-01-06
System.getProperties
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory