Msys使用笔记

2008年1月13日 robertbao 没有评论

还是觉得在Windows下搭建仿Linux开发环境,Msys+MinGW的组合比Cygwin要好使。下面是我用Msys时的一些记录:

增加挂载点
d:/msys-1.0/etc/fstab

界面调整
修改d:/msys-1.0/etc/profile,在其末尾添加如下几行:
export PS1=’[\u@msys \W]$ ‘
export PS2=’> ‘
export PS4=’+ ‘
export LANG=en

alias l=’/bin/ls –show-control-chars –color=tty’
alias la=’/bin/ls -aF –show-control-chars –color=tty’
alias ll=’/bin/ls -alF –show-control-chars –color=tty’
alias ls=’/bin/ls –show-control-chars -F –color=tty’

修改字体
d:/msys-1.0/msys.bat
start rxvt -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-18 -tn msys -geometry 80×25 -e /bin/sh –login -i

修改背景
:startrxvt
rem Setup the default colors for rxvt.
if “x%MSYSBGCOLOR%” == “x” set MSYSBGCOLOR=White
if “x%MSYSFGCOLOR%” == “x” set MSYSFGCOLOR=Black
if “x%MINGW32BGCOLOR%” == “x” set MINGW32BGCOLOR=Black
if “x%MINGW32FGCOLOR%” == “x” set MINGW32FGCOLOR=White
if “%MSYSTEM%” == “MSYS” set BGCOLOR=%MSYSBGCOLOR%
if “%MSYSTEM%” == “MSYS” set FGCOLOR=%MSYSFGCOLOR%
if “%MSYSTEM%” == “MINGW32″ set BGCOLOR=%MINGW32BGCOLOR%
if “%MSYSTEM%” == “MINGW32″ set FGCOLOR=%MINGW32FGCOLOR%

分类: WORK 标签: , ,

Eclipse使用笔记

2007年12月2日 robertbao 没有评论

在工作中使用Eclipse有几年了,我写Java程序的主力IDE最初是JBuilder,中间数次切换到Netbeans和IDEA,最后稳定在Eclipse。使用Eclipse的过程中也不时会有bug出现,搞的人很恼火,但总体来说,Eclipse不失为一款伟大的IDE产品,无论在功能上还是构思设计上。在这里记录一些我使用Eclipse的笔记,对Eclipse掌握的越多,就越能体会到”develop with pleasure”。

eclipse_download.jpg

[Eclipse使用]

Eclipse安装
下载JEE版
设置JRE和Server Runtime
下载插件:CDT/viPlugin/jadclipse等
安装插件:link方式

调整设置
显示行号=General – text editors – line number
去除拼写检查=General – text editors – spelling
字体设置 = General – Appearance – colors and fonts
代码折叠=java – editor – folding
注释格式=java – code style – code templates – comments – type
去掉自动生成的todo=code templates – code
本地历史记录数加大
windows–preference-XDoclet的设置
锁定工具栏
team下ignore resources
修改Windows->Preferences->XML->XML Files->Editor,增加到118字符
Eclipse-java=Window-preference-java-code style-formatter每行增至118字符 (Line wrapping)
屏蔽编译警告
Window -> Preference -> Java -> Compiler -> Error/Warnings -> Generic types -> Unchecked generic type operation : 选Ignore
如果只是想在显示上屏蔽:
在Filters – Description里选doesn’t contain,然后在下面的输入框输入References to generic type 或 generic type或raw type之类的关键字就可以了

帮助中最重要的
提示与技巧
键绑定
代码模板--首选项-java-编辑器-模板

搭建C开发环境
下载Eclipse CDT插件
安装C开发环境

  1. Download and run the MinGW setup program, MinGW-5.1.3.exe.
  2. Select download and install the MinGW base tools and the g++ compiler. You may select the Current or Candidate version of these tools. You may also install any of the other available compilers as well.
    Do not install the MinGW Make feature as the MSYS version of make from step 5 is a more complete implementation of make.
  3. The MinGW setup program currently does not install the gdb debugger. To install the debugger, download the file from the following location: gdb-6.6.tar.bz2
  4. Extract the contents of the file gdb-6.6.tar.bz2 to the same location where you installed MinGW.
  5. If you want to use Makefile projects, download and run the setup program from the following location: MSYS-1.0.10.exe. MSYS provides an implementation of make and related command line tools. This is not required for other types of projects with the MinGW toolchain, which use CDT’s internal build tools to perform the build.

在Eclipse中建立外部make项目,用MSYS中的make,gcc、gdb用MinGW中的
修改build directory为${workspace_loc:/项目名}

Eclipse卸载
1、备份workspace中.metadata文件夹
2、备份myPlugin和links文件夹
3、备份configuration文件夹
4、在Eclipse中导出个人配置

[Eclipse技巧]

Eclipse提速
1.取消系统的自动折叠
操作方法:
Window->Preferences->Java->Editor->Folding tab.
2.关闭不常用的工程。
一些不常用的工程打开的时候,也会影响你正在使用工程的操作速度。
3.设置启动参数
-vmargs -Xverify:none -Xms512M -Xmx1024M -XX:PermSize=128M -XX:MaxPermSize=256M -XX:+UseParallelGC

Tab键设置
UE=高级-设置-编辑器-自动换行/制表符设置
Eclipse-java=Window-preference-java-code style-formatter
Eclipse-text=Window-preference-General-Editors-Text Editors
Eclipse-xml=Window-preference-xml-xml files-Editor
Eclipse-ant=Windows=prefernce-Ant-Editor-Formatter

其他技巧
可以复制粘贴项目
首选项-java-编辑器-代码辅助--补全时填充自变量名
Enter键--字符串回绕
通过从进程或调试目标的上下文菜单中选择属性,可以看到命令行

[Eclipse快捷键]

eclipse_assist.jpg

在Eclipse中使用快捷键能够大大提高工作效率,Eclipse也列出了它的全部快捷键,估计有上百个之多,当然我们在工作中记住常用的1、20个就足够用了。

分类: WORK 标签: ,

我的Antfile模板

2007年6月26日 robertbao 没有评论

下午有点时间,整理了一下最近几个项目使用的Antfile,并参考了spring源代码中Antfile的格式,形成一个模板,以后就套用这个了。

不过还是更习惯使用Makefile的格式,xml看多了真是头晕~

[文件头]

1
2
<?xml version="1.0" encoding="UTF-8"?>
<project name="filemanager" basedir="." default="help">

[说明]

4
5
6
7
8
9
10
11
    <!-- ============================== -->
    <!-- 说明                           -->
    <!-- ============================== -->
    <description>
    ROBERTBAO - http://www.robertbao.com
    Copyright (C) 2006-2010 robertbao.com
    @Author: robertbao
    </description>

[环境变量]

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    <!-- ============================== -->
    <!-- 环境变量                       -->
    <!-- ============================== -->
    <property name="app.name" value="filemanager" />
 
    <property name="src.dir" value="${basedir}/src/" />
    <property name="bin.dir" value="${basedir}/WebContent/WEB-INF/classes" />
    <property name="lib.dir" value="${basedir}/WebContent/WEB-INF/lib" />
    <property name="war.dir" value="${basedir}/war" />
    <property name="doc.dir" value="${basedir}/javadoc" />
    <property name="db.dir" value="${basedir}/db" />
    <property name="junitreport.dir" value="${basedir}/junitreport" />
    <property name="junitxml.dir" value="${junitreport.dir}/xml" />
    <property name="junithtml.dir" value="${junitreport.dir}/html" />
    <property name="cobertura.dir" value="${basedir}/cobertura" />
    <property name="instrumented.dir" value="${cobertura.dir}/classes" />
 
    <property name="db.driver" value="com.mysql.jdbc.Driver" />
    <property name="db.url" value="jdbc:mysql://localhost:3306/${app.name}" />
    <property name="db.user" value="robertbao" />
    <property name="db.pw" value="robertbao123" />

[类加载路径]

35
36
37
38
39
40
41
42
43
44
45
    <!-- ============================== -->
    <!-- 类加载路径                     -->
    <!-- ============================== -->
    <path id="classpath">
        <pathelement location="${basedir}" />
        <pathelement location="${basedir}/WebContent/WEB-INF" />
        <pathelement location="${basedir}/WebContent/WEB-INF/classes" />
        <fileset dir="${lib.dir}">
            <include name="**/*.jar" />
        </fileset>
    </path>

[帮助]

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    <!-- ============================== -->
    <!-- 帮助                           -->
    <!-- ============================== -->
    <target name="help">
        <echo message="" />
        <echo message="${app.name} build file" />
        <echo message="------------------------------------------------------" />
        <echo message="" />
        <echo message="Available targets are:" />
        <echo message="" />
        <echo message="clean            --> Clean output dir" />
        <echo message="build            --> Compile main Java sources and copy libraries" />
        <echo message="javadoc          --> Create complete Javadoc documentation" />
        <echo message="warfile          --> Build the web application archive" />
        <echo message="setup-db         --> Initialize the database" />
        <echo message="junit-test       --> Junit test" />
        <echo message="cobertura-test   --> cobertura test" />
        <echo message="cobertura-check  --> cobertura check" />
        <echo message="junit-report     --> Junit report" />
        <echo message="cobertura-report --> cobertura report" />
        <echo message="report           --> Gen report" />
        <echo message="run              --> Run main class" />
        <echo message="jar              --> Build jar" />
        <echo message="all              --> Clean, build, javadoc, warfile, test" />
        <echo message="clean-ibatis     --> Clean ibatis dir" />
        <echo message="zip              --> Zip something" />
        <echo message="mail             --> Mail something" />
        <echo message="" />
    </target>

[清理环境]

77
78
79
80
81
82
83
    <!-- ============================== -->
    <!-- 清理环境                       -->
    <!-- ============================== -->
    <target name="clean" description="Clean output dirs (build, docs, testbuild, testreports, weblib, dist)">
        <delete dir="${bin.dir}" />
        <delete dir="${war.dir}" />
    </target>

[编译]

85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
    <!-- ============================== -->
    <!-- 编译                           -->
    <!-- ============================== -->
    <target name="build" description="Compile main source tree java files into class files, generate jar files">
        <mkdir dir="${bin.dir}" />
        <javac destdir="${bin.dir}" source="1.5" target="1.5" debug="true" deprecation="false" optimize="false" failonerror="true">
            <src path="${src.dir}" />
            <compilerarg line="-encoding UTF-8" />
            <classpath refid="classpath">
            </classpath>
        </javac>
        <copy todir="${bin.dir}" preservelastmodified="true">
            <fileset dir="${src.dir}">
                <include name="**/*.xml" />
                <include name="**/*.properties" />
            </fileset>
        </copy>
    </target>

[生成javadoc]

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
    <!-- ============================== -->
    <!-- 生成javadoc                    -->
    <!-- ============================== -->
    <target name="javadoc" description="Create complete Javadoc documentation">
        <delete dir="${doc.dir}" />
        <mkdir dir="${doc.dir}" />
        <javadoc sourcepath="${src.dir}" destdir="${doc.dir}" windowtitle="${app.name}" source="1.5" author="true" version="true" use="true" packagenames="*">
            <doctitle>
                <h1>${app.name}</h1>
            </doctitle>
            <bottom>
                <i>robertbao, 2006-2010.</i>
            </bottom>
            <classpath refid="classpath" />
        </javadoc>
    </target>

[打war包]

121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
    <!-- ============================== -->
    <!-- 打war包                        -->
    <!-- ============================== -->
    <target name="warfile" description="Build the web application archive">
        <mkdir dir="${war.dir}" />
        <war warfile="${war.dir}/${app.name}.war" basedir="${war.dir}" webxml="${war.dir}/WEB-INF/web.xml">
            <include name="*" />
            <include name="docs/**" />
            <include name="html/**" />
            <include name="styles/**" />
            <include name="images/**" />
            <include name="WEB-INF/*.*" />
            <exclude name="WEB-INF/web.xml" />
            <include name="WEB-INF/classes/*.*" />
            <include name="WEB-INF/lib/**" />
            <include name="WEB-INF/jsp/**" />
            <include name="WEB-INF/classes/META-INF/*" />
            <include name="META-INF/*" />
            <exclude name="**/.*" />
        </war>
    </target>

[数据库创建表]

143
144
145
146
147
148
149
150
151
152
153
154
155
156
    <!-- ============================== -->
    <!-- 数据库创建表                   -->
    <!-- ============================== -->
    <target name="db-create-table" if="useMYSQL">
        <echo message="Creating tables using: ${db.driver} ${db.url}" />
        <sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}" onerror="continue">
            <classpath>
                <fileset dir="${db.dir}/mysql">
                    <include name="mysql*.jar" />
                </fileset>
            </classpath>
            <transaction src="${db.dir}/create-table.sql" />
        </sql>
    </target>

[数据库插入表]

158
159
160
161
162
163
164
165
166
167
168
169
170
171
    <!-- ============================== -->
    <!-- 数据库插入表                   -->
    <!-- ============================== -->
    <target name="db-insert-table">
        <echo message="Populating tables using: ${db.driver} ${db.url}" />
        <sql driver="${db.driver}" url="${db.url}" userid="${db.user}" password="${db.pw}">
            <classpath>
                <fileset dir="${db.dir}/mysql">
                    <include name="mysql*.jar" />
                </fileset>
            </classpath>
            <transaction src="${db.dir}/insert-table.sql" />
        </sql>
    </target>

[创建数据库环境]

173
174
175
176
177
    <!-- ============================== -->
    <!-- 创建数据库环境                 -->
    <!-- ============================== -->
    <target name="setup-db" depends="db-create-table,db-insert-table" description="Initialize the selected database">
    </target>

[junit单元测试]

179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
    <!-- ============================== -->
    <!-- junit单元测试                  -->
    <!-- ============================== -->
    <target name="junit-test" description="Run tests using initialized database">
        <delete dir="${junitxml.dir}" />
        <mkdir dir="${junitxml.dir}" />
        <junit forkmode="perBatch" printsummary="true" haltonfailure="no" haltonerror="no">
            <classpath path="${bin.dir}" />
            <classpath refid="classpath" />
            <formatter type="xml" />
            <batchtest fork="yes" todir="${junitxml.dir}">
                <fileset dir="${bin.dir}">
                    <include name="**/*ActionTest.class" />
                    <exclude name="**/BaseActionTest.class" />
                    <exclude name="**/*SuiteTests.class" />
                </fileset>
            </batchtest>
        </junit>
    </target>

[cobertura任务定义]

199
200
201
202
    <!-- ============================== -->
    <!-- cobertura任务定义              -->
    <!-- ============================== -->
    <taskdef classpathref="classpath" resource="tasks.properties" />

[cobertura准备]

204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
    <!-- ============================== -->
    <!-- cobertura准备                  -->
    <!-- ============================== -->
    <target name="cobertura-instrument">
        <delete dir="${instrumented.dir}" />
        <mkdir dir="${instrumented.dir}" />
        <delete file="${basedir}/cobertura.ser"/>
        <cobertura-instrument todir="${instrumented.dir}">
            <ignore regex="org.apache.log4j.*" />
            <fileset dir="${bin.dir}">
                <include name="**/*.class" />
                <exclude name="**/T*Test.class" />
            </fileset>
        </cobertura-instrument>
        <copy todir="${instrumented.dir}" preservelastmodified="true">
            <fileset dir="${src.dir}">
                <include name="**/*.xml" />
                <include name="**/*.properties" />
            </fileset>
        </copy>
    </target>

[cobertura-junit单元测试]

226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
    <!-- ============================== -->
    <!-- cobertura-junit单元测试        -->
    <!-- ============================== -->
    <target name="cobertura-test" depends="cobertura-instrument" description="cobertura-test">
        <delete dir="${junitxml.dir}" />
        <mkdir dir="${junitxml.dir}" />
        <junit fork="yes" printsummary="true" haltonfailure="no" haltonerror="no">
            <classpath path="${instrumented.dir}" />
            <classpath path="${bin.dir}" />
            <classpath refid="classpath" />
            <formatter type="xml" />
            <batchtest todir="${junitxml.dir}">
                <fileset dir="${src.dir}">
                    <include name="**/T*Test.java" />
                </fileset>
            </batchtest>
        </junit>
    </target>

[cobertura检查]

245
246
247
248
249
250
    <!-- ============================== -->
    <!-- cobertura检查                  -->
    <!-- ============================== -->
    <target name="cobertura-check">
        <cobertura-check branchrate="34" totallinerate="100" />
    </target>

[junit报告]

252
253
254
255
256
257
258
259
260
261
262
263
264
    <!-- ============================== -->
    <!-- junit报告                      -->
    <!-- ============================== -->
    <target name="junit-report">
        <delete dir="${junithtml.dir}" />
        <mkdir dir="${junithtml.dir}" />
        <junitreport todir="${junithtml.dir}">
            <fileset dir="${junitxml.dir}">
                <include name="TEST-*.xml" />
            </fileset>
            <report format="frames" todir="${junithtml.dir}" />
        </junitreport>
    </target>

[cobertura报告]

266
267
268
269
270
271
272
273
274
275
276
    <!-- ============================== -->
    <!-- cobertura报告                  -->
    <!-- ============================== -->
    <target name="cobertura-report">
        <delete dir="${cobertura.dir}/xml" />
        <mkdir dir="${cobertura.dir}/xml" />
        <delete dir="${cobertura.dir}/html" />
        <mkdir dir="${cobertura.dir}/html" />
        <cobertura-report srcdir="${src.dir}" destdir="${cobertura.dir}/xml" format="xml"/>
        <cobertura-report srcdir="${src.dir}" destdir="${cobertura.dir}/html" />
    </target>

[junit+cobertura测试报告]

278
279
280
281
282
    <!-- ============================== -->
    <!-- junit+cobertura测试报告        -->
    <!-- ============================== -->
    <target name="report" depends="junit-report,cobertura-report">
    </target>

[运行主类]

284
285
286
287
288
289
290
291
    <!-- ============================== -->
    <!-- 运行主类                       -->
    <!-- ============================== -->
    <target name="run">
        <java classname="com.robertbao.base.quartz.ComQuartz" failonerror="true" fork="yes">
            <classpath refid="classpath" />
        </java>
    </target>

[生成jar包]

293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
    <!-- ============================== -->
    <!-- 生成jar包                      -->
    <!-- ============================== -->
    <target name="jar">
        <delete>
            <fileset dir="${basedir}">
                <include name="${app.name}.jar" />
            </fileset>
        </delete>
        <jar destfile="${basedir}/${app.name}.jar" manifest="${basedir}/WebContent/META-INF/manifest.mf">
            <fileset dir="${bin.dir}">
                <include name="**/*" />
            </fileset>
            <fileset dir="${basedir}/WebContent/WEB-INF">
                <include name="**/*.xml" />
                <exclude name="classes/hbm/*.xml" />
            </fileset>
            <manifest>
                <attribute name="Main-Class" value="com.robertbao.base.main.Run" />
            </manifest>
        </jar>
    </target>

[全部运行]

316
317
318
319
    <!-- ============================== -->
    <!-- 全部运行                       -->
    <!-- ============================== -->
    <target name="all" depends="clean,build,javadoc,warfile,junit-test" description="Clean,build,javadoc,warfile,junit-test" />

[清理ibatis自动生成代码]

321
322
323
324
325
326
327
328
    <!-- ============================== -->
    <!-- 清理ibatis自动生成代码         -->
    <!-- ============================== -->
    <target name="clean-ibatis" description="Clean ibatis dir">
        <delete dir="${src.dir}/com/robertbao/${app.name}/po/dbauto" />
        <delete dir="${src.dir}/com/robertbao/${app.name}/dao/dbauto" />
        <delete dir="${src.dir}/com/robertbao/${app.name}/sqlmap/dbauto" />
    </target>

[zip压缩]

330
331
332
333
334
335
336
337
338
    <!-- ============================== -->
    <!-- zip压缩                        -->
    <!-- ============================== -->
    <target name="zip">
        <tstamp>
            <format property="date" pattern="yyyyMMdd" />
        </tstamp>
        <jar jarfile="${basedir}/report${date}.zip" basedir="${junitreport.dir}" excludes="*.xml" />
    </target>

[发邮件]

340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
    <!-- ============================== -->
    <!-- 发邮件                         -->
    <!-- ============================== -->
    <target name="mail">
        <mail mailhost="smtp.gmail.com" mailport="465" user="" password="" subject="ant mail">
            <from address="robertb9527@gmail.com" />
            <to address="robertbao@robertbao.com" />
            <message>The ${app.name} nightly build has completed</message>
            <attachments>
                <fileset dir="${basedir}">
                    <include name="*.zip" />
                </fileset>
            </attachments>
        </mail>
    </target>

[文件尾]

356
</project>
分类: WORK 标签: ,

Word 2007中的书法字帖

2007年5月20日 robertbao 15 条评论

shufa.jpg

看到上面的书法字体了吗,比较帅吧,可别以为是我写的,我现在都不知道笔咋握了~~~

上面的字都是用Word 2007中的”书法字帖”功能写出来的,这项功能可以灵活地创建字帖文档,自定义字帖中的字体颜色、网格样式、文字方向等,然后将它们打印出来,就像小时候练字的字帖一样了。

具体创建过程很简单:

1、在”新建文档”对话框中选择”书法字帖”;

2、在”书法”选项卡中点击”增减字符”,在”书法字体”包含的11种类型列表中,选择要使用的字体类型;

3、单击”关闭”按钮,选择的字符就会添加到文档中,同时打开”书法”工具栏,可以进行各种颜色、样式方面的调整。

同时还可以选择”网格样式”,包括了常见的米字格、田字格等(怎么没有回宫格),这样打印出来,就可以像字帖一样进行书法练习了。

style.jpg

PS:只是现在每种字体的字库数量还比较少,数量最多的汉仪赵楷繁,也不过才2010个字,甚至比不上老徐的6000多字,这样就会有很多常用字找不到,期待Word以后的完善吧…

分类: PASTIME 标签: ,

效果不错

2007年5月20日 robertbao 5 条评论

collage.jpg


去年8月买的K800i,11月买的T60,用到今天依旧坚挺

K800i随手抓拍效果很好

T60狂打游戏也不算热

这些…我…很满意…

PS:一个同事刚买了Wii,最近有空玩了几次,真是太爽了…棒球、保龄、网球…还真有真实的感觉…唉,就是客厅小了点,都发挥不出来,玩的时候经常互相打到…真是个好的锻炼身体的东东…有搞一个的想法了…

分类: PASTIME 标签: , ,