Wednesday

CSS table row coloring >> tr:nth-child get 2nd, 3rd, 6th and 7th children at once?














<html>
           <head>
                   <style>
                         caption {
                                text-align: center;
                           }
                            tr:nth-child(4n+1):not(:first-child), tr:nth-child(4n) {
                                  background: #EAEAEA;
                             }
                             tr:nth-child(4n-1), tr:nth-child(4n-2) {
                                 background: #E7F2FC;
                            }
                            </style>
                </head>
               
    <body topmargin=0 leftmargin=0>
      <table >
        <caption><b><br>HEADER</b></caption>
        <tr>
          <td height="21"><b>column 1</b></td>
          <td height="21"><b>column 2</b></td>
          <td height="21"><b>column 3</b></td>
          <td height="21"><b>column 4</b></td>
        </tr>
        <tr>
          <td>row 1.1</td>
          <td>row 1.2</td>
          <td>row 1.3</td>
          <td>row 1.4</td>
        </tr>
        <tr>
          <td colspan="4">row 2</td>
        </tr>
        <tr>
          <td>row 3.1</td>
          <td>row 4.2</td>
          <td>row 4.3</td>
          <td>row 4.4</td>
        </tr>
        <tr>
          <td colspan="4">row 4</td>
        </tr>
        <tr>
          <td>row 5.1</td>
          <td>row 5.2</td>
          <td>row 5.3</td>
          <td>row 5.4</td>
        </tr>
        <tr>
          <td colspan="4">row 6</td>
        </tr>
      </table>
     </body>
</html>

Clearcase error: Checkout is currently disabled for element | An update must be performed on the element to enable a checkout.

BUG:
While i tried to checkout a folder, it failed with the following error:
Error adding the file D:\myview\myvob\parentdir\myfile.xls to source control.
Checkout is currently disabled for element D:\myview\myvob\parentdir.
An update appears to have been aborted or errors were encountered during an update.  An update must be performed on the element to enable a checkout.

FIX:
Update your view from the root.
clearcase explorer >> your snapshot >> right click >> update view

Friday

Ant scp error: com.jcraft.jsch.JSchException: reject HostKey: 10.xx.xx.xx

BUG:
I got the following error in scp task when run ant.
my build file:

<scp todir="${username}:${password}@${ip}:${dir}" >
       <fileset dir="${parentDir}/">
            <include name="**/${dirToCopy}"/>
         </fileset>
</scp>

ERROR:
com.jcraft.jsch.JSchException: reject HostKey: 10.xx.xx.xx

FIX:
Add trust attribute.
<scp todir="${username}:${password}@${ip}:${dir}" trust="true" >
         <fileset dir="${parentDir}/">
            <include name="**/${dirToCopy}"/>
         </fileset>
</scp>

Regex date format validation (11_digit_identification_number date_of_birth_with_following_format_dd.mm.yyyy)

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Test {

       public static void main( String args[] ) {

              String line[] = {"96325587410 10.01.1980", "96325587410 8.4.1988",
                          "96325587410 31.12.2000", "96325587410 70.01.2000",                                  "96325587410 1-01-1980", "216235456242334458 10.01.1980"
                          "21652334458 10.01.2980"};

              String pattern = "\\A\\s*\\d{11}\\s*(0?[1-9]|[12][0-9]|3[01])\\.(0?[1-9]|1[012])\\.((19|20)\\d\\d)\\s*\\Z";
              String parameters  = "\\A\\s*(\\d{11})\\s*((0?[1-9]|[12][0-9]|3[01]).(0?[1-9]|1[012]).((19|20)\\d\\d))\\s*\\Z";

              for(int i = 0; i< line.length ; i++) {
                     Pattern r = Pattern.compile(pattern);
                     Matcher m = r.matcher(line[i]);
                     System.out.println("KEYWORD: " + line[i]);
                    
                     if (m.find( )) {
                           Pattern cno = Pattern.compile(parameters);
                           Matcher m1 = cno.matcher(line[i]);
                           if(m1.find( )) {
                                  System.out.println("--> identityno: " + m1.group(1));
                                  System.out.println("--> dateofbirth: " + m1.group(2) );
                           }
                          
                     } else {
                           System.out.println("---> NO MATCH");
                     }
                    
                     System.out.println("---------------------------------------");
              }

       }
}


OUTPUT:

KEYWORD: 96325587410 10.01.1980
--> identityno: 96325587410
--> dateofbirth: 10.01.1980
---------------------------------------------
KEYWORD: 96325587410 8.4.1988
--> identityno: 96325587410
--> dateofbirth: 8.4.1988
---------------------------------------------
KEYWORD: 96325587410 31.12.2000
--> identityno: 96325587410
--> dateofbirth: 31.12.2000
---------------------------------------------
KEYWORD: 96325587410 70.01.2000
---> NO MATCH
---------------------------------------------
KEYWORD: 96325587410 1-01-1980
---> NO MATCH
---------------------------------------------
KEYWORD: 216235456242334458 10.01.1980
---> NO MATCH
---------------------------------------------
KEYWORD: 21652334458 10.01.2980
---> NO MATCH
---------------------------------------------

Join ArrayList String elements into a single String with a separator

Download commons-lang3-3.0.1.jar.

https://mvnrepository.com/artifact/
org.apache.commons/commons-lang3/3.0.1
For maven:

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.0.1</version>
</dependency>

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

public class Test {
      
       public static void main(String[] args) {
              List<String> list = new ArrayList<String>();
              list.add("less");
              list.add("talk");
              list.add("more");
              list.add("code");

              System.out.println(StringUtils.join(list, ", "));
       }
}

OUTPUT:
less, talk, more, code