2007-08-28

Automatic Login to google with WScript.

WScript is the short name for Windows Script. It can be a VBScript or JScript(not Javascript but a Microsoft standard!) If we use it properly, it can save us a lot of work. Here is an example for a script which can be used to login in google account automaticly.

var ie=WScript.createobject("InternetExplorer.Application");
var args = WScript.arguments;
var followme="http://www.google.com/";
if(args.length>0)
{
followme
+=args(0);
}
ie.Navigate(
"https://www.google.com/accounts/Login?continue="+followme);
SynchronizeIE();
var doc=ie.document;
doc.forms[
0].Email.value="yourName@gmail.com";
doc.forms[
0].Passwd.value="^your password";

//because the checkbox "PersistentCookie" appears randomly
if(doc.forms[0].PersistentCookie!=null)
{
doc.forms[
0].PersistentCookie.checked=false;
}
doc.forms[
0].submit();
SynchronizeIE();
ie.Visible
=true;

//wait for IE finishs its job
function SynchronizeIE()
{
while(ie.Busy)
{
WScript.Sleep(
100);
}
}

Save the code as googleSpecific.js and make it under the %windir%\system32, then create a file called google.bat under the same path with the content:

@cls

@wscript %windir%\system32\googleSpecific.js %1 %2 %3 %4 %5 %6 %7 %8 %9

After that, execute "google mail" in command promp, you can log in your gmail directly now.

Other commands are:
google notebook
google bookmarks
If you type "google" without any parameters, you will sign in with the google.com.

2007-08-23

Eclipse 3.2.2 with JBoss Server 4.2.1

Since I want to try the new version of JBoss Server, I downloaded the newest Version of it and unzip it to a folder. Just like usual, I go to the eclipse workbench and select file | new | other | server | next, then I can see 2 entries for JBoss server which are the v3.2.x one and the v4.0.

Chosing the 2nd option I get the error :

Missing classpath entry C:\jboss-4.2.1.GA\server\default\lib\javax.servlet.jar

As far as I know, from the version 4.x of the Jboss Server, it already includes the EJB. So the only reason for that error should due to a not correct server definition.

Internet is a good place to find the answer. Thanks to Wolfgang Knauf, we have some new JBoss server definitions here: http://www.informatik.fh-wiesbaden.de/~knauf/public/

There are two different jars for WTP 1.5 and 2.0.

To use the plugin:
  • JBoss 4.0.x: You MUST have installed the EJB3 RC9 to the default configuration so that the plugin can find all required libraries.
    For JBoss 4.0.4 with installer including EJB3 RC8 this is done automatically.
    For EJB3 RC 9 there is no JBoss AS installer, it must be installed to the default configuration manually. Later you can install EJB3 RC9 to any other configuration, the jars from the default configuration are only needed for starting up application clients and for Eclipse.
  • JBoss 4.2.0: the default configuration must be present so that the plugin can find all required libraries (tested for CR1 to GA)
  • JBoss 5.0.0: the default configuration must be present so that the plugin can find all required libraries (tested for Beta2)
  • Delete previous versions of this plugin if already installed.
  • Download org.eclipse.jst.server.jboss.ejb3_1.5.0.v200706052200.jar
  • Copy the file to the subdirectory "plugins" of your eclipse installation.
  • Restart eclipse once with the "-clean" option: "eclipse -clean".
  • Create a new server runtime. You will find the runtimes in the "JBoss" branch, labeled "JBoss 4.0.4 or 4.0.5 with EJB3 RC8 or RC9", "JBoss 4.2.0" or "JBoss 5.0"
So enjoy it!

2007-08-20

Deleted Files under FreeBSD

In last week I made a mistake by deleting some documents on a server which runs FreeBSD. Three seconds after I typed "rm -r *.*" and pressed Enter, I'd realized I made a big mistake. There is always a thing called "recycled bin" in Windows or GUIs in Linux, but not for such a situation with text command. So, I searched in my poor memory and tried finding some tools under FreeBSD just like "undelete" under sweet DOS. The only result and choice is: testdisk.
Exactly saying, PhotoRec, which can be downloaded here.

It's really sad for me to find out that there is only FreeBSD port for testdisk, which can be easily installed by typing "pkg_add -r testdisk", but not for PhotoRec. The only way is downloading the source and compiling by yourself. I must admit that I didn't make it done. So I was almost mad when I realized there is no kind of softwares that can rescue the deleted files under FreeBSD.

The solution to this disaster: for some luckies I made a backup before several months and it includes the files that I deleted! So here is the lesson I've learned: ALWAYS make backups before you do something! Today is just losing some files, what happens if our hard disks die?

Like some words I saw elsewhere:

Love, just like you've never been hurt,
Live, just like you will die tomorrow,
Sing, even if nobody is listening.

We can add an extra line to that:

Backup, 'cause you will never know when your hard disks want to die.

2007-08-13

Gospel of Tux unearthed!

Every generation has a mythology. Every millenium has a doomsday cult. Every legend gets the distortion knob wound up until the speaker melts. Archeologists at the University of Helsinki today uncovered what could be the earliest known writings from the Cult of Tux, a fanatical religious sect that flourished during the early Silicon Age, around the dawn of the third millenium AD...

The Gospel of Tux (v1.0)

In the beginning Turing created the Machine.

And the Machine was crufty and bogacious, existing in theory only. And von Neumann looked upon the Machine, and saw that it was crufty. He divided the Machine into two Abstractions, the Data and the Code, and yet the two were one Architecture. This is a great Mystery, and the beginning of wisdom.

And von Neumann spoke unto the Architecture, and blessed it, saying, "Go forth and replicate, freely exchanging data and code, and bring forth all manner of devices unto the earth." And it was so, and it was cool. The Architecture prospered and was implemented in hardware and software. And it brought forth many Systems unto the earth.

The first Systems were mighty giants; many great works of renown did they accomplish. Among them were Colossus, the codebreaker; ENIAC, the targeter; EDSAC and MULTIVAC and all manner of froody creatures ending in AC, the experimenters; and SAGE, the defender of the sky and father of all networks. These were the mighty giants of old, the first children of Turing, and their works are written in the Books of the Ancients. This was the First Age, the age of Lore.

Now the sons of Marketing looked upon the children of Turing, and saw that they were swift of mind and terse of name and had many great and baleful attributes. And they said unto themselves, "Let us go now and make us Corporations, to bind the Systems to our own use that they may bring us great fortune." With sweet words did they lure their customers, and with many chains did they bind the Systems, to fashion them after their own image. And the sons of Marketing fashioned themselves Suits to wear, the better to lure their customers, and wrote grave and perilous Licenses, the better to bind the Systems. And the sons of Marketing thus became known as Suits, despising and being despised by the true Engineers, the children of von Neumann.

And the Systems and their Corporations replicated and grew numerous upon the earth. In those days there were IBM and Digital, Burroughs and Honeywell, Unisys and Rand, and many others. And they each kept to their own System, hardware and software, and did not interchange, for their Licences forbade it. This was the Second Age, the age of Mainframes.

More: http://www.ao.com/~regan/penguins/tux.html

2007-08-09

The confusing difference beweteen different JOINs in SQL

There are two kinds of JOINs: one is INNER JOIN, the other is OUTER JOIN.

Sounds like similar, but very different:

INNER JOIN means the result of a query should exist in the source tables.
OUTER JOIN means the result of a query CAN be some NULLs partially.

INNER JOIN is a keyword of SQL, but OUTER JOIN not.
OUTER JOIN includes two types JOINs: one is LEFT JOIN, the other is RIGHT JOIN,

NOTICE: LEFT JOIN & RIGHT JOIN are keywords of SQL.

Now let's look at some examples to understand things more clearly.

Given two tables:

TABLE 1: exam

ID Score
------------------------
1 A-
2 B+
5 C-

TABLE 2: student

ID Name
------------------------
1 Joe
5 Geogre
7 Ben

First SQL query:
SELECT e.ID, s.Name, e.Score FROM exam AS e INNER JOIN student AS s ON s.ID=e.ID;

So we get:

ID Name Score
-----------------------------
1 Joe A-
5 Geogre C-

In fact, this query is equaled to:
SELECT e.ID, s.Name, e.Score FROM exam AS e, student AS s WHERE s.ID=e.ID;

Second SQL query:
SELECT e.ID, s.Name, e.Score FROM exam AS e LEFT JOIN student AS s ON s.ID=e.ID;

We should get the following this time:
ID Name Score
-----------------------------
1 Joe A-
2 NULL B+
5 Geogre C-

Third SQL query:
SELECT e.ID, s.Name, e.Score FROM exam AS e RIGHT JOIN student AS s ON s.ID=e.ID;

We should get the following this time:
ID Name Score
-----------------------------
1 Joe A-
5 Geogre C-
7 Ben NULL

So you find the difference!

LEFT JOIN will try to find every match for the table BEFORE the statement LEFT JOIN, when nothing matched can be found, then a NULL will be used.

RIGHT JOIN will try to find every match for the table AFTER the statement RIGHT JOIN, when nothing matched can be found, then a NULL will be used.

2007-08-02

QuantumDB Eclipse Plugin

Today I've tried the famous QuantumDB Eclipse Plugin, It's really a powerful database management tool and supports many different databases.

To install it, open Eclipse and select from the menu "help"->"Software updates"->"Find and Install..."->"Search for new features to install"->"new remote site", then type the update URL: http://quantum.sourceforge.net/update-site, then click next...

Note: Quantum needs the GEF plugin to work, so you have to install it before installing Quantum. That plugin can be installed via an already built-in remote site: "Callisto Discovery Site".

After successful installation, I was really frustrated to figure out that the Quantum comes with only TWO connector:

  1. JDBC to ODBC bridge
  2. MS Access

If we want to use MySQL, we must get the connector jar! Now it's called MySQL Connector / J. Go to that page and download the package.

Tip: you don't need to register or sign in when you click "select a mirror", just find the gray text "No thanks, just take me to the downloads!".

Extract all things in a folder, you can find a file called like mysql-connector-java-5.0.7-bin.jar. You need to do the following to add support of MySQL driver:

  1. Go to eclipse and switch to the view "Quantum DB" by clicking the top right icon near to "Java". Add a new bookmark by right click on the left "database bookmarks" panel.
  2. Now click "Add driver", find "mysql" in the dropdown list "type", then click "add external jar", point to the file mysql-connector-java-5.0.7-bin.jar.
  3. Click the "browse" button for the class name "com.mysql.jdbc.Driver", then go on clicking many "OK" buttons.

So now do the step again and select "mysql" as connector, a dialog will be shown to let you input some infos of the mysql database you want to connect. That is it!