HTML : Easiest way to create simple tooltips

Tooltips are the ones which appear as little bubbles with text, when you mouse hover over an item on Web-page.

In HTML, it is very easy to create them.

Simply add 'title' attribute to the element.

Examples:

<a title="Tooltip for Anchor !" href="someLink" >Gliding Phenomena Blog </a>

<img title="Tooltip on an Image..." src="myPic.jpg"  />

<div title="This is tooltip for the entire DIV">

Some content.

Blah 

Blah

</div>

SQL : Update only year in the date field

UPDATE mytable
SET datefield = CONCAT('2012','-',MONTH(datefield),'-',DAYOFMONTH(datefield))
WHERE YEAR(datefield) = 2006;

Javascript: Regex for Email Validation


function isValidEmail(email){
 var emailRegx = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
 return emailRegx.test(email);
}

Mac: Show/hide Hidden files in Mac OS

To Show Hidden files run the following 2 commands in the terminal

defaults write com.apple.finder AppleShowAllFiles TRUE

killall Finder


To Hide Hidden files run the following 2 commands in the terminal.

defaults write com.apple.finder AppleShowAllFiles FALSE

killall Finder

Draw Smooth Circles in JAVA instead of jagged edge circles.

Usually when we draw circles/ovals using Graphics2D in JAVA, we get jagged edges.
Following example creates smooth edges to the circle.
The key is g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

public class DrawSmoothCircle {
public static void main(String[] argv) throws Exception {
BufferedImage bufferedImage = new BufferedImage(100,100, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bufferedImage.createGraphics();

g2d.setRenderingHint (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setPaint(Color.green);
g2d.fillOval(10, 10, 50, 50);
g2d.dispose();

ImageIO.write(bufferedImage, "png", new File("newimage.png"));
}
}

Unix: Check unix/linux machine hardware configurations


$ uname -a
Linux comp0.abc.xyz.org 2.6.18-164.11.1.el5 #1 SMP Wed Jan 20 07:32:21 EST 2010 x86_64 x86_64 x86_64 GNU/Linux


$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 15
model  : 65
model name : Dual-Core AMD Opteron(tm) Processor 2220
stepping : 3
cpu MHz  : 2800.098
cache size : 1024 KB
physical id : 0
siblings : 2
core id  : 0
cpu cores : 2
apicid  : 0
fpu  : yes
fpu_exception : yes
cpuid level : 1
wp  : yes
flags  : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips : 5600.19
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc


Mac : check if my intel based Mac is 32-bit or 64-bit

1. Choose About This Mac from the Apple () menu in the upper-left menu bar
2. See what Processor it has.
3. Compare your Processor Name to information below to determine whether your Mac has a 32-bit or 64-bit processor.


Processor Name  
32- or 64-bit
Intel Core Solo
32 bit
Intel Core Duo
32 bit
Intel Core 2 Duo
64 bit
Intel Quad-Core Xeon
64 bit
Dual-Core Intel Xeon
64 bit
Quad-Core Intel Xeon
64 bit

Source: Extracted from http://support.apple.com/kb/ht3696

Unix: Running processes in parallel in unix shell

By using the ampersand '&' , we can run processes in parallel. Example 1: Consider the following script

for i=0; i<10;i++
do
 cat inp$i.txt;
done

The above script would run sequentially executing cat inp1.txt; cat inp2.txt; cat inp3.txt' ..... We can issue these processes in parallel by using '&' instead ';'

for i=0; i<10;i++
do
 cat inp$i.txt &
done

Example 2:

$ runprog1; runprog2; runprog2;

Above statement would execute sequentially.

$ runprog1&runprog2&runprog2&

Above statement would execute all in parallel

$ (runprog1; runprog2; runprog2;)&

Above statement would start processes sequentially and then execution is parallel.

Displaying the AJAX content in a separate window

Write the following piece of code in your call back function to display the AJAX content in a separate browser window.
function(data) {
var myWindow = window.open('','Name of the Window','');

myWindow.document.open();
myWindow.document.write(data);
myWindow.document.close();
}

Note: You need to make sure your browser pop up blocker has disabled.

CakePHP: remove cakePHP Flash messages using JQuery

Typically you would have all the cakePHP flash messages inside the div - alert_messages.

By using JQuery, we can remove these after intended time period.
The following example removes the cakePHP flash message after 5 seconds time period.

$(document).ready(function() {
  $('#alert_messages').animate({opacity: 1.0}, 5000).fadeOut();  
});

style.display=‘none’ doesnt work on option tags in Chrome, IE

We cannot set a style, display:none on OPTION TAG in Chrome and IE, It can be done in Firefox !

Kinda Solutions :

1. Use disabled attribute for the OPTION

2. If you want to remove them permanently, use removeChild to delete the option.

3. If you want them to show/hide, then u might have to save the removed options into a javascript variable.

jQuery: Select all options in a Multiple-option Select Box

The following code will programmatically select all the options in a multiple-option Select box. Assuming you have jQuery setup.
$("#selectAllButt").click(function() {
  $("#mySelectList option").each(function() {
    $(this).attr("selected","selected");
  });
});

The following code will programmatically UN-Select all the options in a multiple-option Select box.
$("#selectNoneButt").click(function() {
  $("#mySelectList option").each(function() {
    $(this).removeAttr("selected");
  });
});

jQuery: Get checked checkboxes, radio buttons using Pseudo selectors

jQuery Pseudo Selectors are very efficient way to get the checked checkboxes or radio buttons.
The Pseudo Selector used is - :checked

Following are some simple examples to follow:
$("#chkBoxIdOrRadioButtId").is(":checked");
- returns a boolean true if checked or false
$("#chkBoxIdOrRadioButtId").not(":checked");
- returns a boolean true if unchecked or false
$("#chkBoxIdOrRadioButtId").attr('checked','checked');
- programmatically check the desired.
$("input:radio[name='myRadioGrpName']:checked").val();
- return the value of the checked radio from the 'myRadioGrpName' group.
$("input[name='myChkBoxGrp']:checked").length;
- returns the count of the checked
$("input[name='myChkBoxGrp']:not(:checked)").length;
- returns the count of the unchecked

jQuery : Get the number of options in a select box

Using jQuery to get the number of options in a select box
$('#mySelectBoxId option').length;

Using jQuery to get the number of options that are selected in a select box
$('#mySelectBoxId option:selected').length;

jQuery, CakePHP: Submit a form using ajax; implementing "quick save"

In CakePHP, If you want to submit a FORM using an AJAX request, use jQuery Form Plugin.

You can find a detailed example at http://marcgrabanski.com/article/cakephp-ajax-quick-save-jquery

An alternative to this plugin is invoking a javascript function, when a submit button is clicked, and which would read all the input data inside the form and send it to the controller.

Tcl/Tk: How to find out the Tcl version

How to find out the Tcl version

[yourLoginPrompt]$ tclsh
% info patchlevel
8.4.13
% puts $tcl_version
8.4
% info tclversion
8.4
%

Javascript: Make indexOf function working in IE

The indexOf function is a recent addition to the ECMA-262 standard and newly introduced in JavaScript 1.6, hence it may not work in some browsers. You can work around this by inserting the following piece of code at the beginning of your scripts.

Note: This function will work in FF1.5 or above, because this algorithm is exactly the one used in Firefox and SpiderMonkey(is the code-name for the Mozilla's C implementation of JavaScript).

if(!Array.indexOf) {
  Array.prototype.indexOf = function(obj) {
    for(var i = 0; i < this.length; i++) {
      if(this[i] == obj) { return i; }
    }

    return -1;
  }
}

Javascript: Easy Javascript Debugging using Firebug Console.

Instead of using the traditional 'alert' statements for debugging, the best way to debug is using Firebug console.
What you need : Firefox browser and Firebug addon

A simple example:
INSTEAD OF :

function foo() {
 if(some condition) {
    alert("Status update");
  }
}

USE :

function foo() {
 if(some condition) {
  console.log("Status update");
 }
}

For more details : http://getfirebug.com/logging

cakePHP: Passing multiple parameters from view to controller in cakePHP

There is no direct specification for passing multiple parameters from view (.ctp file) to controller (.php file) in cakePHP. It is intuitive !
The format of the url with a single parameter look like : ../myApp/myController/myFunction/parameter1

To pass multiple parameters simply append at the end which might look like
../myApp/myController/myFunction/parameter1/parameter2/parameter3

Some generic ways are:
1.
array ('action' = '/myFunction/'. $id .'/'.$another_id); 

2.
$Html-> link ('edit', array ('url'='/ myController/myFunction? Id ='. $Id. '& another_id ='. $another_id)). 


3.
$Html-> link ('edit', array ('action' = 'myFunction', $id,$another_id)). 


The function in myController would look like:
 function myFunction ($id, $another_id){
   // do something
}

Date formatting in JavaScript

We would be using 3 different methods to get the current system date, month and year.
  • getDate() : Returns the date
  • getMonth(): Returns the month
  • getFullYear(): Returns the year
#1: month/date/year (5/12/2010)

var date = new Date();
var sysDate = date.getDate();
var sysMonth = date.getMonth();
var sysYear = date.getFullYear();

document.write(sysMonth + "/" + sysDate + "/" + sysYear);

#2: date-month-year (12-May-2010)

var date = new Date();
var sysDate = date.getDate();
var sysMonth = date.getMonth();
var sysYear = date.getFullYear();

var monthNames = new Array("January", "February", "March",
               "April", "May", "June", "July", "August", 
               "September", "October", "November", 
               "December");

document.write(sysDate + "-" + monthNames[sysMonth] + "-" + sysYear);

#3: date-month-year (12th May 2010)

var date = new Date();
var sysDate = date.getDate();
var sysMonth = date.getMonth();
var sysYear = date.getFullYear();

var monthNames = new Array("January", "February", "March",
               "April", "May", "June", "July", "August", 
               "September", "October", "November", 
               "December");

var sup = "";

if(sysDate == 1 || sysDate == 21 || sysDate == 31) sup ="st";
else if (sysDate == 2 || sysDate == 22) sup = "nd";
else if (sysDate == 3 || sysDate == 23) sup = "rd";
else sup = "th";

document.write(sysDate + "" + sup + " " + monthNames[sysMonth] + " " + sysYear);

jQuery: Using jQuery with Other Libraries

Ever faced a problem to use jQuery with other Library ?
By default, jQuery uses "$" as a shortcut for "jQuery"

jQuery provides the convenience by defining our own shortcut which eliminates the conflict.
A simple example

<script src="jquery.js"> </script>
<script src="prototype.js"> </script>

<script type="text/javascript" >
jQuery.noConflict()  //now by default, $ is jQuery.
  //But you can reassign it to your own variable.
    var $jq = jQuery;
    //start using $jq for jquery's $
    $jq(document).ready(function() {
    $jq("div").hide();    });
</script>

Open a File Browser From Your Current Command Prompt/Terminal Directory


Open Finder in Mac OS X, the terminal type
open .

Open a File Browser in Windows, in the command prompt type:
explorer .
OR
start .

Open a File Browser in Linux, in the terminal type
nautilus .
OR
gnome-open .


PHP: Comparing dates/date strings in PHP

Comparing Date strings in PHP is easy using strtotime function.
The strtotime function returns # of seconds since Jan 1,1970 UTC.

Simple example:
$strtDate = strtotime("2009-10-3");
$endDate = strtotime("2010/11/9");
if($strtDate > $endDate){
 // do something
}
if($strtDate < $endDate){
 /do something
}

CSS/HTML : ID or CLASS attribute? Which one to use when ?

A simple, yet powerful classification of the DOM elements can done using the element attributes ID and CLASS. By giving a CLASS attribute, we can refer/select MULTIPLE elements with the same class. Example:

<div class="myclassA">first content</div>
<div class="myclassA">second content</div>
<div class="myclassA">third content</div>

Once we have such layout, we can access all the div's easily, some of them would be: 1. In the .CSS file as :

.myclassA{
 color : red;
}

2. If ur using JQuery:

$(".myclassA").css("color", "blue");

By giving a ID attribute, we can refer/select EXACTLY one element with that ID. Example:

<div id="myDivIdA">first content&lt;/div>
<div id="myDivIdB">second content</div>

Once we have such layout, we can access EXACTLY one div easily, some of them would be: 1. In the .CSS file as :

#myDivIdA{
 color : red;
}

2. If ur using JQuery:

$("#myDivIdB").css("color", "blue");

NOTE: 
When accessing, CLASS attributes are prefixed with '.'
and ID attributes are prefixed with '#'

Elements can have both CLASS and ID attributes. So you can can even more flexibility.

jQuery: $("#elementId") != document.getElementById("elementId")

The most natural assumption is that  $ in jQuery is equivalent to document.getElementById. But it is NOT !! Took me a while to figure it out.

$("#elementId")!=document.getElementById("elementId")

$("#elementId") method gives a jQuery object that is always an array of Elements.

So to the get the real DOM element you have to use $("#myElementId")[0] or the more readable $("#myElementId").get(0)

Gmail Adds Drag-and-Drop Attachment Uploads and Attach Calendar Invitation

A very cool feature from google GMAIL !
Now you can drag and drop attachments and insert invitations directly in 'compose mail'.
Simply drag single/multiple files into the 'Compose Mail' window !

ShiftIt: Windows 7 Aero Snap for Your Mac !

Wondered if you wanted to get the smart resizing introduced in Windows 7 on your Mac ?

Well Try this http://code.google.com/p/shiftit/
ShiftIt is a free download for Mac OS X only.

Theres another software Called Cinch http://www.irradiatedsoftware.com/cinch/ ,but you need to pay for it !

Easy and smart way to install Eclipse plugins

You can install the eclipse plugin in 2 standard ways:
1. Download the plugin from web and place both the "features" and "plugins" folder's contents into your eclipse installation features and plugins folders respectively.
2. You can install through "Update Manager"() by giving the update URL.

Note: The disadvantage with the above approaches are, all the installed plugins will work for only your eclipse installation. If your eclipse crashes, you will ended up with installing all the plugins that you did. And moreover every team member has to do the same every time they install Eclipse.

There is one other way that you can install Eclipse plugin and get rid of above disadvantage. And its pretty easy I believe. Please follow the steps below:

1. Create a folder structure like below anywhere in your shared folder. (The folder name must be 'eclipse' with subfolders matching exactly 'features' and 'plugins')







2. Download the plugins from web and place features folder contents and plugin folder contents into respective folders that you have created above.

3. Create a new folder called "links" in your eclipse home installation like below and create a new plain text file called plugins.link (Technically, it can be called anything.link). In it put the line path=...\My Shared Folder (i.e. path value should be the eclipse folder path that you have created above.)



4. Finally launch the eclipse. It will notices the links/plugin.link file and load any plugins from that path as well.

Advantage: With this approach you will be decoupling external plugins with your eclipse installation so that way you can have your team share the same plugins every time they change their project preferences or eclipse installation.




Click a button using Javascript

Here is how you click a button in using javascript.


<script type="text/javascript" >

  document.getElementById("mybutton").click;

</script>


This specifically helps when ur using AJAX helpers in cakePHP and you want to submit the AJAX form using javascript. In this case u will not be able to use either .submit or .onClick

Change permissions for ALL the files/subfolders within a directory

Change permissions for all the files/subfolders within a directory Option to use is 'do it recursively', the -R option . Example in unix based machines

chmod 777 -R directoryname

OffiSync integrates between MS Office on the desktop and Google Apps on the cloud

"OffiSync integrates between MS Office on the desktop and Google Apps on the cloud, allowing users to work together on the same files and see changes in real time, access document from any computer and share files with people in a secure way."


CakePHP : DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 325]

DbAcl::allow() - Invalid node [CORE\cake\libs\controller\components\acl.php, line 325]
If your following the “Simple Acl Controlled Application” , then you might see the above error message.
A simple fix is, in the function 'initDB()' replace
 $this->Acl->allow($group, 'controllers');
 with
 $this->Acl->allow(array( 'model' => 'Group', 'foreign_key' => 1), 'controllers');

So the total function would look like the following:


function initDB() {
 $group =&amp; $this-&gt;User-&gt;Group;
//Allow admins to everything
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 1), 'controllers');
 //allow managers to posts and widgets
 $this-&gt;Acl-&gt;deny(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 2), 'controllers');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 2), 'controllers/Posts');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 2), 'controllers/Widgets');

//allow users to only add and edit on posts and widgets
 $this-&gt;Acl-&gt;deny(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 3), 'controllers');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 3), 'controllers/Posts/add');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 3), 'controllers/Posts/edit');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 3), 'controllers/Widgets/add');
 $this-&gt;Acl-&gt;allow(array( 'model' =&gt; 'Group', 'foreign_key' =&gt; 3), 'controllers/Widgets/edit');
}

Beautiful BING images as your Desktop Wallpaper !!

Theres a BING downloader http://bing.codeplex.com/releases/ , helps to download the current BING image and sets as your Desktop Wallpaper.

This app requires .NET Framework for working. Download and install the latest .NET framework as well.

jQuery : Execute particular code after the animation effect has completed

If you want to execute particular code after the animation has completed, try the following:


$("#myDivToFade").fadeOut(function() {
 // This code will be executed
 // after the animation is complete
});

Associating CakePHP files ( *.ctp or *.thtml ) with Eclipse

To set up your version of Eclipse to read either file type( *.ctp or *.thtml), follow these steps

  • Go to Window > Preferences > General > Content types
  • In the content types window navigate the tree to text > PHP content type
  • Click add
  • Enter *.ctp or *.thtml depending on what version of CakePHP you use. It might be best to add both - just in case.
  • Now navigate to Editors > File Associations
  • Enter *.ctp or *.thtml depending on what version of CakePHP you use.
  • Under "Associated Editors:", select the PHP Editor and click Default.


    Fixing Warning (2): Cannot modify header information - headers already sent by (output started at...

    How to fix the following error in PHP
    Warning (2): Cannot modify header information - headers already sent by (output started at  ... 

    This is also referred to as "whitespace problem".
    The error message typically looks something like
    Warning (2): Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/test-cake/app/models/post.php:1) [CORE/cake/libs/controller/controller.php, line 644]

    Steps to resolve the issue:
    1) Find the header() statement that is causing the problem. The error must be at or before this line.

    2) Identify statements that could send output to the user before this header statement. Example 'echo ' statements. You cannot have these 'echo' statements before header() statement.

    3) Make sure there is no white space before the php start and end tags.
    Also at the beginning of the file a blank line before the <?php start tag may look innocent, when processed by PHP, it will turn into an echo statement printing out a blank line. This is a common culprit.

    Running Tomcat manager when you start the server through eclipse

    You can't open the tomcat manager by hitting http://localhost:8080 URL when you start the server through eclipse. This is because the eclipse by default creates the tomcat server instance separate from your installation and uses its custom config files for starting and stopping the tomcat. And also it deploys the webapps under workspace temporary folders (Ex: .metadata\.plugins\org.eclipse.wst.server.core\tmp0). The solutions is to change the default behavior and

    You can switch off this default behavior by fallowing th
    e below steps so that you can login to tomcat manager/admin by hitting the http://localhost:8080 URL.
    1. Add a new server by right clicking in the servers perspective of your eclipse.
    2. Double click on the server added in the above step and change both the server and deploy paths like below.
    Server Path : {Tomcat home}
    Deploy Path : {Tomcat home}/webapps













    3. Start the server.

    Note: When you do this, your custom config files will be overwritten in your Tomcat installation each time the tomcat server is started within eclipse. And the manipulation you do through manager/admin will be lost next time the Tomcat server is started in Eclipse.

    Mac OS X Fixing Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'

    How to fix Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'

    Apparently, Mac OS X doesn't allow for PHP MySQL connection out of the box. You get this:

        Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'
    OR In CakePHP
    Warning: Could not connect to Database.

    I found the most clear fix here:

        /etc/php.ini(.default) looks for mysql.sock in the wrong place... two options are to make a symbolic link from the right place to the socket...

        sudo mkdir /var/mysql
        sudo ln -s /private/tmp/mysql.sock /var/mysql/mysql.sock

        Or you can update your php.ini (.default) by finding "mysql.default_socket" and setting it to equal /private/tmp/mysql.sock and then restart apache web server

    Using CakePHP BAKE : A Fast and simple start for Web Application

    Using CakePHP BAKE feature is really very easy to setup the building stone for the web application with all basic functionalities.

    Here are the steps to start baking easily.
    Assuming you created your Database....

    1. Download the latest stable release from http://cakephp.org/
    2. Rename it to your desired app name and place it in your Web Server root directory.
    3. Open terminal and goto ur Web Server root directory/urAppName/cake/console
    4. Execute the command : ./cake bake
    5. Follow the wizard to complete the baking !

    Setting WiFi On UBUNTU via Parallels on MAC

    It is sometimes grueling when WIFI donot work after installing UBUNTU via Parallels on MAC.
    The following might resolve the Wifi issues.

    1. Make Sure the following configuration is set for Network Adapter


    2. Login into UBUNTU and open Terminal
    3. Execute the following commands:
    sudo ifconfig eth0 up
    sudo dhclient eth0


    4. Open Firefox browser. By default it is set to 'Work Offline'.
    5. In the Firefox Menu: Open 'File' and uncheck 'Work Offline'

    Cool trick in Windows 7

    Create a folder on your desktop or anywhere on your system and then rename it like below:
    MasterConsole.{ED7BA470-8E54-465E-825C-99712043E01C}
    The icon will change to the control panel icon and you will have access to EVERYTHING from this one spot. It is very cool I think. The “masterconsole” portion of the statement can named differently if you choose to do so.

    Mac: 4 easy steps to Install Tomcat on Mac OSX Snow Leapord


    4 easy steps to Install Tomcat on Snow Leopard.

    STEP 1: -- Download Tomcat 6, Binary Distribution, under Core (zip or tar.gz) from http://tomcat.apache.org/download-60.cgi
    -- Unzip the downloaded package.

    STEP 2: -- Change directories to Library
          cd /Library
    -- Create the Tomcat directory
        mkdir Tomcat

    -- Copy the unzipped downloaded package: apache-tomcat-6.0.x
    -- Paste it in this newly created Directory : /Library/Tomcat. 

    STEP 3:
    -- Edit the shell local startup script. Create if it does not exist.
    nano ~/.profile
    -- Add the following 2 lines to the .profile file: (BASH)
    -- Remember in apache-tomcat-6.0.x, the 'x' refers to what ever version # you have downloaded
    export JAVA_HOME=/Library/Java/Home
    export CATALINA_HOME=/Library/Tomcat/apache-tomcat-6.0.x

    STEP 4:
    -- Open a new Terminal window. Execute the following
    -- cd /Library/Tomcat/apache-tomcat-6.0.x/conf
    -- Edit the tomcat-users.xml file
    nano tomcat-users.xml
    -- Add the following, where admin is the administrator name you assign and password is the password
    <user username="admin" password="password" roles="standard,manager,admin"/>

    -- The tomcat-users.xml file should look something like this:

    <tomcat-users>
    <!--
    <roll rollname="tomcat"/>
    <roll rollname="role1"/>
    <user username="tomcat" password="tomcat" roles="tomcat" />
    <user username="role1" password="tomcat" roles="role1" />
    <user username="both" password="tomcat" roles="tomcat,role1" />
    -->
    <user username="admin" password="password" roles="standard,manager,admin"/>
    </tomcat-users>


    -- Save the tomcat-users.xml file and quit the editor

    And This is it....
    Now, to start tomcat
    -- Execute the Tomcat startup script located under /Library/Tomcat/apache-tomcat-6.0.x/bin
    -- ./startup.sh
    -- Test it by opening the page : http://localhost:8080/

    Now, to stop tomcat
    -- Execute the Tomcat startup script located under /Library/Tomcat/apache-tomcat-6.0.x/bin
    -- ./shutdown.sh



    Useful AJAX Modal windows using javascript frameworks

    This is an interesting link which has 30 useful AJAX Modal windows implemented using javascript frameworks.
    These have neat little descriptions about the framework it uses.
    It is easy to pick the solution based on the current javascript framework your using !

    http://www.dottony.com/30-useful-ajax-lightbox-and-modal-dialog-solutions/

    Installing UBUNTU on MAC using Parallels Desktop

    To install any Linux guest OS on Parallels Desktop, we need to download the respective .dmg from http://www.parallels.com/ptn/download/va/?categ=5&sort=rating&lsort=www

    Now at this time, the latest release of UBUNTU for Parallels is 8.04.1 and is available at http://www.parallels.com/ptn/download/va/?va_id=228 Click getApp and download the .dmg.

    Administration Interfaces:
    GUI
    Login: ubuntu
    Password: 123


    I tried downloading .iso files directly from ubuntu site but could not set it up as it asks for a partition !
    Also no luck downloading the CentOS.iso from its site, it wouldn't even create the VM.
    Windows 7 gets installed fine !

    Get names of month, weekday of the year for any date value in PHP


    To get the names of month, weekday, of the year for any date value in PHP, use the function getDate();


    Example:

    $datePieces = getDate(strtotime($mydate));




    echo "Month name: ".$datePieces['month'];  
    echo "Weekday name: ".$datePieces['weekday'];

    Make sure to use quotes for the key value like $datePieces['month'] instead $datePieces[month], since it would throw : Notice: Use of undefined constant .... 

    The associative array $datePieces contains all of the following:




    Array
    (
        [seconds] => 40
        [minutes] => 58
        [hours]   => 21
        [mday]    => 17
        [wday]    => 2
        [mon]     => 6
        [year]    => 2003
        [yday]    => 167
        [weekday] => Tuesday
        [month]   => June
        [0]       => 1055901520
    )

    Python contextlib for Timing Python code

    If you've ever found yourself needing to measure the execution time of specific portions of your Python code, the `contextlib` module o...