Friday, April 18, 2014

Maven - Start a new java project

mvn archetyp:generate
Group, ArtefactId, Version

mvn eclipse:eclipse

Then in Eclipse, you can import the Project:
File > Import > Maven > Existing Maven Projects > Next > Browse to the Root Directory > Select the pom.xml > Finish

Or you can create the Maven project directly in Eclipse:
File > New > Other... > Maven > Maven Project > Next > Next :
Group, ArtefactId, Version

Wednesday, April 16, 2014

XSLT - Definitions

XSLT - a language for transforming XML documents 
XPath - a language for navigating in XML documents 
XSL-FO - a language for formatting XML documents
XQuery - a language for finding and extracting elements and attributes from XML documents.

SQL - First and last day of the month

-- First day of the last month
SELECT DATEADD(mm, DATEDIFF(m,0,GETDATE())-1,0);

-- Last day of the last month
SELECT DATEADD(d,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())  ,0));

SQL - Mixing INNER and OUTER Joins [external link]

When mixing INNER and OUTER joins, it's important to understand the risks involed and this article describe it very clearly:
http://weblogs.sqlteam.com/jeffs/archive/2007/10/11/mixing-inner-outer-joins-sql.aspx

SVN > XSLT = HTML Report

svn log -v --xml file:///C:/subversion/repo/http-conf | xsltproc svnstyle.xsl - > ./svnlog.html

===== svnstyle.xsl =====
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
   <body>
      <h2>SVN Log</h2>
      <table border="1">
      <xsl:for-each select="log/logentry">
         <xsl:if test="author='USERNAME'">
            <tr>
               <td><xsl:value-of select="date"/></td>
               <td><xsl:value-of select="author"/></td>
               <td><xsl:value-of select="msg"/></td>
            </tr>
         </xsl:if>
      </xsl:for-each>
      </table>
   </body>
</html>
</xsl:template>
</xsl:stylesheet>
===== svnstyle.xsl =====


Output: 
===== svnlog.html =====
<html>
   <body> 
      <h2>SVN Log</h2> 
      <table border="1"> 
         <tr> 
            <td>2014-04-11T21:34:31.836671Z</td> 
            <td>
USERNAME</td> 
            <td>My third commit</td> 
         </tr> 
         <tr> 
            <td>2014-04-11T21:34:31.586674Z</td> 
            <td>
USERNAME</td> 
            <td>My second commit</td> 
         </tr> 
         <tr> 
            <td>2014-04-11T21:34:31.024182Z</td> 
            <td>
USERNAME</td> 
            <td>My first commit</td> 
         </tr> 
         <tr> 
            <td>2014-04-11T21:34:30.149193Z</td> 
            <td>
USERNAME</td> 
            <td>Creating the project</td> 
         </tr> 
      </table> 
   </body>

</html>
===== svnlog.html =====


Sunday, April 13, 2014

Friday, April 11, 2014

dos2unix


To convert all the files :
find . -type f -print0 | xargs -0 dos2unix

To convert all the files except those in the « .svn » directories :
find . -type f -not -iwholename '*.svn*' -print0 | xargs -0 dos2unix 

Cygwin - Install (Windows)


www.cygwin.com

Add modules:
- dos2unix (Utils \ dos2unix)
- xsltproc (Libs \ libxslt)
- wget (Web \ wget)
- curl (Net \ curl)
- nc (Net \ nc)
- git (Devel \ git)
- svn (Devel \ subversion)
- ssh (Net \ openssh)
- scp (Net \ openssh)
- openssl (Net \ openssl)

Thursday, April 3, 2014

Request forwarding based on HTTP Header

HTTP Proxy example:


<VirtualHost 1.2.3.4:80> 
   ServerName dynamic-proxy.company.com 
   DocumentRoot "/application/web_server/root" 
   CustomLog logs/dynamic-proxy.access_80.log combined env=!nolog 
   ErrorLog logs/dynamic-proxy.error_80.log 

   RewriteEngine on 

   <Directory /application/web_server/root> 
      Order Deny,Allow 
      Allow from all 
   </Directory> 

   AddDefaultCharset UTF-8
    
#################################################################################
#                                        Server #1
#################################################################################

   RewriteCond /application/web_server/srv01/%{HTTP:x-msisdn} -f 
   RewriteRule ^/root/(.*)$ http://srv01.int.company.com/root/$1 [L,NE] 

#################################################################################
#                                        Server #2
#################################################################################

   RewriteCond /application/web_server/srv02/%{HTTP:x-msisdn} -f 
   RewriteRule ^/root/(.*)$ http://srv02.int.company.com/root/$1 [L,NE] 

################################################################################# 
#                                        Server #3
#################################################################################

   RewriteCond /application/web_server/srv03/%{HTTP:x-msisdn} -f 
   RewriteRule ^/root/(.*)$ http://srv03.int.company.com/root/$1 [L,NE] 

#################################################################################
#                                        DEFAULT 
#################################################################################

   RewriteRule ^/root/(.*)$ http://prd01.int.company.com/root/$1 [L,NE] 

   # Avoid Cross Site Scripting 
   RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK) 
   RewriteRuLe .* - [F] 
</VirtualHost>