CVS commands

check out a project/module:
cvs co -r dbeurope-q57-branch db-cheque
cvs -d $CVSROOT checkout -r "$EUROPE_BRANCH" "$CVSMODULE"

-r tag: revision tag
-R: recursive, default is on.
-d dir:


VPN to my PC

https://webvpn.dovetailsystems.com

haiboliu
last 4 digits + xxxxx
T1600Hliu.dovetail.net
dovetail\hliu

Yahoo Email Plus in Outlook

I tried to setup Yahoo Email into outlook 2007, easy, right?
Here is the link for the detail

But then I realized that I also want to sync my Yahoo folders (other than inbox) too, and I am stuck. That's the point I realize the different between pop3 and imap4. And Yahoo only provides pop service, that's why I could not get my Yahoo folders. But I know I could get all my Yahoo folders in my HTC EVO, then I go ahead to check the settings, I realized that in my HTC EVO, the setting are the followings:
IMAP Server: android.imap.mail.yahoo.com
Security Type: SSL
Server port: 993
android.smtp.mail.yahoo.com
SSL
465

I also know Dovetail Email could also download folders, wondering what the setup?

Window 7 Dock Applications

http://www.windows7hacker.com/index.php/2009/06/5-amazing-dock-application-for-windows-7-ultimate-tweak-all-free/

Activate Window 7

Windows 7

  1. Click Start
    Start button
    .
  2. Right-click Computer.
  3. Select Properties.
  4. At the bottom of this window, click Activate Windows now.
Note To activate your product directly by telephone, type slui.exe 4 in the Search programs and files and then press Enter. Select your location in the drop-down list for a toll free activation telephone number to call. This method is for Windows 7 only.

Windows 7/Vista Dock

Just so I got the name right.

Well, well, it's actually Dell Dock....

StringUtils.stripStart


String strTranAmount="000000000000000000";
strTranAmount = StringUtils.stripStart(strTranAmount, "0"); //the result is empty

String strOrigAmount="000000000001000,00";
strOrigAmount = StringUtils.stripStart(strOrigAmount, "0"); //result 1000,00

JSON

Java Standard Object Notion

It's a format, like XML.

go to http://json.org find all the information.
All the libraries for different languages.

json2.js is JSON parser library for JavaScript.
JSON.parse("blabla");
vs
eval('(' + "blabla" + ')');

JSON is safer and faster.

Tell me again why we want to use JSON.parse() instead of eval()?

Understand JSON.parse() eventually will use eval(), but before that, it will do some checking for you, so it's safer.

Here is a link for details.

HTML5

Adobe supports HTML5 in products such as the Dreamweaver Web design software, with backing for HTML5 tags and cascading style sheets (CSS) code-hinting. Adobe's Project Edge serves as a tool for HTML5 animations. And the company's Jangaroo project is about converting Flash to HTML5.

JavaScript Function

alert("xxx")
prompt("What is your name?", "Enter your name here")
parseInt("12") //you could parseInt("1.2") == 1 and you could parseInt("3 dozen")
parseFloat("1.2")
NaN: parseFloat("$3.4") = NaN //should not include $
isNaN(xxx): check if a value is not a number
document.getElementById("ddd").value
xxx.toFixed(2): round the value to 2 decimal places.
form.submit()
setTimeOut("alert('wake up!');", 60000);
setInterval("alert('wake up!');", 60000); //repeated
clearInterval(timerId);
location.reload();
document.body.clientHeight
document.body.clientWidth
document.getElementById("rockImg").style.height="100px";
onload
onresize
document.cookie.split(';');
if(navigator.cookieEnabled)
In JavaScript, array could contains different type of data, that's different from Java
var showTime = new Array();


Disable Adobe Updater

1. go to C:\Program Files (x86)\Common Files\Adobe\Updater6
or something similar.
2. Click Adobe_Updater.exe, Click Preference, uncheck "Automatically check for Adobe Updates"

XSLT

XSL == Extensible Stylesheet Language, Style sheets for XML
XSLT == XSL Transformation

CSS: Style Sheets for HTML

XSL consists of 3 parts:
XSLT
XPath
XSL-FO

Android Development

1. Download SDK here
2. Extract it into C:\development, put C:\development\android-sdk-windows into PATH.
3. Install ADT plugin for Eclipse (https://dl-ssl.google.com/android/eclipse)
4. C:\development\android-sdk-windows\SDK Manager.exe, Choose package to install. For me, 2.2.

Create symlinks in windows vista

mklink /D \europe57\wls\dbeurope\autodeploy \europe57\wls\dbeurope\applications

Avery

I got this avery add-in for Word (in my google docs), it's great to print label.

After installation, you'll find "Avery" at the top of menus (after add-ins). Click it, it will show icon for "Avery Wizard", it will show you

For my printer, I put the label paper at where I put photo paper, it's working great!

epub to kindle

http://download.cnet.com/Calibre/3000-2125_4-10910277.html

This is a fantastic software to transfer epub file to Kindle format. Just great!

It's not just epub file, also pdf and many others.

Android Phone -- HTC EVO 4G





Apps:
  1. Advanced Task Killer - Close unwanted apps that maybe running in the background.
  2. Aldiko - eBook reader. Comes with a bunch of free books.
  3. Astrid Tasks - Best task list manager I have found so far. Has options for tasks list and reminders.
  4. ASTRO - Best file manager for the phone and SD card.
  5. AudioManager - Has a widget to control all the audio options for the phone in one place. Must have app if you put your phone on silence / vibrate only / custom audio profile for alerts and notifications.
  6. Foursquare - App to publish your location information based on nearby establishments. Pushes the same info to Facebook and Twitter.
  7. Google Sky Map - Shows off a real-time view of the stars based on where you point the phone. Best app to show off to your friends with the "WOW" factor.
  8. Meebo IM - All in one mobile instant messenger with AIM, Yahoo, MSN, GTalk. But uses a lot of battery if used continuously.
  9. Mint - All in one money manager to track expenses etc.
  10. Network - I use it to turn off the GSM radio and use CDMA only. This trick has improved my battery life.
  11. Photoshop.com Mobile - Have some fun with the pictures taken with the phone. Must have to show off to your iPhone fanboys.
  12. ShootMe - Phone screenshot grabber.
  13. Shopper - Google shopping app which has a built in barcode scanner. Runs a Google product search using pictures or barcode.
  14. Ustream - Live video broadcast phone to their website.
  15. XKCD Viewer - View XKCD cartoons and the hover over text.

EDIT - added more to the list based on suggestions:

  • Dolphin HD Browser - Added to the list since it is faster and more option packed than default browser.
  • Compass - Neat app to show off the built in capability.
  • ScoreMobile FC - Something to keep track of the World Cup 2010 going on right now.
  • World Newspapers
  • MITBBS by Chenio Software


C++ compiler

http://nuwen.net/mingw.html#install

I am not a C++ developer, but recently I have to set up a C++ development environment, here is the notes:

1. download Eclipse CDT here

There is preference: automatically build, save....
CTRL + B: build

2. Download C++ compiler here

3. Extract it to C:\

put C:\MinGW\bin in your windows PATH.

4. how to include a header

<#>include C:\includes\myHeader.h

5. how to use cout

#include
using namespace std;

Portable Evernotes

http://dl.dbank.com/c09t63uqld

Copy Files from Remote Machine

Quickly setup a AspectJ project

1. download AJDT for eclipse

Eclipse 3.6 Update Site URL:http://download.eclipse.org/tools/ajdt/36/update
Eclipse 3.5 Update Site URL:http://download.eclipse.org/tools/ajdt/35/update

2. Create a AspectJ project, and you are all set.

You might find some syntax error in aspect class, ignore it.

AspectJ, Spring, and Guice

Recently, I have some time to take a look at these 3 things, mainly on AOP part.

Spring has a very good support for AOP, but the main problem is, all the beans need to be managed by Spring's container, otherwise, AOP won't work. This is ideal if you have a completely Spring-powered project. But it won't do you any good if you are not.

[Not exactly: Spring could inject values into non-Spring bean]

1. define bean in config as abstract plus the configurations, the id, let's see, is "testBean1"
2. add @configurable("testBean1") before the class in .java file.
3. add in config file.

It seems behind the scene, it's still AspectJ is doing all the work.

Guice has the same problem, the Java classes have to be binded by Guice's injector to have AOP work.

That leaves only one choice, AspectJ.
With AspectJ, we could have a very powerful tool to work on big project.

Imagine your boss gives you this task: log the result whenever a method named getMyMoneyBack() gets called. Sound easy? Not so fast, the problem is getMyMoneyBack() exists in thousands of classes, and they are called by millions of times. You really don't want to go to millions of places to put your log code there, do you?

With AspectJ, life is much easier.

You define a point cut like:

pointcut logGetMyMoneyBack() : call (* *.getMyMoneyBack(..))

String around() : logGetMyMoneyBack
{
String result = proceed();
System.out.println(result );
return result;
}
return proceed();

Guice


Here is the idea:

You have a class A, which depends on class B and class C.
First step, you want to create interface iB for class B and interface iC for class C, why? won't you rather depend on an interface than an concrete class? This will give a flexibility to use whatever classes you like to use, as long as they implement the interface. For example, B is concrete class for credit card processing, when you do the test, you don't want to call B to do a real credit card processing, right? Ok, so are we good to depend on interface?

Second step, in the run time, which concrete class to use? Guice provides a simple way, called Module, what Module does is binding interface with concrete class. So you could have many Modules, for example, in Module1, you bind iB to class B1, and iC to C1, while in Module2, you could bind iB to class B2, and iC to C2. In runtime, you could decide to use which Module as you like.

Ok, all these are just theories, now let's dive into the bolts and nolts.

Class A have 2 dependencies in iB and iC, in its constructor, you need add an annotation, @Inject, this signal Guice that we want to do Dependency Injection.

In the codes where you want to use class A, you don't need call A's constructor, instead, you use Guice injector

Injector injector = Guice.createInjector(new Module1());
Class A = injector.getInstance(A.class);

That's it.
Let's calm down to understand what's we have just done, it's a lot.

1. We create a Class A instance without calling its constructor.
2. We have binded its 2 dependencies into class A. not just interfaces, but real concrete classes: B1 and C1.

Now you see, A doesn't even know anything about B1 and C1, they are completely decoupled. Their only glue is interface iB and iC. And Guice injector makes it super easy to bind them together in run time. aHa....

Also, you Module1 is also decoupled from Class A, if A doesn't have the annotation, Module1 will just leave it alone.

todoist



SQLite Data Types

In Version 3:

Null:
INTEGER:
REAL:
TEXT:
BLOB:

No Boolean type.
No Date and Time type, but the build-in Date and Time function could store Date and Time as TEXT, REAL or Integer.

TEXT as ISO8601 Strings (YYYY-MM-DD HH:MM:SS.SSS)
REAL
INTEGER

Flex XML

Here is what I have

xml  
      Date   
    2010-10-15 
 /Date  
Number
       1000 
 /Number
 xml

The question is how can I get the vale of Date and Number?

if myXML is used to refer to the above XML

var strDate:String = myXML.Date[0].toString();
var strNumber:String = myXML.Number[0].toString();

Flex eventhandler mode

This weekend, I have a problem with Flex, to say specifically, with Flex's Event Handle mode.

Here is my situation, I need loop through SP500 symbols, and send the url to Yahoo web site to get some data.

When I sent a query, it will take some time to get the data back, the way Flex handles this is using Event Handler. It will add a listener to URLStream object, which will listen to complete event. When the stream is done loading, URLStream will be notified, and will proceed to do something else, like put the stream into database.

Now I got problems at the hand. You see, sending query and loading stream is separated, they are not in liner relationship. What will happen is you will send 500 queries to Yahoo server, then you wait for the data coming back to you one by one, not necessarily in the sending order.

First problem is, because I send the 500 queries together, Yahoo decides not like it, and I will get some timeout error.

Second problem is, when the data comes back, I need know the data is for which symbol, so I need pass the symbol to the complete event handler, fortunately, I found some solution:

urlStream.addEventListener(Event.COMPLETE, function(e:Event):void{loadedEventHandler(e, symbol);});

You see, that let me pass symbol to complete event handler.

addEventLister's signiture is (Event.COMPLETE, eventHandlerFunctionName:String)

But the eventHandlerFunction has to be like functionName(e:Event), so my own's event handler doesn't qualify the signature.

what this does, add a more standard event handler above my own event handler, then call my own event handler.

This resolve the problem, but the first problem is hard to resolve, eventually, I have to use Java to do what I want to do.

SQLite vs MySQL

Here is a list of well-known Users of SQLite:


Here is a debate regarding SQLite vs MySQL


It seems to me, in 99% case, SQLite is good for production use.

SQLiteJDBC

SQLiteJDBC is a Java JDBC driver for SQLite. Link

Sample code:

It will create the test.db file in the root directory of the project.

Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
Statement stat = conn.createStatement();
stat.executeUpdate("drop table if exists people;");
stat.executeUpdate("create table people (name, occupation);");
PreparedStatement prep = conn.prepareStatement( "insert into people values (?, ?);");
prep.setString(1, "Gandhi");
prep.setString(2, "politics");
prep.addBatch();
prep.setString(1, "Turing");
prep.setString(2, "computers");
prep.addBatch();
prep.setString(1, "Wittgenstein");
prep.setString(2, "smartypants");
prep.addBatch();
conn.setAutoCommit(false);
prep.executeBatch();
conn.setAutoCommit(true);
ResultSet rs = stat.executeQuery("select * from people;");
while (rs.next()) 
{
      System.out.println("name = " + rs.getString("name"));
      System.out.println("job = " + rs.getString("occupation"));
}
rs.close();
conn.close();

Some Java Stuff

Int vs Long vs Double vs REAL

string to int
Integer.parseInt(myString);

int to string
String.valueOf(myInt);

String to java.util.Date

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date tradeDate = formatter.parse(dateString);

String strFormatDate = formatter.format(tradeDate);

java.util.Date to long
tradeDate.getTime();

java.util.Date to long to java.sql.Date
java.sql.Date sqlDate = new java.sql.Date(tradeDate.getTime());

StringTokenNizer vs split
String[] dateValues = value.split("-")

SQLite

I didn't realize that Adobe Air is actually using SQLite engine until this morning.

Then I found SQLite Browser

It's a powerful tool to manage SQLite DataBase, you could create/update/delete tables/columns, and you could also issue SQL commands against table.

Now this solves a problem for me:

I could use Flex Air to build fancy UI against local DataBase without worrying about DataBase driver....you know, these complicated stuff. For me, I just need a simple relational database, I don't care security, I don't care users....just simple database that I could store data persistently.

SQLite Browser allows to import .CSV file into Table directly, it could even extract the first row as the column name if you choose.

Regarding the limits: see here but here is the recap:

Bear in minds, all these limits are configurable, just to avoid making things complicated, let's just take whatever default comes.

Maximum number of Columns: 2000
Maximum length of a string or BLOB: 1 Billion bytes -- about 954 MB

Now, the sky is just open....

Flex 4, Air 2, and others

From last night, I started writing a Flex program. Here is what it does:
1. open a .xls file and show it in datagrid.
2. search by column, type as change.
3. Open the changed datagrid in new .xls file.

It's pretty neat, would be very useful to process a large .xsl file.

But then I found it's not that useful because Excel could do basically everything it does. Kind of frustrated a little bit, but then I realize that it's not that bad, after I jsut re-picked up what I left about a year ago. After all, I start using Flash Builder 4, Flex 4 API, AIR 2 API, refresh some of my knowledge on Flex, like layout, HGroup(HBox), VGroup (VBox), ArrayCollection, Column list, ComboBox, Filter function....and also how to release a project.

So, it's good.

Change Cygwin ls colors

1. first, put the following lines in your .bashrc

alias ls='ls --color=auto -F --group-directories-first'
eval `dircolors -b /etc/DIR_COLORS`

2. edit /etc/DIR_COLORS`

Before I found that there are some directories always with green background, very annoying, take a good look, found the reason, I don't have enough permissions for these folders, so chmod 755 do it.

Eclipse conflicts with ClipMagic

I like ClipMagic, which gives me total control on ClipBoard, plus some additional perks.

But Eclipse is my bread, which I make a living on it.

Now, one of my favorite thing that I do quite often in Eclipse: alt + up/down to copy lines are not working, I then found it has something to do with ClipMagic, as I close ClipMagic, alt = up/down works....

Now I need find out how to let these two work together....

I have decided scrapping ClipMagic using Ditto....

Total Commander

Why I want to use Total Commander?

1. multiple windows operations.
2. multiple files/folder renaming.
3. save your selections into a file.
4. synchronizations: they will check the differences. ask your which way to sync.
5. Powerful search: full text search. (might need enable unicode)
6. Copy multiple files' name, path, detail into clipboard.



set up FTP server at your machine using IIS 6

Control Panel->Programs and Features->turn windows features on or off->Internet Information Services->FTP Publishing Service->FTP Server
Control Panel->Administrative Tools->Internet Information Services (IIS) 6.0 Manager->Defautl FTP Site start it.
ftp://localhost:21
righ click->Peermissions->Users (matt-PC\Users), give full control
restart the server, now users will have the delete permissions.

explore this

http://www.softwarecybersleuth.co.uk/pagethree.htm


Quick Add Links to Windows Vista Explorer Favorite Links


If you’ve used Windows Vista for 5 minutes, you’ll have seen the Favorite Links when browsing around your filesystem. What is annoying is that by default the favorite links doesn’t include enough useful links.

Here’s the default links list (I’m sure you have seen this)

If you want to add a new link to the links bar, all you have to do is drag and drop the folder onto the links bar. I’m going to add my Computer link to the menu:

Now, it shows up in the list:

Much better!

Managing your links is extremely simple. Just open up your home directory by clicking on your icon on the start menu. You’ll see the LInks folder:

This folder contains all of the shortcuts to your favorite locations.

To remove an item from the list, you can either right-click the item and choose Remove Link, or just go to your Links folder and delete it from there.

Kindle On PC

Just updated Kindle on PC, found some very nice new features.

The nicest one: you could search now....

so nice...

Driver Genius

A very nice tool to install/backup drivers....

ClipMagic

Pretty handy.

Little tip on outlook attachments

Even had a situation that you received an Email with a lot of attachments, and you have to save them one by one?

Well, you could select them all, then save as into a folder all by once.
Or you could select all, and copy them, then paste to your desired folder.

Use command's output as input

See, I want to use the output of pwd as input of cygpath, here is what I do

cygpath -w "`pwd`"

`` means executing pwd and get the result, "" will make sure we get the full path without worrying about blank. This command will show current path in windows format.

Where is color of ls command defined?

Where is color of ls command defined?

by NIXCRAFT · 5 COMMENTS

1) Configuration file for the ls color command is /etc/DIR_COLORS for Linux. You can modify those colours if you want.

2) Here is list of most common colors: (RHEL 3.x/FCx/RH and other linux distros)
Executable files: Green
* Normal file : Normal
* Directory: Blue
* Symbolic link : Cyan
* Pipe: Yellow
* Socket: Magenta
* Block device driver: Bold yellow foreground, with black background
* Character device driver: Bold yellow foreground, with black background
* Orphaned syminks : Blinking Bold white with red background
* Missing links ( - and the files they point to) : Blinking Bold white with red background
* Archives or compressed : Red (.tar, .gz, .zip, .rpm)
* Image files : Magenta (.jpg, gif, bmp, png, tif)

3) They are stored in special shell variable called LS_COLORS

4) You can customized them in /etc/DIR_COLORS or file pointed by shell variable COLORS.

5) To customized colors you must use special string combination:
FILE-TYPE Attribute codes: Text color codes:Background color codes

Where,

  • FILE-TYPE: is file type like DIR (for directories)
  • Attribute codes:
    • 00=none
    • 01=bold
    • 04=underscore
    • 05=blink
    • 07=reverse
    • 08=concealed
  • Text color codes:
    • 30=black
    • 31=red
    • 32=green
    • 33=yellow
    • 34=blue
    • 35=magenta
    • 36=cyan
    • 37=white
  • Background color codes:
    • 40=black
    • 41=red
    • 42=green
    • 43=yellow
    • 44=blue
    • 45=magenta
    • 46=cyan
    • 47=white

For example to define Bold Blue color for DIR file type, entry should look as follows:
DIR 01;34

6) Let us modify dir color on Red Hat (Fedora) Linux:

# vi /etc/DIR_COLORS

Modify DIR entry
From:

DIR 01;34 # default is Bold blue with black background

To:

DIR 01;34;41 # NEW default is Bold blue with RED background

Save file.

7) Logout and login again, Please note that if you have shell variable defined COLORS then use that file (use echo $COLORS to find it out).

todo.txt

This is todo tool for cygwin (not just for cygwin).

couple of things to set up:

export PATH=$PATH:"C:\cygwin\home\hliu\working_dir\todo.txt_cli-2.7"
chmod +x todo.sh
mv todo.cfg ~/.
(make some changes on todo.cfg, like define location of todo.txt and colors)
in .bashrc
alias t='todo.sh -d C:/cygwin/home/hliu/todo.cfg'

some commands
t add "go to drug store"
t do 1
t pri 1 A
t depri 1 A
t ls

Search in cygwin

Open in Windows (cygstart is doing the same thing)
Search File
credit to Rob


I made a little change to use TextPad as my editor.

now how to use this command:

cd $de_arc
u -f "*.xml" "DB" : this is to search the current directory for all *.xml file which contains "DB".

-d: directory
-e: editor, otherwise will search editors
-f: file name pattern
-s: case senstive
-h: help

u [-d] [-e] [-f] [regular expression or file path]

Open Windows Explorer in Cygwin

Robert on programming

put the script in a file called windows in /bin/
dos2unix windows
chmod 755 windows

that's it.


- and _

SWIFT doesn't like underscore.
CHIPS is ok with underscore.
Both are OK with dash.
DataBase doesn't like dash.

Run a Command as Administrator from the Windows 7 / Vista Run box

If you are a command line junkie like me, and have been testing out Windows 7 or Vista… one of the first things you’ll notice is that there is no way to run a command from the run box in “Administrator” mode. Until now.

To try this out, go to the run box and type in something (cmd, for example)

Now instead of hitting the Enter key, use Ctrl+Shift + Enter. You will be prompted with the obnoxious User Account Control dialog… but it will then open up a command prompt in Administrator mode.

Hint: You can use Alt + C to quickly close the User Account Control dialog in Vista, or Alt+Y in Windows 7.

HTML Parser

http://htmlparser.sourceforge.net/samples.html

need change 2.1-SNAPSHOT to 2.3.1 for all pom.xml, 2.1 one must be outdated.

cygwin

export google=http://keyboardr.com/nightly/#home/
export blog=http://forevergarden17.blogspot.com

alias cs='cygstart'

then I could just type
cs $google
cs $blog

to go straight to my favorite page.

# Display the $PATH in a human acceptable way
function path()
{
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}

uname -srv: find the version of cygwin
man uname

dos2unix: if you edit a file in windows, then try to execute this file in cygwin, you will have problem, so should use dos2unix to fix it.

MS Dos warning in cygwin 7 fix:

Environment Variables (kinda awkward hidden button) -> Add a variable of CYGWIN with value of nodosfilewarning.

Search multiple lines

I am seeking a way or a tool to search/replace multiple lines.

CVS commands

cvs --help-commands: list all cvs commands
cvs -H : show options for command
cvs -d :ext:$hliu@jupiter:/var/local/devcvs checkout create_eclipse_iach_environment
---this will login to juipter using user name 'hliu', go to folder /var/local/devcvs, and checkout folder "create_eclipse_iach_environment".
rtag -r dbeurope-pts2-branch EUROPE_10_3_0_8_2010_08_12 DBPayments

Some Eclipse Text Edit Shortcut

Home: go to beginning of the line.
End: go to end of the line.
Shift + Home: select from current cursor till start of the line.
Shift + End: select from current cursor till end of the line.
CTR + Delete: Delete next word.
CTR + Backspace: Delete previous word.
CTR + Shift + Delete: Delete to end of the line.
CTR + Shift + right/left: Select next/previous word.
CTR + ALT + Up/Dn: Copy the current line before or after the current line.
CTR + ALT + J: Join the lines. (move the next line to join the current line.)
ALT + Up/Dn: Move the current line up or down.
Shift + CTR + P: move cursor between open/close bracket.
Shift + ALT + R: Re factor Rename the variable
CTR + LF/RT: move cursor by word
SHIFT + Enter: Insert a line after the current line.
SHIFT + CTR + Enter: insert a new line before the current line.

Console2

This almost drove me crazy.

I am using Console2, but there is one problem really bother me: I could display previous commands. When I hit Up arrow key, it always scroll the screen up. Finally, I found how to fix this: Settings->Hotkeys, uncheck "Use scroll lock for scrolling".

Now, I am happy.

Ant

Without a good grasp on Ant, I don't think I could master this whole system.
So Ant In Action.

Build File contains ONE project.
Each project contains MULTIPLE targets.
Target contains tasks.
Tasks do the work.

You could invoke any of the tasks individually.


<target name="execute" depends="compile">
<java classname="org.antbook.welcome.Main" classpath="build/classes">
<arg value="a"/>
<arg value="b"/>
<arg file="."/>
</java>
</target>

ant -buildfile build.xml compile <==> ant compile

That's the default thing that I have been talking about, when you use ant without specifying build file name, ant will by default use file name build.xml.

Eclipse has a good integration with Ant, so you could invoke build.xml directly from Eclipse.

ant command-line options:
-help, -h: list the options Ant supports.
-Dproperty=value: set a property to a value. for example: ant -Dhost=localhost. set property host=localhost.
-buildfile , -f: Use the named buildfile.
-keep-going, -k: when one target on the command line fails, still run other targets.
-logfile : save the log to the named file.
-verbose, -v: Print verbose output for better debugging.
-diagnostics: Print information that might be helpful to diagnose or report problems.
-debug, -d: Print debugging information.
-logger : Name a different logger.
-propertyfile : Load properties from file. -D definitions take priorty.
-quiet, -q: Run a quiet build: only print errors.

Just as Java has classes and variables, Ant has datatypes and properties. Ant properties are immutable.

Ant allows flexibility in how Booleans can be specified with on, true, and yes.
${...} denotes a use of Ant property.
PATH, FILESET,


Export Eclipse

Ok, I have some certain ways to use Eclipse, and I really don't want to lose them when I have to work on another machine or after a upgrade.

I need a plan to export that.

Command Line vs Runas

In the last post, I have listed a lot of run as commands, well, it's great, but the problem is I need invoke run as first by hitting START + R, then type in the commands. What I really want is I could invoke everything from command line.

Well, windows' default cmd utility sucks, but I found an alternative: Console2. It's pretty nice.

To invoke run as commands in Console2, you need type START first. For example, to invoke excel, you need type like

start excel

Documentum RESTful Web Service

I just checked https://community.emc.com/community/labs/dctm_rest/earlyaccess?view=overview, it's pretty sad that there is not a lot activities about it.

I don't know how the project goes now, but I don't have a good feeling.

Last year, about the same time, I used the web service to build a demo for JPMorgan Chase, and I think it's actually pretty slick.

Craig Randall used to work on this project, but last year he moved on to work for Adobe, check http://craigrandall.net/.

It's sad that you see all these good people are leaving, and Documentum is kind of down......after all, documentum is my main skill to earn a living for about 5 years.

xdoclet

Basically, you put some tags on the bean class, and xdoclet will generate interface, remote interface, and ejb.xml, xml files for weblogic and websphere....

http://xdoclet.sourceforge.net/xdoclet/index.html

Reverse-xdoclet

http://www.gootz.net/gbin/reverse-xdoclet/

What this does is, you already have Bean, interface, xml....but you want to the bean class to have xdoclet tags, reverse-xdoclet will do it for you.

Every Day Shortcut Key

Shortcuts:
Fn + PgUp: turn light on/off.
Fn + Home: increase brightness.
Fn + End: decrease brightness.
F6: in a web browser, hit F6 will activate address bar.
CTR + tab: tab through web browser tabs.
START + D: toggle desktop
START + Pause: Display the System Properties dialog box
START + R: Open the Run dialog box
START + L: Lock computer or Switch user
CTR + Esp: Open Start Menu
ALT + F4: Quit Program
CTR + W: Close Window
CTR + START + F: search computer in network

Commands:
control -> open control panel
calc -> calculator
control admintools ->Admin Tools
sysdm.cpl->System properties

control desktop->Open Personalization
desk.cpl->Display properties
services.msc->Services
devmgmt.msc->Device Manager
lusrmgr.msc-> User Accounts
osk->on screen keyboard
winchat->windows chat
appwiz.cpl->Add/Remove Program
clipbrd->clipboard viewer
intl.cpl->Regional Settings
iexplore->IE
winver->Check Windows Version
winword->Office Word
excel->Office Excel
powerpnt->Office PowerPoint
textpad->TextPad
timedate.cpl->Time Panel
mmsys.cpl->Sound and Audio

taskmgr.exe->Start Task Manager

http://windows.microsoft.com/en-US/windows-vista/Keyboard-shortcuts
http://mypchell.com/guides/34-guides/69-156-useful-run-commands

Quick Establishment on Database

create a user account

create user haibo_comr identified by pass;
grant dba to haibo_comr;

DbHostname: 127.0.0.1
DbPort: 1521
DbDatabase: my_database
DbUsername: Haibo_comr
DbPassword: pass

Script need this kind of information to access to database, so it could create all the tables.

1. build a database quickly---MySQL probably the best option.
2. write an utility to load/unload tables by using xml files as inputs.
3. ORM (object-oriented mapping), so could write Java codes against DB quickly. Hibernate?
4. Store the whole environment: VW Mare image.

Refcardz DZone

Joined Refcardz DZone


Look like a good place to catch some new technologies.

Just learnt: Eclipse Helios (3.6.0) already released.

Also Eclipse SDK 4.0 is on the way.

Groovy

groovy: An agile dynamic language for the Java Platform.

A quick introduction:


Installation:
1. It's zip file, just unzip it to some directory. For example: C:\groovy-1.7.2.
2. Go to C:\groovy-1.7.2\bin, execute groovyConsole.bat (windows) or groovyConsole (Unix).
3. Now you have a groovy console. Now this is what I need, I really don't have much interest to learn some new grammar, but GroovyConsole recognize the normal Java codes too, so I would like to use GroovyConsole as a Java Console. In this way, I could execute some simple Java codes directly in console.
4. How to add some existing library? Script->Add Jar to classpath or Add Directory to classpath.

For example, if I want to test some methods for StringUtils, I just need download the jar, and add it to classpath. Write some codes in Script console:

import org.apache.commons.lang.StringUtils;

String str = StringUtils.leftPad("999", 5, 'x');
System.out.println(str);

*****

Basically just treat the console as a Java file, the nice thing about it is you don't need to compile the codes.

Strange thing: seem Groovy Console doesn't like String[] stars = {"Tom", "Sam"};

But it's ok to use String[] stars = ["Tom", "Sam"];

System.out.println == println

println "${new Date()}"

****************************
class HelloWorld
{
def name
def greet() { "Hello ${name}" }
}

def helloWorld = new HelloWorld()

helloWorld.name = "Groovy"

println helloWorld.greet()

Unix Grep

grep "BusinessStatus" -B10 -A2 importList-Test.xml > output.xml

General meaning: get some stuff from importList-Test.xml, and put it into output.xml.

What stuff? lines which contain "BusinessStatus" + 10 lines before it + 2 lines after it.

This is very useful to extract certain patterned-contents from a large file.

find . -name "*Bean.java" -exec echo "==={}:" \; -exec grep "re\"DefaultDataSource\"" -B1 -A3 {} \;

find . -name "*Extent.java" -exec grep "CLASSNAME =" '{}' > output.xml \;

BlazeDS

turnkey means ready to use.

Is BlazeDS the best (or one of the best) Java way to send back-end data to the front-end?

How about Web Service?

Here is the benchmark:


By Default

By default, you will get some benefits automatically, isn't that nice? Yes, it's really good until you want to know more.

Ok, let me explain. In SQL, ORDER BY keyword sort the records in ascending order by default. That's nice, but what if you want to sort the records in descending order? If you don't know that SQL sort by ascending order by default, you might get confused a little bit. That's just most simple example.

Now, coming into the framework. We now have all sorts of frameworks, and their purpose, simply put, is to make the life easier for us (the developers), but does they?

Let's use Spring as an example. I am saying this is the only benefit, but one of the most basic benefits to use Spring is you don't need write a lot of Java class, all you need is fill up some xml configuration file, and Spring will do this automatically for you. But do you know that all Spring beans are singletons by default? What if you don't want your bean to be singleton? That's where confusion starts.

See the problem, so far? All the frameworks have these default rules, and you must know all these rules to utilize the most benefits, and these are the pains that you have to suffer for the gains.

One of the most import lessons that I have learnt by studying these frameworks is to pay attention to the keyword "default".

StringUtils and others

org.apache.commons.lang.StringUtils

very useful to format Strings

//left(): get the leftmost len characters of a String.

StringUtils.left("abc", 0) ==> ""
StringUtils.left("abc", 1) ==> "a"
StringUtils.left("abc", 2) ==> "ab"

StringUtils.leftPad("999", 4, '0') ==> "0999"
StringUtils.leftPad("999", 5, '0') ==> "00999"

StringUtils.rightPad("999", 4, '0') ==> "9990"
StringUtils.rightPad("999", 5, '0') ==> "99900"

StringUtils.stripToEmpty(null) = ""; //very useful to convert null to empty String.
StringUtils.stripToEmpty(" abc") ==> "abc"
StringUtils.stripToEmpty(" abc ") ==>"abc"
StringUtils.stripToEmpty(" a bc ") ==>"a bc"


StringUtils.isBlank(null) ==> ture
StringUtils.isBlank("") ==> true
StringUtils.isBlanck(" ") ==> true

more often we use isNotBlank(myString) //to make sure myString is a valid non-empty string.


//the only difference is whitespace is not considered as isEmpty.

StringUtils.isEmpty(null) ==> ture
StringUtils.isEmpty("") ==> true
StringUtils.isEmpty(" ") ==> false //see the difference with isBlank

String[] doesn't have a method called contains, but you could use ArrayUtils.contains

String[] stars = {"Tom", "Sam"};
ArrayUtils.contains(starts, "Sam") ==> true