Tuesday, May 15, 2012

HTML

Complete list of HTML tags: http://www.w3schools.com/tags/default.asp

- HTML stands for Hyper Text Markup Language
- HTML is not a programming language, it is a markup language
- Practically speaking, there is no difference between the htm and html extensions
- In XHTML, all elements must be closed. Adding a slash inside the start tag, like
, is the proper way of closing empty elements in XHTML (and XML)
- HTML tags, attribute names and attribute values are not case sensitive but World Wide Web Consortium (W3C) recommends lowercase in HTML 4, and demands lowercase tags in XHTML. Newer versions of (X)HTML will demand lowercase attributes
- In XHTML, XML, elements with no end tag (closing tag) are not allowed
- attribute id vs name: id must be unique and is used as an identifier of an HTML element while name is used for form elements and form elements can share the same name
- HTML comment sample:
 <!-- This is a comment --> 
- The <center>, <font>, <basefont>, <s>, <strike> and <u> tags and align, bgcolor and color attributes are deprecated in HTML 4, and removed from HTML5. Style sheets (CSS) should be used to define the layout and display properties for many HTML element
- Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.w3schools.com/html/"
- HTML frames are obsolete in HTML5. Cons: http://webdesign.about.com/od/framesprosandcons/a/aaframesyuck_2.htm
- The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly. 
 <!-- This is a comment --> 

Reference: http://www.w3schools.com

Wednesday, May 9, 2012

How to create Sublabels / Hierarchical Labels in Blogspot

I always wanted my label section to look like the archive section where labels can have hierarchy and the number of posts is displayed beside each label. I learned how to create the hierarchical tree from this blog but the nodes have to be added one by one and the number of posts per label are not displayed so I tweaked it a little to suit my needs. Here are the steps:
  1. Add the Labels gadget if is not yet added
    From your dashboard, click Layout -> Add a Gadget and select Labels
  2. Add an HTML gadget. This is where you will create your hierarchical labels.
    From your dashboard, click Layout -> Add a Gadget and select HTML/Javascript
  3. Ensure that the Labels gadget comes first before the HTML gadget in your layout.
    From your dashboard, click Layout and arrange your gadgets by dragging them to the desired location so that the Labels gadget is on top or comes first before the HTML gadget
  4. Update the Template
    1. Add the dtree javascript.
      From your dashboard, click Template -> Edit HTML -> Proceed and check Expand Widget Templates. Copy and paste this code
      <link href='https://sites.google.com/site/efekefek/file-js/dtree.css' rel='StyleSheet' type='text/css'/>
      <script src='https://sites.google.com/site/efekefek/file-js/createdtree.js' type='text/javascript'/>
      after this tag
      <b:skin><![CDATA[/*
    2. Remove the Label widget content
      Find the Label widget code. It looks like this
      <b:widget id='Label1' locked='false' title='Labels' type='Label'>
      <b:includable id='main'>
          
       ...  
      
      </b:includable>
      </b:widget>
      Replace the code inside <b:includable id='main'> and </b:includable> with this code
      <script type='text/javascript'>
        var labelCountMap = {};
        <b:loop values='data:labels' var='label'>
           labelCountMap ["<data:label.name/>"] = "<data:label.count/>";
         </b:loop>
      </script>
    3. Save template
  5. Prepare the code of the Hierarchical Labels
    Copy the code below and replace the data with your own Labels. The data is in format
    parentLabel: { subLabels }
    The subLabels are comma separated. If the parentLabel doesn't have subLabels, replace it with {}.
    <div class="dtree">
    <p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
    <script type="text/javascript">
    <!--
    function isEmpty(obj) {
        for(var prop in obj) {
            if(obj.hasOwnProperty(prop))
                return false;
        }
        return true;
    }
    
    function addMap(d, startingNode, parentNode, map) {
     for (var key in map) {
      if (isEmpty(map[key])) {
       d.add(startingNode++,parentNode,key+' ('+labelCountMap[key]+')','/search/label/'+key);
      } else {
       d.add(startingNode++,parentNode,key+' ('+labelCountMap[key]+')','/search/label/'+key);
       startingNode = addMap(d, startingNode, startingNode-1, map[key]);
      }
      
     }
     return startingNode; 
    }
    
    var data = {
     'Label 1' : {
      'Label 1.1' : {},
      'Label 1.2' : {
       'Label 1.2.1' : {}
      }, 
      'Label 1.3' : {}
     }, 
     'Label 2' : {
      'Label 2.1' : {}, 
      'Label 2.2' : {}
     }, 
     'Label 3' : {}, 
     'Label 4' : {}};
    
    d = new dTree('d');
    d.config.useLines = true;
    d.config.useIcons = false;
    d.config.inOrder = true;
    
    d.add(0,-1,'');   
    addMap(d, 1, 0, data);
    
    document.write(d);
    //-->
    </script>
    </div>
  6. Paste the code in the HTML widget
    From your dashboard, click Layout and Edit the HTML widget. Paste the code inside Content and Save

Wednesday, July 27, 2011

Maven POM


Source: http://maven.apache.org/guides/introduction/introduction-to-the-pom.html

Monday, July 25, 2011

Basic UNIX commands

  • man - manual/help
  • pwd - print working/current directory
  • ls - list files
  • ls -l - lists files in 'long format', which contains lots of useful information, e.g. the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified
  • cd - change directory
  • mkdir [dir] - creates dir
  • rmdir [dir] - removes dir
  • more [options] file(s) - Display contents of files
  • less [options] file(s) - Display contents of files
    Useful commands while viewing a file with 'more' or 'less':
    • <spacebar> - scroll forward one page
    • ^b (control-b) - scroll backward one page
    • /<text> - search for string
    • n - find next occurence of string
    • N - find previous occurence of string (search for string in opposite direction)*
    • g - go to the beginning of the file*
    • G - go to the end of the file*
    • v - edit the current file with 'vi'*
    • :n - go to the next file*
    • :p - go to the previous file*
    • q - quit
    *works in 'less', not 'more'
  • grep [options] <pattern> [files] - search inside files for the given pattern
    Useful options:
    • -i - ignore case
    • -r or -R - search files in directories/subdirectories recursively
    • -v - nvert match: select non-matching lines
  • tail [options] [filenames] - show tail/end of file
  • tail -f temp.log - follow/monitor the file, display the last 10 lines of temp.log and append new lines to the display as new lines are added to temp.log
  • vi filename - edit the file
    Modes:
    • command mode - letters of the keyboard will be interpreted as commands
    • insert mode - letters of the keyboard will type or edit text
    Useful commands:
    • x - deletes the character the cursor is under
    • dd - deletes the line the cursor is on
    • a - append after the cursor
    • i - insert before the cursor
    • ESC - non edit mode
    • :wq - saves the current changes and exits vi
    • :w - saves the current changes but does not exit vi
    • :q - exits vi without saving any change

References:
http://claymore.rfmh.org/public/computer_resources/unix_commands.html
http://mally.stanford.edu/~sr/computing/basic-unix.html
http://cmgm.stanford.edu/classes/unix/vi.html
http://en.wikipedia.org
http://www.ccsf.edu/Pub/Fac/vi.html

Friday, July 22, 2011

Installing your own jar into Local Repository

  • Update your maven setting to point the localRepository to where you want to install the jar
    1. Go to <MAVEN_HOME>\conf directory
    2. Open settings.xml and change <localRepositorygt; tag to the path where you want to install the jar file
  • In command prompt, type:
    mvn install:install-file -Dfile=your-artifact-1.0.jar \
                             [-DpomFile=your-pom.xml] \
                             [-Dsources=src.jar] \
                             [-Djavadoc=apidocs.jar] \
                             [-DgroupId=org.some.group] \
                             [-DartifactId=your-artifact] \
                             [-Dversion=1.0] \
                             [-Dpackaging=jar] \
                             [-Dclassifier=sources] \
                             [-DgeneratePom=true] \
                             [-DcreateChecksum=true]
    
    Where: <path-to-file>  the path to the file to load
       <group-id>      the group that the file should be registered under
       <artifact-id>   the artifact name for the file
       <version>       the version of the file
       <packaging>     the packaging of the file e.g. jar

    Sample:
    mvn install:install-file -Dfile=C:\bel\docs\lib\jxl-2.6.3.jar -DgroupId=jexcelapi -DartifactId=jxl -Dversion=2.6.3 -Dpackaging=jar -DgeneratePom -DcreateChecksum=true

  • In your repository, you will find the new jar installed
  • To use the jar, add it in your pom.xml like:
    <dependency>
     <groupId>jexcelapi</groupId>
     <artifactId>jxl</artifactId>
     <version>2.6.3</version>
    </dependency>

Monday, April 25, 2011

Maven Setup

  1. Install Maven
  2. Update {MAVEN_HOME}\conf\settings.xml
    Update the following:
    • localRepository
    • proxies
    • profiles
    • activeProfiles