Thursday 29 March 2012

How to change the apache port for xampp?

By default, Apache Server listens on port 80.
But if that port is already being used by some other application and you dont want to stop that application
or port 80 is blocked by your network admin, you have to change the port of Xampp.

To change it follow the steps:

1. Stop the xampp server, if it is already running.
2. Go to folder "C:\xampp\apache\conf". (By default apache is installed in C folder)
3. Open the file httpd.conf.
4. Search the string "Listen" in the file.
5. Replace port number 80 to any other unused port number.
6. Search for "ServerName" in the file.
7. Replace port number 80 to any other unused port number in the ServerName.
8. Save the httpd.conf.
9. Start the xampp server.

Thursday 22 March 2012

Dynamic Menu Highlighting using php and CSS

The below example explains making a navigation menu that dynamically
highlights the currently displayed page using php and css

It is better to use a common navigation menu file on the site rather than repeating same code on all the pages.
The reason is that if the menu items change ,we can easily modified a single file rather than changing all the files.

In the navigation menu file (say navigationMenu.php) add the below code

   <div id="menu">
    <?php
    $active[$currentPage] = " class=active";                //dont forget to put space infront of class
    ?>
    <ul>
        <li <?php echo $active[1] ?>><a href="newfile1.php" id="index">HOME</a></li>
      <li <?php echo $active[2] ?>><a href="newfile2.php">CONTACT US</a></li>
        <li <?php echo $active[3] ?>><a href="newfile3.php">LINKS</a></li>
        <li <?php echo $active[4] ?>><a href="newfile4.php">TEAM</a></li>
    </ul>
   </div>

In the CSS add

#menu a:hover, #menu .active a  {
    background-color: red;
    color: #5A5A5A;
    display: normal;
    letter-spacing:1px;
    font-size: 11px;
  
}

In the individual pages (say contactus.php) add

<?php
$currentPage = 2;
include 'index.php';
?>

Demo : Clicking CONTACT US link



Thursday 15 March 2012

ImportError: No module named BeautifulSoup

To fix this issue

1. Download BeautifulSoup from
   http://www.crummy.com/software/BeautifulSoup/#Download

2. Extract it into a folder

3. Copy the BeautifulSoup.py in BeautifulSoup folder into a directory that's on your Python path
   eg:
      unix: /usr/local/lib/python2.2/site-packages
      Windows: C:\Python24\Lib\site-packages.

ImportError: No module named mechanize

1. Download mechanize from
   http://wwwsearch.sourceforge.net/mechanize/src/

2. Extract it into a folder

3. copy the whole mechanize directory into a directory on your Python path
    eg:
  unix:  /usr/local/lib/python2.4/site-packages
  Windows: C:\Python24\Lib\site-packages
 Only copy the mechanize directory that's inside the distributed tar / zip archive, not the
 entire mechanize-x.x.x directory!

ImportError: No module named ClientForm

ClientForm is a Python module for handling HTML forms on the client side,
useful for parsing HTML forms, filling them in and returning the completed forms to the server.

To fix this issue :

1. Download ClientForm from:
   http://wwwsearch.sourceforge.net/old/ClientForm/

2. Extract it .

3. Copy the ClientForm.py in ClientForm folder into a directory that's on your Python path
    eg:
         unix: /usr/local/lib/python2.2/site-packages
         Windows: C:\Python24\Lib\site-packages.

Monday 12 March 2012

valign not working for row in jsf panelgrid?

valign not working for row in jsf panelgrid?

Instead of valign we should give:

vertical-align : top

In panelgrid add rowclasses="rowStyle"


<h:panelGrid columns="3" styleClass="rowStyle">
</h:panelGrid>

In CSS add

.rowStyle{
vertical-align:top
}


Sunday 11 March 2012

Cytoscape Web Examples

prerequestics:  

you should install cytoscape web and adjust the javascript src path to the path where you extracted Cytoscape Web. set swfPath and flashInstallerPath correctly .
If you are facing any difficulties in setting the path, please refer Cytoscape web tutorial


Drawing a simple network with values on nodes

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
            <script type="text/javascript" src="js/AC_OETags.min.js"></script>
            <script type="text/javascript" src="js/json2.min.js"></script>
            <script type="text/javascript" src="js/cytoscapeweb.min.js"></script>
        </head>                 
<script type="text/javascript">
window.onload=function() {
            // network data could alternatively be grabbed via ajax
     var xml = '\
    <graphml>\
    <key id="label" for="all" attr.name="label" attr.type="string"/>\
    <key id="weight" for="node" attr.name="weight" attr.type="double"/>\
    <graph edgedefault="undirected">\
        <node id="1"><data key="label">1</data><data key="weight">1.8</data></node>\
        <node id="2"><data key="label">2</data><data key="weight">1.1</data></node>\
        <node id="3"><data key="label">3</data><data key="weight">1.1</data></node>\
        <node id="4"><data key="label">4</data><data key="weight">1.1</data></node>\
        <node id="5"><data key="label">5</data><data key="weight">.3</data></node>\
        <node id="6"><data key="label">6</data><data key="weight">.3</data></node>\
        <edge source="1" target="2" ></edge>\
        <edge source="2" target="3" ></edge>\
        <edge source="4" target="5" ></edge>\
        <edge source="3" target="4" ></edge>\
        <edge source="6" target="5" ></edge>\
        <edge source="4" target="2" ></edge>\
        <edge source="6" target="1" ></edge>\
    </graph>\
    </graphml>\
    ';
                           
            // init and draw
            // initialization options
                var options = {
                    swfPath: "swf/CytoscapeWeb",
                    flashInstallerPath: "swf/playerProductInstall"
                };
                                                           
                var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);
               
                var draw_options = {
                    // your data goes here
                    network: xml,
                   
                    // show edge labels too
                    edgeLabelsVisible: false,
                   
                    edgeTooltipsEnabled:true,
                  
                    // let's try another layout
                    layout: "circle",
                                                          
                    // hide pan zoom
                    panZoomControlVisible: true
                };
               
                vis.draw(draw_options);
               
            };
            </script>
           
            <style>
                /* The Cytoscape Web container must have its dimensions set. */
                html, body { height: 100%; width: 100%; padding: 0; margin: 0; }
                #cytoscapeweb { width: 100%; height: 100%; }
            </style>
        </head>
       
        <body>
            <div id="cytoscapeweb">
                Cytoscape Web will replace the contents of this div with your graph.
            </div>
        </body>
       
    </html>



The above example will draw a network with 6 nodes and 7 edges.

















Drawing a network with nodes of different size

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
            <script type="text/javascript" src="js/AC_OETags.min.js"></script>
            <script type="text/javascript" src="js/json2.min.js"></script>
            <script type="text/javascript" src="js/cytoscapeweb.min.js"></script>
        </head>                 
<script type="text/javascript">
window.onload=function() {
            // network data could alternatively be grabbed via ajax
     var xml = '\
    <graphml>\
    <key id="label" for="all" attr.name="label" attr.type="string"/>\
    <key id="weight" for="node" attr.name="weight" attr.type="double"/>\
    <graph edgedefault="undirected">\
        <node id="1"><data key="label">1</data><data key="weight">.7</data></node>\
        <node id="2"><data key="label">2</data><data key="weight">.5</data></node>\
        <node id="3"><data key="label">3</data><data key="weight">.5</data></node>\
        <node id="4"><data key="label">4</data><data key="weight">.5</data></node>\
        <node id="5"><data key="label">5</data><data key="weight">.2</data></node>\
        <node id="6"><data key="label">6</data><data key="weight">.2</data></node>\
        <edge source="1" target="2" ></edge>\
        <edge source="2" target="3" ></edge>\
        <edge source="4" target="5" ></edge>\
        <edge source="3" target="4" ></edge>\
        <edge source="6" target="5" ></edge>\
        <edge source="4" target="2" ></edge>\
        <edge source="6" target="1" ></edge>\
    </graph>\
    </graphml>\
    ';
                           
            // init and draw
            // initialization options
                var options = {
                    swfPath: "swf/CytoscapeWeb",
                    flashInstallerPath: "swf/playerProductInstall"
                };
                                                           
                var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);
               
             // visual style we will use
                var visual_style = {
                    global: {
                        backgroundColor: "#ABCFD6"
                    },
                    nodes: {
                        shape: "circle",
                        borderWidth: 2,
                        borderColor: "#ffffff",
                        // setting different size to the nodes
                        size: {
                            defaultValue: 20,
                            continuousMapper: { attrName: "weight", minValue: 30, maxValue: 60 }
                        },
                        labelHorizontalAnchor: "center"
                    },
                    edges: {
                        width: 1,
                        color: "#0B94B1"
                    }
                };
               
                var draw_options = {
                    // your data goes here
                    network: xml,
                   
                    // show edge labels too
                    edgeLabelsVisible: false,
                                 
                 
                 // set the style at initialisation
                    visualStyle : visual_style,
                  
                    // circle layout for nodes
                    layout: "circle",
                                                          
                    // hide pan zoom
                    panZoomControlVisible: true
                };
               
                vis.draw(draw_options);
               
            };
            </script>
           
            <style>
                /* The Cytoscape Web container must have its dimensions set. */
                html, body { height: 100%; width: 100%; padding: 0; margin: 0; }
                #cytoscapeweb { width: 100%; height: 100%; }
            </style>
        </head>
       
        <body>
            <div id="cytoscapeweb">
                Cytoscape Web will replace the contents of this div with your graph.
            </div>
        </body>
       
    </html>
























Drawing a network with different colored nodes and edges 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
            <script type="text/javascript" src="js/AC_OETags.min.js"></script>
            <script type="text/javascript" src="js/json2.min.js"></script>
            <script type="text/javascript" src="js/cytoscapeweb.min.js"></script>
        </head>                 
<script type="text/javascript">
window.onload=function() {
            // network data could alternatively be grabbed via ajax
     var xml = '\
    <graphml>\
    <key id="label" for="all" attr.name="label" attr.type="string"/>\
    <key id="weight" for="node" attr.name="weight" attr.type="double"/>\
    <graph edgedefault="undirected">\
        <node id="1"><data key="label">1</data><data key="weight">.7</data></node>\
        <node id="2"><data key="label">2</data><data key="weight">.5</data></node>\
        <node id="3"><data key="label">3</data><data key="weight">.5</data></node>\
        <node id="4"><data key="label">4</data><data key="weight">.5</data></node>\
        <node id="5"><data key="label">5</data><data key="weight">.2</data></node>\
        <node id="6"><data key="label">6</data><data key="weight">.2</data></node>\
        <edge source="1" target="2" id="gene"></edge>\
        <edge source="2" target="3" id="gene"></edge>\
        <edge source="4" target="5" id="gene"></edge>\
        <edge source="3" target="4" id="miR"></edge>\
        <edge source="6" target="5" id="miR"></edge>\
        <edge source="4" target="2" id="miR1"></edge>\
        <edge source="6" target="1" id="miR1"></edge>\
    </graph>\
    </graphml>\
    ';
                           
            // init and draw
            // initialization options
                var options = {
                    swfPath: "swf/CytoscapeWeb",
                    flashInstallerPath: "swf/playerProductInstall"
                };
                                                           
                var vis = new org.cytoscapeweb.Visualization("cytoscapeweb", options);
               
             // visual style we will use
                var visual_style = {
                    global: {
                        backgroundColor: "#ABCFD6"
                    },
                    nodes: {
                        shape: "circle",
                        borderWidth: 2,
                        borderColor: "#ffffff",
                        // setting different size to the nodes
                        size: {
                            defaultValue: 20,
                            continuousMapper: { attrName: "weight", minValue: 30, maxValue: 60 }
                        },
                        //setting different color to the node
                        color : {
                            discreteMapper : {
                                attrName : "id",
                                entries : [ {
                                    attrValue : "1",
                                    value : "red"
                                }, {
                                    attrValue : "2",
                                    value : "gray"
                                }, {
                                    attrValue : "3",
                                    value : "gray"
                                }, {
                                    attrValue : "4",
                                    value : "gray"
                                }, {
                                    attrValue : "5",
                                    value : "yellow"
                                }, {
                                    attrValue : "6",
                                    value : "yellow"
                                } ]
                            }
                        },
                        labelHorizontalAnchor: "center"
                    },
                    edges : {
                        width : 2,
                        //setting different color to the edges
                        color : {
                            discreteMapper : {
                                attrName : "id",
                                entries : [ {
                                    attrValue : "gene",
                                    value : "red"
                                }, {
                                    attrValue : "miR",
                                    value : "white"
                                }, {
                                    attrValue : "miR1",
                                    value : "blue"
                                } ]
                            }
                        }
                    }
                };
               
                var draw_options = {
                    // your data goes here
                    network: xml,
                   
                    // show edge labels too
                    edgeLabelsVisible: false,
                                 
                 
                 // set the style at initialisation
                    visualStyle : visual_style,
                  
                    // circle layout for nodes
                    layout: "circle",
                                                          
                    // hide pan zoom
                    panZoomControlVisible: true
                };
               
                vis.draw(draw_options);
               
            };
            </script>
           
            <style>
                /* The Cytoscape Web container must have its dimensions set. */
                html, body { height: 100%; width: 100%; padding: 0; margin: 0; }
                #cytoscapeweb { width: 100%; height: 100%; }
            </style>
        </head>
       
        <body>
            <div id="cytoscapeweb">
                Cytoscape Web will replace the contents of this div with your graph.
            </div>
        </body>
       
    </html>