Convert PDF for Kindle

Calibre vs Mobipocket Creator

Mobipocket Creator gives you more freedom. It first extracts contents from PDF and generate HTML file, then use HTML to generate .PRC file. So we have the chance to edit the HTML file before we generate the final .PRC file.

Plus, unlike what Calibre generated, PRC file's TOC is working.

Eclipse Debugging

When you debug in Eclipse, quite often, you want to put your mouse over a variable and check the value of the variable, but sometimes, this is not working, instead to show the value, it shows the definition of the variable. I did some search, some people suggests Java->Editor->Hovers, uncheck or check "Combined Hover", but it's not working for me.

I found that the problem depends on which thread you are selecting, if you are selecting the active thread, the variable value will show up, but if not, it will not.

Eclipse Debugging Problem

If you have 2 threads, and you are debugging between them, it seems the debug point always stops at only one thread, and lose the focus on the other, the trick to fix it is

Preferences->Java->Debug->Default suspend policy for new breakpoints: choose "Suspend VM"

Windows Search Replacement

Does anyone out there feel Windows' own "Search" really suck like what I feel? If you do, here is a good news:

I found Agent Ransack, which is really nice and fast.

Uninstalling Oracle 10g Manually from Windows XP

From Link

Oracle's installation utility has a nasty habit of leaving a lot of items behind. I wrote this up to document what I've found you need to do to uninstall Oracle 10g manually. This is specific to 10g and Windows XP. Removing 9i is very similar if I remember right, but who's using 9i anymore? ;-)

The first thing you should do, is go ahead and run the installation tool to do an uninstall. It probably will leave some things behind, but it's worth running. Then go through this list and remove anything it missed. This list is detailed enough though, that I believe even if you did not run the uninstallation tool, this would fully uninstall Oracle.

The most commonly missed item is to make sure you remove everything from the GAC because the uninstaller doesn't appear to. I get to that later, but if you wanted to know the largest source of uninstallation problems, it's libraries remaining in the GAC.

After running the supplied Oracle uninstallation utility (which may or may not do some or all of the following):

Stop any Oracle services that have been left running.
Start->Settings->Control Panel->Services
Look for any services with names starting with 'Oracle' and stop them.

Run regedit and delete the following keys (some may have slightly different names in your registry):
HKEY_CURRENT_USER\SOFTWARE\ORACLE
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application\Oracle.oracle
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OracleDBConsole
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Oracle10g_home
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OraclService

Note that the services control panel will still show the old services until you reboot.

Delete the Oracle home directory
C:\Oracle

Delete the Oracle Program Files directory:
C:\Program Files\Oracle

Delete the Oracle Start Menu shortcuts directory:
C:\Documents and Settings\All Users\Start Menu\Programs\Oracle*
Where * indicates the name of your install. Look for and remove all Oracle directories from that location.

Remove Oracle refereces from the path. To edit your path go to:
Start->Settings->Control Panel->System->Advanced->Environment Variables
Edit both of the environment variables user PATH and system PATH. Remove any Oracle references in them.

Remove Oracle.DataAccess and any Polic.Oracle files from the GAC which is at:
C:\Windows\assembly\

There, now your system is Oracle free. If you are installing a new instance of Oracle (and not just an additional DB) I recommend you do this before any new Oracle installation.
Note: I used several other websites and searches as references when developing these steps, but I was unable to find any steps that covered all of the items for Oracle 10g so I assembled them here.

Oracle Tablesapce

A tablespace is a logical storage unit within an Oracle database. It is logical because a tablespace is not visible in the file system of the machine on which the database resides. A tablespace, in turn, consists of at least one datafile which, in turn, are physically located in the file system of the server. Btw, a datafile belongs to exactly one tablespace.

Each table, index and so on that is stored in an Oracle database belongs to a tablespace. The tablespace builds the bridge between the Oracle database and the filesystem in which the table's or index' data is stored.

There are three types of tablespaces in Oracle:
Permanent tablespaces
Undo tablespaces
temporary tablespaces

Oracle XE "Database" vs "Scheme"

This is from: link

In Oracle, a database means a collection of data files and control files stored on disk. You can have only one database with Oracle XE. A database is mounted by a Oracle instance, which means all the background daemons and programs that you can see with ps.

You probably want a schema, which is what other DBMS products (e.g. MySQL) often refer to as a "database". IIRC there was no limit on the number of schemas in Oracle XE. You can create those from the APEX UI that comes with XE, or from command line (with CREATE USER -- again, confusingly, a userand schema are largely synonymous in this case).

I recommend reading the Concepts guide from Oracle documentation, most of this basic stuff (e.g. how things are called in Oracle-lingo) is covered there.

Oracle XE 10g problem

I used to use Oracle 10g enterprise version as my database, but I found it takes too much memory, so I switched to XE, it's working great until tonight.

When I start my weblogic server, I keep getting such error:

ORA-12519: TNS:no appropriate servicehandler found.

I have absolutely no idea what's this about, so google it, and found this: link

The fix is easy, and it works:

alter system set processes=150 scope=spfile;

Then restart your database.

If you run into an error like this: "ORA-01653: unable to extend table HAIBO_COMR.FORM by 8 in tablespace SYSTEM"

alter database datafile 'C:\ORACLEXE\ORADATA\XE\SYSTEM.DBF' RESIZE 1000M;
Make sure the highlighted part is the one in your system.

Other useful queries:
SELECT * FROM dba_data_files
purge recyclebin;
SELECT  tablespace_name,  SUM(bytes/1024/1024) FROM  dba_segments GROUP BY  tablespace_name;
select tablespace_name, sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;

Eclipse Showlocation

add this line at eclipse.ini
....

-showlocation
-vmargs
....

Eclipse change CVS changed files

Preferences->Team->CVS->Label Decorations->Enable font and color decorations

Then click "Color and Fonts", change CVS->Outgoing Change (Background/Foregroud)

Eclipse Debugging Problem

I recently set up a project, and try to debug it. But it always stops at FileInputStream.class line 106.

Here is the solution

Uncheck

Window > Preferences > Java > Debug : Suspend execution on uncaught exceptions

Eclipse Template Proposals

Windows->Preferences->Java->Editor->Templates

Eclipse CVS Plugin - CVS Version Tree

Short manual:
  • Rightclick on a CVS resource in the package explorer and select "Team -> Show in Version Tree" from the popup menu to display a version tree for a CVS resource.
  • Left click on a revision in the version tree to display the details in the detail view on the right.
  • Double click a revision in the version tree to open an editor with the contents of that revision.
  • Open context menu on a revision to open or compare revisions.
  • Use context menu or plugin tool bar to configure layout.
  • Configure layout, color and sizes of the ui elements: "Windows -> Preferences: Team / CVS / Version Tree"

ERROR: JDWP unable to get necessary JVMTI capabilities.

I got this error today when I try to start up weblogic as debug mode.

Did some searching, here is the solution:

I found that I have 2 sets of "-Xdebug -Xrunjdwp:", one is for 8453, the other is for 5005.

I simply removed the 5005 one:

-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

Now it's working.

Regular Expression in TextPad

Link

Configure -> Preferences -> Editor
Check "Use POSIX regular expression syntax"

search c.+b
all the following will be found:
c234b
cxyz123b
C123-=b

Search .+=
means anything until=

Special character which needs escaping \

+ ? . * ^ () [] {} | \

. is wildcard
[blabla]
example: [0-9] [a-z]
[^0-9] means non digits
^PATTERN: find pattern at start of line
PATTERN$: find pattern at end of line
for example, search ^todo find line 1, search todo$ find line2.
line 1: todo things
line 2: we will do it. todo

for example,
search c.*b, find 1,2, and 3.
search c.+b, find 2 and 3.
search c.?b, find 1 and 2.
search c.\{3\}b, find 3
search cx\{3\}b, find 3 too

1 cb
2 cab
3 cxxxb

Quantifiers:
+      1 or more times
?      0 or 1 time; item is optional
*      0 or more times; item is optional or repeatable
{N}    N times
{N,}   N or more times
{N,M}  N to M times
Recently I bought a Samsung internal hard drive from newegg.com. 

1. installation. My PC has 3 types of hard drive.
IDE Data Cable
IDE Power Cable
SATA Data Cable
SATA Power Cable (Black One)

    a. IDE power cable + IDE data cable
    b. IDE power cable + SATA data cable
    c. SATA power cable + SATA data cable 


2. recognize. After the installation, and I restart my PC, but I found the new hard drive is only about 32 MB. After doing some search, I found it here, and I download the program, it's said "Supported OS: 32-bit versions of Windows XP/Vista/2003", mine is 32 bit Window 7 Professional. It works great.

We are Fedwire vendor

Each vendor listed below has successfully executed a Federal Reserve Bank-prescribed test script for the product(s) named on this list, demonstrating that the vendor and/or its depository institution customer was able to use the product(s) listed to connect to the Federal Reserve Banks' Depository Institution Test (DIT) environment through the FedLine Direct access solution, to send and receive properly formatted Fedwire Funds Service messages and to appropriately handle exception and error conditions.
Link

Youtube Hack

To make the video play automatically (like it does on the youtube page) add &autoplay=1 to both of the youtube url codes above.

So you would change http://www.youtube.com/v/6gmP4nk0EOE to http://www.youtube.com/v/6gmP4nk0EOE&autoplay=1


If you want the youtube clip to automatically restart and loop when done then add this additional modifier to the url: &loop=1

Therefore, you would change all the youtube urls to this:
http://www.youtube.com/v/6gmP4nk0EOE&autoplay=1&loop=1

Eclipse settings and plugins

Actually it should be called workspace settings, which locates at \.metadata.

If you want to copy setting from one workspace to another, just copy .metadata folder, but I am not sure if this might be a little bit overkill. A smaller set probably is enough: .plugins\org.eclipse.core.runtime, this will sure cover fonts, formatter, shortcuts.

While plugins, it's for Eclipse, they are installed into Eclipse folder, not in workspace folder. For example, just copy .metadata folder will copy the StartExplorer plugin over.

Change TextPad selected line color

Tomcat vs Apache

Link

Subversion Installation Summary

You could install subversion only or subversion with Apache Server. The latter lets to access to subversion from different machine.

1. Install subversion. (recommend using windows binary, as it will automatically add subversion's bin folder to PATH, save yourself some trouble)

2. Create subversion as an automatic windows services.

sc create svnserver binpath= "d:\svn\bin\svnserve.exe --service -r d:\svn\repository" displayname= "Subversion" depend= Tcpip start= auto

This saves you to remember to start subversion every time.

3. Create a source repository.

svnadmin create "d:\svn\repository".

Bear in mind, you could create a repository anywhere you want. After doing that, you should find a bunch of files are created under d:\svn\repository. 

4. Configure for subversion only installation. If you install subversion with Apache, skip this step.

  a. d:\svn\repository\conf/svnserve.conf, uncomment the following lines:
     anon-access = none
     auth-access = write 
     password-db = passwd 

  b. d:\svn\repository\passwd
    you can add user here in the following format:
    haibo=secret

5. Install Apache Sever, if you don't want to use port 80, change \Apache2.2\httpd.conf,

Listen 8181

At this point, Apache knows nothing about subversion.

6. Configure Apache with Subversion.
a. open D:\Apache Software Foundation\Apache2.2\httpd.conf, add the following at the end of the file

#load moules for svn
LoadModule  dav_module modules/mod_dav.so
LoadModule  dav_svn_module  "D:/svn/bin/mod_dav_svn.so"
LoadModule  authz_svn_module  "D:/svn/bin/mod_authz_svn.so"


# Configure Subversion repository
<Location /repository2>
DAV svn
SVNPath "D:\svn\repository2"
AuthType Basic
AuthName "Subversion Repository2"
AuthUserFile "D:\svn_conf\passwd"
Require valid-user
AuthzSVNAccessFile D:\svn_conf\svn-acl
</Location>

For "Configure Subversion repository" part, you could put it into another by doing this

Include D:/svn_conf/subversion.conf

7. Now we need configure D:\svn_conf\passwd and D:\svn_conf\svn-acl.

cd D:\Apache Software Foundation\Apache2.2\bin
htpasswd -cm d:\svn_conf\passwd Sam

this is create an encrypted password for user "Sam", it will prompt your to enter password.

If you want to add another, htpasswd -m d:\svn_conf\passwd haibo

Be noted, we are not using -c option here, otherwise, it will remove user Sam.

Then create D:\svn_conf\svn-acl, this file will define which users have what access.

[repository:/]
Sam = rw
* = r

[repository2:/]
Sam = rw
* = r

8. Now, start Apache Sever, your url should be:

http://localhost:8181/repository2/

Install Subversion with Apache Server

You could install only Subversion without server. (Please my notes), but the problem is you could only access to subversion at the same machine. To make sure you could access to subversion repository from anywhere, you need install Apache Server.

1. Suppose you have already installed subversion, you need create a repository

 svnadmin create "d:\svn\repository2"

2. install Apache Server, I used  httpd-2.2.17-win32-x86-no_ssl.msi. Install it D:\Apache Software Foundation\Apache2.2

3. open D:\Apache Software Foundation\Apache2.2\httpd.conf, add the following at the end of the file

#load moules for svn
LoadModule  dav_module modules/mod_dav.so
LoadModule  dav_svn_module  "D:/svn/bin/mod_dav_svn.so"
LoadModule  authz_svn_module  "D:/svn/bin/mod_authz_svn.so"

# Configure Subversion repository
<Location /repository2>
DAV svn
SVNPath "D:\svn\repository2"
AuthType Basic
AuthName "Subversion Repository2"
AuthUserFile "D:\svn_conf\passwd"
Require valid-user
AuthzSVNAccessFile D:\svn_conf\svn-acl
</Location>

4. create folder D:\svn_conf

cd D:\Apache Software Foundation\Apache2.2\bin
htpasswd -cm d:\svn_conf\passwd Sam

this is create an encrypted password for user "Sam", it will prompt your to enter password.

If you want to add another, htpasswd -m d:\svn_conf\passwd haibo

Be noted, we are not using -c option here, otherwise, it will remove user Sam.

Then create D:\svn_conf\svn-acl, this file will define which users have what access.

[repository:/]
Sam = rw
* = r

[repository2:/]
Sam = rw
* = r

You can see here, we give user "Sam" write access to both repository and repository2.

5. Apache is using 80 as the default port, if this port is already used, you could change it to 8181 by changing in D:\Apache Software Foundation\Apache2.2\httpd.conf, 

Listen 8181

Now, start Apache Sever, your url should be:

http://localhost:8181/repository2/

Convert an Eclipse “General” Project to a Java Project

Link

I don’t know how many times I’ve accidentally created a General project instead of a Java project, and it always bugged me that you couldn’t convert from General to Java without starting over.

The quick and easy hack is explained well here. Open the relevant .project file and add the following (note that you don’t need the element if one is already there):

<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>

It’s too bad you can’t “Add Java Project Nature” from within the Eclipse UI

Make sure you do this with the project closed!

Subversion

How to install

Installation Notes:

1. go to here to download windows binary, I used 1.6.6 version. Install it, I install it at d:\svn\.
2. The installer will add d:\svn\bin into my PATH, so we could execute any svn command.
3. Here is the command to create a source repository: svnadmin create "d:\svn\repository".
4. For each repository, we have something to configure, like who has the access.
5. d:\svn\repository\conf/svnserve.conf, uncomment the following lines:
     anon-access = none
     auth-access = write
     password-db = passwd
You can see, we give anonymous user none access, and authorized user write access, while the password for each user is defined in passwd file.
6. d:\svn\repository\passwd
    you can add user here in the following format:
    haibo=secret
That means giving user "haibo" with password "secret" write access.
7. now use the following command to create Subversion as an automatic windows services.

sc create svnserver binpath= "d:\svn\bin\svnserve.exe --service -r d:\svn\repository" displayname= "Subversion" depend= Tcpip start= auto

After that, you could go to Services, and start "Subversion" service.
8. put export SVN_EDITOR=TextPad.exe into cygwin's .bashrc, supposing TextPad.exe is already in PATH, so we could execute all the stuff from cygwin instead of CMD, which gave me some funny characters. You could try svn help to make sure everything is all right.
10. Now create a project in repository:
svn mkdir svn://localhost/myproject

11. You might need download TortoiseSVN.
12. You might want to download Subclipse for SVN.

Replace text in a lot of files

After I set up smbc-wl project on my eclipse, I have found that the CVS user name is actually Ian's user name. If you have the same problem, here is a quick solution to fix this:

First, we put the text that we want into a file called "bar".
Then we search all file named as "Root", and put the content of "bar" into it.