2006/12/28

How to reset auto-increment column in MySQL

utilize this command: ALTER TABLE $table AUTO_INCREMENT = 1
ex. ALTER TABLE bugs.bugs AUTO_INCREMENT = 1

2006/12/11

Cannot enter X Window

# mount /mnt/cdrom
# cp /mnt/cdrom/ /tmp
# tar zxvf vmware-linux-tools.tar.gz
# cd 到vm開頭的目錄
# ./vmware-install.pl # startx

2006/06/30

The Five Variables of Project Management

Update: Picked up on a thread on TheServerSide, so there may be some more discussion over there.

In my experience (and more so that of my more experienced colleagues) there are five variables over which you can exert control to decide when – and with what functionality – you can deliver your software.

Scope

In simple terms, if you deliver less functionality, it will take you less time. The problem is that often the decision as to what not to deliver happens during the development process itself. This means that prioritisation of functionality from the outset is important. if half way through you need to cut scope, but the only stuff you have left is the stuff your users simply must have, and you spent the last three months delivering things they’d only like to have, your options are limited. Priorities can change, but core functionality tends not too – concentrate on delivering that and you’ll make it easier for yourself in the long run.

Time

Typically the thing over which technical people have the least control (anecdotally it seems as though the go-live date for software is defined more by sales and marketing than by need), but you can decide to deliver later to get what you want.

People

Adding more people to a project can make it faster – to a point. However in software adding people very rarely tends to result in a linear increase in productivity. Hiring the right people can be more efficient, but is far from easy.

Some organisations take the ‘lots of dumb people being told what to do by one or two smart people’ route, others the ‘a few smart people all knowing what to do’. I’m sure most of us (myself included) believe we hope for the later. I’ve certainly seen examples in the consultancy world where an organisation with a lower charge rate but lots of people ends up costing much more deliver than a small number of people with higher charge rates.

Process

Reworking one’s process in order to be more efficient is an obvious thing to do, but hard to achieve. Depending on the flexibility of your organisation changing your process might not be easy, even if you know what it is to change. Changes mid-project – for example in order to deliver faster – tend to be limited, small changes. Retrospecitves can be a good tool for identifying what the team thinks is required, but don’t discount seeking outside help – someone from another team might have a different take on things.

A far more common type of process change occurs when people make what is often claimed to be short-term sacrifices in terms of software quality to deliver on time. Changes could involve writing less developer tests, spending less time performing manual tests, stop pairing, or spend less time ensuring consistent technical vision. When these changes really are short-term, and time is set aside afterwards to repair the damage done, this may be a viable technique. However those organisations which tend to drop quality in order to deliver faster tend to use this technique more than any other, and frequently never spend time playing catch up – leading to a team spending most of their time running from one disaster to another.

Risk

Risk Management is something I’m personally becoming aware of. Making sure you have situations in which potential risks can be raised is important (a daily stand-up might be one). Periodically risks should be assessed, in terms of how likely they are to occur, and also in terms of how much damage they can create.

Some risks can be mitigated, some eliminated entirely, and others cannot be addressed by you. In any case once prioritised in terms of likelihood and potential damage, they can be mitigated or communicated to your business sponsor accordingly.

Ten things programmers might want to know about marketers

Seth Godin wrote up "Ten things programmers might want to know about marketers," trying to bridge the gap between the engineer and the marketing dork who spoils his effort. Quick summary: marketing is unrepeatable, and indeterminate.

The ten things are:
  1. Marketing is not rational. Programming is. Works the same way every time. Marketing doesn't, almost in a Heisenbergian way. If it worked before, it probably won't work again.
  2. Marketing is even more difficult to schedule than bug fixes. Marketing expenses are easily timed, of course, but the results are not. That's because there's a human at each end of the equation.
  3. Most marketers have no clue whatsoever what to do. So we do unoriginal things, or stall, or make promises we can't keep.
  4. Just because Sergey is both a brilliant programmer and a brilliant marketer doesn't mean that all brilliant programmers are good at marketing.
  5. People often prefer things that are inelegant, arcane or even broken. Except when they don't.
  6. Truly brilliant coding is hard to quantify, demand or predict. Same is true with marketing.
  7. There is no number seven.
  8. Unlike mediocre programmers, mediocre marketers occasionally get lucky. When they do, they end up with a success they can brag about for a generation. But that doesn't mean they know how to do it again.
  9. Just because some marketers are dorks doesn't mean your marketer is a dork. Some programmers aren't so great either. Be patient.
  10. Without marketing, all your great coding is worthless. Push your marketer to be brave and bold and remarkable. Do it every day. Your code is worth it.

2006/05/23

[Problem] Cannot Start OracleOraHome92Agent

Scenario
As we wanna start OracleOraHome92Agent service, it always cannot be initialized normally.


Root Cause

It's service internal error or windows internal


Solution

delete the *.q files which locate at %oracle_home%\network\agent

2006/05/05

SP2-0678: 資料欄或屬性類型無法經由 SQL*Plus 顯示

As I use sqlplus to do query, it showed the error message as belows:
SP2-0678: 資料欄或屬性類型無法經由 SQL*Plus 顯示
The sql statement is select * from projec2;

Owing to the column in this table include BLOB data, sqlplus cannot show the BLOB data so it will return this kind of error message.

2006/04/10

log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.ConvertUtils)

Whenever I start tomcat with MyEclipse, I see that following message on console. What is that mean? Should I do something? May be this is beyound the MyEclipse but I appreciate it if somone would tell me how I can fix this..


log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.ConvertUtils).
log4j:WARN Please initialize the log4j system properly.


No worries, its just a message from one of the libraries (Hibernate maybe) that you are using letting you know that Commons Logging will not use Log4J because it couldn't find aconfig file for it, so it will just log to the console or use the JDK's logger found in JDK 1.4+

If you do include a log4j config file in your classpath, Hibernate can optionally spit out more logging messages than any human may want, for example, if you are debugging complex code.


reference

2006/04/04

Dina Programming Font

Dina is a monospace bitmap font, primarily aimed at programmers. It is relatively compact to allow a lot of code on screen, while (hopefully) clear enough to remain readable even at high resolutions.

I made this font after having tried all the free programming fonts I could find. Somehow there was some detail in each of them that meant I couldn't work with them in the long run.

http://www.donationcoder.com/Software/Jibz/Dina/

2006/03/28

Simplify XML processing with VTD-XML

Summary
As the enabling technology for next-generation Web-based applications, XML is both easy and straightforward to learn and use. Unfortunately, the same thing cannot be said about the current state of XML processing: the Document Object Model and the Simple API for XML are both too slow, inefficient, and difficult to use. Providing a broadly useful and advanced option that goes beyond DOM and SAX, VTD-XML is the next-generation XML processing model that simplifies both XML programming and selection of an XML processing model. By highlighting some of the key technical strengths of VTD-XML using the latest performance benchmark numbers and code examples, this article demonstrates that VTD-XML has the potential to finally take the "monkey" off the back of enterprise architects constantly struggling with the decision of whether to use DOM or SAX.

http://www.javaworld.com/javaworld/jw-03-2006/jw-0327-simplify.html

2006/03/24

Log4j example

**here has four examples about how to utilize log4j.

the core of log4j is log4j.properties, we can do some configuration in this property files, including log message format, output file name, appender

setting and so on.

1. com.ptc.demo.log4j.module1.Module1Test: write log information to console
2. com.ptc.demo.log4j.module2.Module2Test: write log information to log files and rotate the log file by day
3. com.ptc.demo.log4j.module3.Module3Test: write log information to log files and rotate the log file by file size
4. com.ptc.demo.log4j.module4.Module4Test: write log information to log file (in HTML format)


---------------------
output message
---------------------
2006-03-24 13:50:03,015 DEBUG com.ptc.demo.log4j.module1.Module1Test.sortByAsc(Module1Test.java:26) - [ant, cat, dog, dophin, tiger, zebra]
2006-03-24 13:50:03,015 DEBUG com.ptc.demo.log4j.module1.Module1Test.sortByDesc(Module1Test.java:41) - [zebra, tiger, dophin, dog, cat, ant]



log4j.properties
=========================================================================
#module1 -- output to console
log4j.category.com.ptc.demo.log4j.module1=DEBUG,module1
log4j.appender.module1=org.apache.log4j.ConsoleAppender
log4j.appender.module1.layout=org.apache.log4j.PatternLayout
log4j.appender.module1.layout.ConversionPattern=%d %5p %l - %m%n


#module2 -- output to log and rotate by day
log4j.category.com.ptc.demo.log4j.module2=DEBUG,module2
log4j.appender.module2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.module2.threshold=debug
log4j.appender.module2.File=C:\module2.log
log4j.appender.module2.DatePattern='.'yyyyMMdd
log4j.appender.module2.Append=true
log4j.appender.module2.layout=org.apache.log4j.PatternLayout
log4j.appender.module2.layout.ConversionPattern=%d %5p %l - %m%n


#module3 -- output to log and rotate by file size
log4j.category.com.ptc.demo.log4j.module3=DEBUG,module3
log4j.appender.module3=org.apache.log4j.RollingFileAppender
log4j.appender.module3.threshold=debug
log4j.appender.module3.File=C:\module3.log
#rotate size = 500 KB
log4j.appender.module3.MaxFileSize=500KB
#keep three backup files
log4j.appender.module3.MaxBackupIndex=3
log4j.appender.module3.layout=org.apache.log4j.PatternLayout
log4j.appender.module3.layout.ConversionPattern=%d %5p %l - %m%n


#module4 -- output to log and by HTML format
log4j.category.com.ptc.demo.log4j.module4=DEBUG,module4
log4j.appender.module4=org.apache.log4j.FileAppender
log4j.appender.module4.File=C:\module4.html
log4j.appender.module4.Append=true
log4j.appender.module4.layout=org.apache.log4j.HTMLLayout
=========================================================================


class file (each class file has the same content and only has different class name)
=========================================================================
package com.ptc.demo.log4j.module1;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Collections;

import org.apache.log4j.Logger;

/**
*
* @author Albert
*
*/
public class Module1Test {

private static Logger logger = Logger.getLogger(Module1Test.class.getName());

/**
* sorting by ascending
* @param str
*/
public void sortByAsc(String str[]){
List list = Arrays.asList(str);
Collections.sort(list);
logger.debug(list);
}

/**
* sorting by descending
* @param str
*/
public void sortByDesc(String str[]){
List list = Arrays.asList(str);
Collections.sort(list, new Comparator(){
public int compare(Object obj1, Object obj2){
return ((String)obj2).compareTo((String)obj1);
}
}
);
logger.debug(list);
}

/**
* @param args
*/
public static void main(String[] args) {
Module1Test module1Test = new Module1Test();

String str[] = new String[]{"dog","ant","zebra","cat","tiger","dophin"};
module1Test.sortByAsc(str);
module1Test.sortByDesc(str);
}

}
=========================================================================

2006/03/23

Exception Handling

The following are some of the generally accepted principles of exception handling:

1. If you can’t handle an exception, don’t catch it.
2. If you catch an exception, don’t swallow it.
3. Catch an exception as close as possible to its source.
4. Log an exception where you catch it, unless you plan to rethrow it.
5. Structure your methods according to how fine-grained your exception handling must be.
6. Use as many typed exceptions as you need, particularly for application exceptions.


"Best Practices in EJB Exception Handling"
http://www-106.ibm.com/developerworks/java/library/j-ejbexcept.html

"Best Practices for Exception Handling"
http://www.onjava.com/pub/a/onjava/2003/11/19/exceptions.html

"Designing with Exceptions"
http://www.javaworld.com/jw-07-1998/jw-07-techniques.html

"Exceptions in Java"
http://www.javaworld.com/jw-07-1998/jw-07-exceptions.html

"Exceptional Practices, Part 1"
http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html

"Exceptional Practices, Part 2"
http://www.javaworld.com/javaworld/jw-09-2001/jw-0914-exceptions.html

"When catching exceptions, don't cast your net too wide"
http://www.javaworld.com/javaworld/javatips/jw-javatip134.html

"Use nested exceptions"
http://www.javaworld.com/javaworld/javatips/jw-javatip91.html

"Beware the dangers of generic exceptions"
http://www.javaworld.com/javaworld/jw-10-2003/jw-1003-generics.html

[Info] Abator: code generator for iBATIS

Abator is a code generator for iBATIS. Abator will introspect a database table (or many tables) and will generate iBATIS artifacts that can be used to access the table(s). This lessens the initial nuisance of setting up objects and configuration files to interact with database tables. Abator seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for custom queries, or stored procedures.


http://ibatis.apache.org/abator.html

2006/03/14

Plug memory leaks in enterprise Java applications

Strategies for detecting and fixing enterprise memory leaks

Summary
Because Java uses automatic garbage collection, developers think Java programs are free from possible memory leaks. Although automatic garbage collection solves the main cause of memory leaks, they can remain in a Java program. Specifically, such memory leaks in complex multitiered applications can be extremely daunting to detect and plug. This article analyzes the main causes of memory leaks in Java Enterprise Edition (Java EE) applications, and suggests strategies for detecting them. (3,200 words; March 13, 2006)

By Ambily Pankajakshan

http://www.javaworld.com/javaworld/jw-03-2006/jw-0313-leak.html

2006/01/13

[Troubleshooting] The deployment framework was unable to register with the Data Replication Service

Description
Deployer:149204]The deployment framework was unable to register with the Data Replication Service.


Resolution
確認一下,在/etc/hosts裡頭是否有127.0.0.1 localhost
若無,請加上127.0.0.1 localhost
並且需重開機才能生效