Posts

Showing posts from 2015

MS SQL Server : How to remove duplicate text in a csv String in table

Here is the function which will return string after removing duplicate text from a csv cell value. create function dbo.RemoveDuplicateTextInCSVString(@SOURCE_STR varchar(50)) returns varchar(50) as begin     declare @TEMP_STR varchar(50)   declare @WORD_STR varchar(50)   set @TEMP_STR = ','   while len(@SOURCE_STR) > 0 begin print '--------------------' set @WORD_STR = left(@SOURCE_STR, charindex(',', @SOURCE_STR+',')-1)+',' print '@WORD_STR :'+ @WORD_STR if charindex(','+@WORD_STR, @TEMP_STR) = 0 begin set @TEMP_STR = @TEMP_STR + @WORD_STR print '@TEMP_STR : '+@TEMP_STR end else print 'found duplicate, remove this..' set @SOURCE_STR = stuff(@SOURCE_STR, 1, charindex(',', @SOURCE_STR+','), '') print '@SOURCE_STR '+@SOURCE_STR   end   return @SOURCE_STR end

Collection holds value as a refernce in java

Value as a Reference example : Here we are fecthing a list from a collection and updating this which leads to automatic update of Map because  numList is directly referring to   testmap. ----------------------------------- public class ValueAsReference{ enum EvenOdd{ EVEN,ODD } public static void main(String ... arg){ Map<String,List<String>> testmap=new HashMap<String, List<String>>(); for(int i=0;i<20;i++){ String key=""; if(i%2 ==0){ key=""+EvenOdd.EVEN; }else{ key=""+EvenOdd.ODD; } List<String> numList=testmap.get(key); if(numList==null){ numList=new ArrayList<String>(); numList.add("i="+i); testmap.put(key, numList); }else{ numList.add("i="+i); } } for(String key : testmap.keySet()){ System.out.println("key : "+key); System.out.println(testmap.get(key)); }

Google App Engine deleted default GCS bucket. Is there a way to restore it?

No, there is no way to restore a deleted bucket or object inside a bucket. DELETE operation comes under strong global consistency. Keep in mind that you can use Google Cloud Storage only after enabling billing for your project. It's not free. You can go through Cloud storage documentation   Bucket will be deleted permanently. You can see google documentation.  Although a bucket will be deleted only if it is empty, means you have to delete all objects first and then you can delete an empty bucket. Choose bucket carefully as these are unique globally and can not be nested like folders or directories.

Set your application context path in Tomcat 7

Set Context path in Tomcat 7 or more using catalina.properties file, Step 1) Add following lines to catalina.properties file under <tomcat-install dir>/conf directory, #myApp war file version myApp .war=myAppLive -1.0.0.1.war myApp .path=/myAppLive #application deployment location appBase=webapps Step 2) Now update context path in <Host> node in server.xml file in same location, <Host name="localhost"  appBase="webapps"             unpackWARs="true" autoDeploy="false"> ... ....     <Context path="${myApp .path}" docBase="${catalina.base}/${appBase}/${myApp .war}"/> ... .... </Host>

Custom directive with dynamic attribute using angular JS

Custom directive with dynamic attribute using angular JS Javascript: var myApp=angular.module('myApp', []); myApp.controller('myCtrl', ['$scope', function($scope) {    $scope.data= [                { name: 'A', size: '12' },                { name: 'C', size: '11' },                { name: 'B', size: '10' }               ]; }]) .directive('myOrderList', function(){   function link(scope, element, attrs) {        var myData=scope.data;            console.log(attrs);            var ulElem=element.html('<ol>');        for(var i=0;i<scope.data.length;i++){                         ulElem.append('<li>'+scope.data[i][attrs.value]+'</li>');         }           }   return {     link: link   }; }); HTML CODE: <div ng-app="myApp"> <div ng-controller="myCtrl">  <div my-order-list value="size"

Maven build is failing to include struts-config.xml or web.xml file to target../../WEB-INF directory

  Maven build is failing to include struts-config.xml or web.xml file to target../../WEB-INF directory due to ‘WebContent ‘ as maven needs ‘ webapps ‘ Add this plugin to pom.xml < plugin > < groupId > org.apache.maven.plugins </ groupId > < artifactId > maven -war- plugin </ artifactId > < version > 2.2 </ version > < configuration > < webResources > < resource > < directory > ${ basedir }/WebContent </ directory > </ resource > </ webResources > < warSourceDirectory > WebContent </ warSourceDirectory > < warSourceExcludes > WebContent/WEB-INF/ lib /*.jar </ warSourceExcludes > < archiveClasses > false </ archiveClasses > </ configuration > </ plugin >

Dynamic response by java and handle using ajax jquery for all content types

Dynamic response by java and handle using ajax jquery for all content types Jquery ajax call              var url= "trackDynamicResponse.do" ;               $.ajax({                                                   url: url,                        type: 'GET' ,                        data :{                              responseType : _responseType                                                       },                        success: function (response, status, xhr){                                                             var ct = xhr.getResponseHeader( "content-type" ) || "" ;                                if (ct.indexOf( 'html' ) > - 1) {                                  console.log( "html ..." );                                                              }                                if (ct.indexOf( 'json' ) > - 1) {                                   console.l

Open popup window with post request data in Javascript

 Open popup window with post request data using javascript:                                  function openWindowWithPostRequest() {            var winName='MyWindow';            var winURL='search.action';            var windowoption='resizable=yes,height=600,width=800,location=0,menubar=0,scrollbars=1';            var params = { 'param1' : '1','param2' :'2'};                       var form = document.createElement("form");            form.setAttribute("method", "post");            form.setAttribute("action", winURL);            form.setAttribute("target",winName);             for (var i in params) {                  if (params.hasOwnProperty(i)) {                      var input = document.createElement('input');                      input.type = 'hidden';                      input.name = i;                      input.value = param