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

Sunday, March 6, 2011

Deployment

  1. Create the package for full release
    1. Check out the Project in Eclipse
      1. Open SVN Repositories. Click Window->Open Perspective->SVN Repository Browser
      2. Assuming that you already have Repository Location set up, find the project in the trunk or branches
      3. Right click project then click Show History to ensure that it has the latest change/fix needed
      4. Tag or make a branch out of the project. Right click project then click New->Tag or Branch
      5. Right click newly created tag/branch then click Show History to ensure that the it has the latest change/fix needed
      6. Check out the newly created tag or branch. Right click project the click Check Out

    2. Build the package
      1. In the console, go to emea-pom of the checked out project
      2. Type
        mvn clean package –DemeaVersion=${currentversion}
      3. After a successful build, go to the emea-release project and copy the whole target folder in a different directory.

  2. Generate the config files/folders of the package
    1. Create a config folder inside the target folder or where the jar is located
    2. Create folders dev, sit, uat and prod inside config folder
    3. Open you FTP Client (e.g. FileZilla) and copy the config files to the newly created folders
      • DEV
      • SIT
      • UAT
      • PROD
    4. Update the ini file with the changes from project and change the VERSION property

  3. Deploy DEV using the exploded jar
    1. In FileZilla, upload/add target/classes/versions to /ams/domains/ACCTSVCS102/versions
    2. In FileZilla, copy target/config/dev to/ams/domains/ACCTSVCS102/versions/config
    3. On DEV WEBLOGIC, stop and delete previously deployed ear
    4. Open Putty and login to DEV (ehdeapp10v.uk.jpmorgan.com)
    5. Point latest to latest deployed version

      1. Go to /ams/domains/ACCTSVCS102/versions/biz-rules
      2. Type rm latest
      3. Type ln -s {newversionFolder} latest
      4. Do step 1-3 to config & emea folders as well

    6. On DEV WEBLOGIC, deploy new ear and start
    7. Delete temporary files

      1. Go to /ams/domains/ACCTSVCS102/scripts and type stop_all.sh
      2. Go to /ams/domains/ACCTSVCS102/servers/admACCTSVCS
      3. Delete tmp folder. Type rm -rf {folderName}
      4. Go to /ams/domains/ACCTSVCS102/servers/mngACCTSVCS
      5. Delete tmp & stage folder
      6. Go to /ams/domains/ACCTSVCS102/scripts and type start_all.sh

    8. Check server: DEV

  4. Copy package(jar) and config files to SIT (ehdeapp10v.uk.jpmorgan.com), /home/eis_dev/a_pfdv01/AMSNA

  5. Create JIRA

  6. Finish!