What is Base64
Base64 is a simple code type for MIME to express any simbol to
64 printable letters: {'A'-'Z', 'a'-'z', '0'-'9', '+', '/'}the method is read 6 bit each time, and map in the 64 letters tables, fill blank with "=", at last we convert each 4 simbol to 3 simbol, since 6*4=8*3.
Introduction to Quartz
Quartz is an enterprise scheduler tool.
as we know, we use Timer or TimerJob in common java code. but some problem may be:
- time is not exact
- job lost if system has error
- not easy to configure
Quartz aims to provide a reliable lib to support, here is some sample code:
#
# Configure Main Scheduler Properties
#
org.quartz.scheduler.instanceName = TestScheduler
org.quartz.scheduler.instanceId = one
#
# Configure ThreadPool
#
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
org.quartz.threadPool.threadPriority = 4
#
# Configure JobStore
#
org.quartz.jobStore.misfireThreshold = 5000
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
and support persistent
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.tablePrefix = QRTZ_
#
# Configure Datasources
#
org.quartz.dataSource.myDS.driver = org.postgresql.Driver
org.quartz.dataSource.myDS.URL = jdbc:postgresql:dev
org.quartz.dataSource.myDS.user = dejanb
org.quartz.dataSource.myDS.password =
org.quartz.dataSource.myDS.maxConnections 5
and java code
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
public class QuartzTest {
public static void main(String[] args) {
try {
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
scheduler.shutdown();
} catch (SchedulerException se) {
se.printStackTrace();
}
}
}
For detail, we can find more document in http://www.opensymphony.com/quartz/
this is really simple and powerful
Some useful code, may be
a statement to get path of webapp
someclass.class.getResource("/").getPath().replace("%20", " ");
a class to build html from xml and xslt
XmlTranslationUtil.java
Do some thing with SWT
These day, i am doing a project for citi contest with some friends.
i am trying swt as ui for the whole days and want to make some useful tips here.
swt is a good library to ui development. unlike awt or swing, it appears just like windows. it is a part of eclipse by ibm and can do more things about local resource.
a useful feature is brought by SashForm. combined with CTabFolder, it provide a effect to maximum size like exlipse.
Some sample code:
to use ctabfolder
CTabFolder tabFolder1 = new CTabFolder(mainForm, SWT.BORDER);
tabFolder1.setSimple(false);
tabFolder1.setMaximizeVisible(true);
tabFolder1.setMinimizeVisible(false);
tabFolder1.setUnselectedCloseVisible(false);
tabFolder1.setSelectionBackground(new Color[] {
Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_BACKGROUND),
Display.getCurrent().getSystemColor(
SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT),
Display.getCurrent()
.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND) },
new int[] { 50, 100 }, true);
tabFolder1.setBorderVisible(true);
tabFolder1.setTabHeight(20);
{
tabItem1 = new CTabItem(tabFolder1, SWT.NONE);
tabItem1.setText("业务信息");
tabItem1.setToolTipText("业务信息");
}
the effect of color is good
to realized maximized
tabFolder1.addCTabFolder2Listener(new CTabFolder2Adapter() {
public void maximize(CTabFolderEvent e) {
sashForm.setMaximizedControl(mainForm);
tabFolder1.setMaximized(true);
}
public void restore(CTabFolderEvent e) {
if (mainForm == sashForm.getMaximizedControl()) {
sashForm.setMaximizedControl(null);
tabFolder1.setMaximized(false);
}
}
public void minimize(CTabFolderEvent e) {
sashForm.setMaximizedControl(mainForm);
mainForm.setData(1);
final ToolItem explore = new ToolItem(fastview, SWT.PUSH);
explore.setToolTipText("Explore");
explore.setImage(SWTResourceManager.getImage("resources/explore.gif"));
explore.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
sashForm.setMaximizedControl(null);
mainForm.setData(0);
explore.dispose();
}
});
}
});
tabFolder1.addMouseListener(new MouseAdapter() {
public void mouseDoubleClick(MouseEvent e) {
if (mainForm != sashForm.getMaximizedControl()) {
sashForm.setMaximizedControl(mainForm);
tabFolder1.setMaximized(true);
} else {
sashForm.setMaximizedControl(null);
tabFolder1.setMaximized(false);
}
}
});
remember, all things must be organized in SashForm as
sashForm = new SashForm(this, SWT.NONE);
mainForm=new SashForm(sashForm, SWT.HORIZONTAL);
How great the exlipse project is.
Recommand a artical about DSL by Flower
A great plan
Today, i asked friends whether there is some standard to value a opensource project. i have got some answer, but still some problem exists:
i know, OSI is responsible to give a certification for OS projects. but is looks to formal and not suitable for small projects.
Some site as sourceforge or open-open provide a platform to release projects. many people selects projects according the hits rate. it is obviously not good.
if we have organization to envalue a opensource project for others to reference, it is helpful in the way followed:
- some developer has a way to check his project and let more people to use
- everyone get a basic standard report for each project
but there is some condition:
we need experts in many fields
we need a standard to check the projects, including users, bugs, etc.
we want to start with small project, which is good and not used by many people
for other detail, i am just thinking. welcome to provide you idea about this plan to opensource.
Some steps in researching Weka
Weka contains many basic algrithm for data mining. i am doing some research of it by reading code and a book about it, in order to do a relative project. here, i'd like to share some achievement.
Firstly, my purpose for the project is to encupsulate the use of weka. but i just found it is difficult to do. as a project for a research tool, weka is good and powerful, but it is really hard to refactor. here is some factor:
- weka output the result it self. it is hard to print as i like until read the code and make some modification on source because some key member is private.
- weka provide many method to min data, but there is little relation between two kind of min, for example, association and classification. maybe they are different, but how can i intergrate them and provide a basic interface to use.
Even though the difficulties, i have tried to do some encupsulation as:

I just try to encupsulate three kind of mining.
A concreter class inheritate a support abstract class and implements a interface as a kind, which may define some basic method for the specific kind.
What i found difficult is that some reture type has to be Object because there is no common class among them.
A key code i think is in AnalyzeSupport:
public abstract class AnalyzeSupport {
protected String trainFileName;
protected Object analyzer;
public AnalyzeSupport(String file){
this.trainFileName=file;
}
public void analyze(){
try{
BufferedReader trainReader = new BufferedReader(new FileReader(trainFileName));
Instances train = new Instances(trainReader);
analyzer=this.buildAnalyzer(train);
trainReader.close();
}catch(Exception e){
e.printStackTrace();
}
}
public Object getAnalyzer(){
return this.analyzer;
}
public abstract Object buildAnalyzer(Instances instances) throws Exception;
}
Later, i may just use interface to operate the class of analyzer and need not to know what kind of algrithm i am using. i just need to use the result.
Scope
i am doing some research in one of theses subjects.
- Search Technology
- Google Desktop
- Weka
- P2P
- Eclipse
- Spring related
if anybody have experience or interest in them, welcome to communicate.
How dream will come true?
Everyone has his own dream, either great or little. The key is not itself, but the way to realization. If no affert is done, nothing will come true. Just thinking will draw nothing on your future.
I used not to want to talk about study or working on my own blog, which seems to serious and boring. Some day, i found some of my throught was wrong. Then i try to seperate them in different place, a place for interest and another for research sharing. They all can be found or accessed through the "ShuJIP Portal"--http://www.shujip.com/.
I choose google's blog to do research because it is most reasonable. Appearantly it looks simple and friendly just like me. More sincerely, i want to do something as greate as Google gave us. As i have mentioned, nothing will come true unless i do something. This is a right place to remind me, to communicate, to share.
To target @ Google.