Friday, July 31, 2009

Add MP3 support in Fedora

Unfortunately Fedora cannot include support for MP3 or DVD video playback or recording. MP3 formats are patented, and the patent holders have not provided the necessary licenses. Fedora also excludes other multimedia software due to patent, copyright, or license restrictions, such as Adobe Flash Player and RealNetworks RealPlayer.
Adding MP3 support to your fedora installation is a simple process. The steps are as below:
(a) Launch terminal and issue command "su" and enter the root password.
(b) copy and paste the following command and press enter:
rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
(c) once the above command finishes, issue the following command:
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
(d) Now, Install all other plug ins..
yum -y install gstreamer-plugins-bad gstreamer-plugins-ugly xine-lib-extras-nonfree

Installing Glassfish server adapter for Eclipse

Installing and running the Sun Glassfish server on a windows machine on any port number is simple out of the box. The installer from Sun allows you to configure the HTTP port number as well as the Admin port number. Yes, the port numbers for the Admin console and HTTP server are different compared to Tomcat or Apache Geronimo or IBM Websphere Community Edition.
Once the server is installed developers will need the Glassfish server adapter for Eclipse, which can be installed using any of the following ways: 
(a) using the "Download Additional Server Adapters" from within Eclipse IDE for which instructions can be found at
    https://glassfishplugins.dev.java.net/eclipse34/
(b) download the jars and install the plugin manually. jars to download can be found at
    https://glassfishplugins.dev.java.net/download/index.html
You will need to download 2 jar files: Plugin jar and the Feature jar, you will need to extract then into the plugins and the features directory respectively. Also, note that these jars have to be extracted in a folder named with the same name as the jar files.
Using one out of the above two steps you should be able to install the Glassfish server adapter in Eclipse with WTP plugins.
However, if for any reasons you do not find the option to add the Glassfish server after following the above steps, you can follow the steps below:
1. Click on Help -> Software Updates
2. Click on the "Available Software" tab and then click on "Add site"
3. Enter the location 
          https://ajax.dev.java.net/eclipse
and click on OK.
4. Once the location is added into the "Available Software" list you can expand it and select the plugins to install.
5. You will need to accept the security certificate to complete the installation.
6. Restart Eclipse and you will find the Glassfish server adapter in the list to add a new server.

How to remove GRUB from Vista patition

If you simply remove the Linux partition, GRUB (Linux boot loader) will still be on your PC (in control if it was installed on the first partition / default location). 
So you need to restore your Master Boot Record (MBR) for Vista (so that Vista will handle the booting, not GRUB).
Here is how to repair/restore your Master Boot Record (MBR)
1. Put the Windows Vista installation disc in the disc drive, and then start the computer.
2. Press a key when you are prompted.
3. Select a language, a time, a currency, a keyboard or an input method, and then click Next.
4. Click Repair your computer.
5. Click the operating system that you want to repair, and then click Next.
6. In the System Recovery Options dialog box, click Command Prompt.
7. Type Bootrec.exe /FixMbr, and then press ENTER.
That's it. Now when you reboot your PC, Vista will load automatically.

Tuesday, July 28, 2009

Events and Event Handlers - HTML Form Elements

What are events?

Events allow you to write JavaScript code that reacts to certain situations. Examples of events include:
  • The user clicking the mouse button
  • The Web page loading
  • A form field being changed

Event handlers

To allow you to run your bits of code when these events occur, JavaScript provides us with event handlers. All the event handlers in JavaScript start with the word on, and each event handler deals with a certain type of event. Here's a list of all the event handlers in JavaScript, along with the objects they apply to and the events that trigger them

Event handler
Applies to: Triggered when:
onAbort Image The loading of the image is cancelled.
onBlur Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window The object in question loses focus (e.g. by clicking outside it or pressing the TAB key).
onChange FileUpload, Select, Text, TextArea The data in the form element is changed by the user.
onClick Button, Document, Checkbox, Link, Radio, Reset, Submit The object is clicked on.
onDblClick Document, Link The object is double-clicked on.
onDragDrop Window An icon is dragged and dropped into the browser.
onError Image, Window A JavaScript error occurs.
onFocus Button, Checkbox, FileUpload, Layer, Password, Radio, Reset, Select, Submit, Text, TextArea, Window The object in question gains focus (e.g. by clicking on it or pressing the TAB key).
onKeyDown Document, Image, Link, TextArea The user presses a key.
onKeyPress Document, Image, Link, TextArea The user presses or holds down a key.
onKeyUp Document, Image, Link, TextArea The user releases a key.
onLoad Image, Window The whole page has finished loading.
onMouseDown Button, Document, Link The user presses a mouse button.
onMouseMove None The user moves the mouse.
onMouseOut Image, Link The user moves the mouse away from the object.
onMouseOver Image, Link The user moves the mouse over the object.
onMouseUp Button, Document, Link The user releases a mouse button.
onMove Window The user moves the browser window or frame.
onReset Form The user clicks the form's Reset button.
onResize Window The user resizes the browser window or frame.
onSelect Text, Textarea The user selects text within the field.
onSubmit Form The user clicks the form's Submit button.
onUnload Window The user leaves the page.

Monday, July 27, 2009

How To Fix Your Own Neck, Upper Back, and Shoulder Pain

This is for all the programmers and people who have to work extensively on the computer and suffer from pain in neck, shoulder and upper back. The article on the web site is very useful and hope will be useful for anyone reading this.
        http://www.drbookspan.com/NeckPainArticle.html

Sunday, July 26, 2009

JavaScript forEach equivalent

Here's a short example of doing the forEach loop equivalent in JavaScript:
var names = ["Chris","Kate","Steve"];

for ( var i in names )
{
   alert( names[i] );
}

Update your Email Regex - JavaScript

Regular Expressions are a common tool in aiding developers to write compact matching functions which are frequently used for error checking on forms. In particular, one of the most common fields to appear on a form is an email field. And with the emergence of newer email syntax behaviors like appending the ‘+’ (plus sign) symbol which allows Gmails users to filter incoming mail to be sorted by folder, tagged with a star, and/or directly archived, there is a need for an updated common regular expression.

Let’s look at the most common email regular exression:

Common Email Regular expressions

var pattern = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

This pattern matches anything that has ‘one of more of’ a through z (lowercase and/or uppercase), 0 through 9, an underscore (_), a dot (.), or a hyphen(-)…. Then followed by a required @ symbol. Then followed by (a through z (upper and/or lower), and/or 0 through 9, and/or a hyphen) followed by a required dot (.). Then lastly followed by an alpha-numeric string that is 2 to 4 characters long. This now allows Gmail users to add their filtered addresses such as user+filter@gmail.com. I hope this short tip was helpful. Enjoy!

Ok, take a deep breath. What’s missing?. That ‘addition’ symbol. So without looking too much farther, and without having to explain it all over again, here is our revised regular expression.

Revised and New Regular Expression

var pattern = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

This now allows Gmail users to add their filtered addresses such as user+filter@gmail.com. I hope this short tip was helpful. Enjoy!

Sending Email using PHP

SMTP E-mail sending class can be found at

http://www.phpclasses.org/browse/package/14.html

You will also need to download another project from the author, "Simple Authentication and Security Layer" from

http://www.phpclasses.org/browse/package/1888.html

you will need 2 files from the second project - login_sasl_client.php & sasl.php

you will also need to customize the file 'test_smtp.php' or rather write your own file using the sample php file provided.

Configuring PHP to send mails on Windows

In a WAMP set up (Windows Apache, MySQL, PHP) by default mail won't work because there is no SMTP server on the localhost.

By changing the PHP.ini file it can be enabled to use a different (remote) email gateway. Amend the following section:
[mail function]
; For Win32 only.
SMTP = some.email.server.com
smtp_port = 25

Saturday, July 25, 2009

Creating Oracle Connection in Glassfish

1. Click on "JDBC" under "Resources" on "Common Tasks" on the left hand side in the admin console of GlassFish.
2. Click on "Connection Pools" on the right pane.
3. Click on the "New" button.
4. Enter a name for the connection pool, select Resource Type: javax.sql.DataSource, select Database Vendor: Oracle
5. Delete all properties, and add following properties:
  • user - set this to Oracle userid
  • password - set this to Oracle password
  • URL - set this to the URL, example jdbc:oracle:thin:@localhost:1521:DATABASENAME
6. Save the connection pool.
7. Now, create a new JDBC Resource, which will have a JNDI name to which your application will refer to.
8. Configuration settings required in the web.xml file and sun-web.xml:
  • unlike tomcat you wont need a \META-INF\context.xml file.
  • configure the JNDI for your application in web.xml, following is an example:
    • <resource-ref>
      <res-ref-name>jdbc/OracleTest</res-ref-name>
      <res-type&gt;javax.sql.DataSource</res-type>
      <res-auth&gt;Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
  • configuration for sun-web.xml:
    • <resource-ref>
      <res-ref-name>jdbc/OracleTest</res-ref-name>
      <jndi-name&gt;jdbc/OracleTest</jndi-name>
      </resource-ref>
jdbc/OracleTest is the JNDI name configured for the Connection Pool that we have created above in the admin colsole of GlassFish.
You can now use java:comp/env/jdbc/OracleTest for look up and connect to the database.

The lib directory of Tomcat in Glassfish

All your JARs which you need for your application goes into the folder:

glassfish/glassfish/domains/domain1/lib/ext

Versions of JDK required for different J2EE application servers

After installing and facing different issues with different J2EE application servers I have observed that Apache Geronimo and IBM Websphere Community Edition both works fine on JDK 1.6 update 1 and above*

Sun Glassfish gets installed on JDK 1.6 update 1, but after installation the admin console does not loads. This can be resolved by upgrading to JDK 1.6 update 14.

However, IBM Websphere Community Edition and Apache Geronimo are both similar. IBM Websphere Community Edition is based on Apache Geronimo, so they both have similar interface and configuration options.

* I have installed the above application servers on JDK 1.6 update 1 and JDK 1.6 update 14 only.