Wednesday, December 26, 2018

method comment in eclipse

  1. Following are the steps to add method comments-
  2. preferences
    1. Java
      1. Code Style
        1. Code Templates
          1. method
            1. Insert variable
  3.  Now to test the above
    1. just type /** and press enter before a method

Tuesday, September 25, 2018

ubuntu permission

sudo chmod -R 777 /* to give permission to the folder and all its contents recursively

installation of visual studio code for angular


  1. download .deb 64 bit package for ubuntu  from https://code.visualstudio.com/download
  2. open terminal and goto the location where the file exists
  3. type the following
    1. sudo dpkg -i code_1.27.2-1536736588_amd64.deb
  4. goto search bar
  5. type visual studio code
  6. lock it to launcher

Tuesday, August 7, 2018

domain driven design

  1. books “Domain-driven Design” by Eric Evans and “Implementing Domain-driven Design” by Vaughn Vernon
  2.  
  3. value object is the object of a class whose constructor is private and which is constructed with the help of factory method inside it. they are not treated as entity. and two value objects having same state are considered to be equal.
  4. https://deviq.com/value-object
  5. they are small
  6. they are immutable
  7. https://martinfowler.com/bliki/ValueObject.html
  8. https://enterprisecraftsmanship.com/2016/01/11/entity-vs-value-object-the-ultimate-list-of-differences/
  9.  
  10. value objects can be considered as @component
  11. address is a good example of value object
  12. value object should not be in a separate table.
  13. value object should not have own identity
  14. aggregates
    1. https://medium.com/withbetterco/using-aggregates-and-factories-in-domain-driven-design-34e0dff220c3
    2. https://www.infoq.com/news/2015/01/aggregates-value-objects-ddd
    3.  

ubuntu

docker

  1. sudo docker pull netflixoss/eureka generates the following error
  2.  Using default tag: latest
    Error response from daemon: manifest for netflixoss/eureka:latest not found
    solution is ->
  3. sudo docker pull netflixoss/eureka:1.3.1
    1. where 1.3.1 is the tag
  4. following is the way to run i.e create a container:
  5. sudo docker run netflixoss/eureka:1.3.1
  6. the problem is unable to connect to the port 
  7. https://stackoverflow.com/questions/47612400/docker-run-unable-to-access-jar-file 
  8. https://bartwullems.blogspot.com/2017/03/docker-error-err
  9. http://blog.thoward37.me/articles/where-are-docker-images-stored/
  10. https://stackoverflow.com/questions/25101312/does-all-running-docker-containers-have-a-separate-process-id
  11.  sudo docker container ls -> will all the running containers
  12. docker --help//help commands
  13. how to locate Dockerfile of pulled docker image ?
  14. docker-compose.yml
  15.  If you need to customize an image image, you should create a Dockerfile, with the first line:
    FROM ubuntu
     

  16. Yes, every docker container will have a different PID on your host machine.
    You can get a docker containers PID by doing:
    docker inspect --format '{{ .State.Pid }}' CONTAINER_ID
    
    If you kill the process on your host, your docker container will die.

    example
    sudo docker inspect --format '{{ .State.Pid }}' 18f966e5228f


maven on ubuntu for spring boot application

  1. maven creates the executable jar inside target folder through the following command:
    1. mvn clean package

Saturday, July 7, 2018

fixer api

ussd

  1. USSD (Unstructured Supplementary Service Data) is a Global System for Mobile(GSM) communication technology that is used to send text between a mobile phone and an application program in the network. Applications may include prepaid roaming or mobile chatting.
  2.  

raster vs vector

Saturday, June 23, 2018

mockito

  1. https://medium.com/@gustavo.ponce.ch/spring-boot-restful-junit-mockito-hamcrest-eclemma-5add7f725d4e 
  2. can we use same mock in two different test methods? what would be its implications ie. pros and cons?
  3. what layer is best suitable for being tested through mockito? controller or service? or both?
  4. https://dzone.com/articles/spring-boot-unit-testing-and-mocking-with-mockito
  5. @Mock vs @InjectMocks?

error-selection-does-not-contain-a-main-type

  1. https://stackoverflow.com/questions/31250359/git-repository-how-to-recover-deleted-files
  2. check the folder structure
  3. do you have src/main/java structure and inside it do you have Main class?

github cloning a repository from a specific commit

  1. clone a repository as usual ie 
    1. git clone repository url
    2. user name and password if it is private
  2. git reset --hard a0f64dcd987669aa15d59a39a51f583b3cqd05k2
  3. in the above command the value after hard flag is the SHA of commit at that particular instant of repository
  4. import as maven project in sts

github recovering a deleted file from previous commit

  1. click on total number of commits
  2. here you can view all the commits
  3. now go to a commit where a file existed and click on < > symbol and if you find the file just download it 

Friday, June 8, 2018

redirecting request on port 80 to 8080 on ubuntu

  1. sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-ports 8080
     
    the above command will redirect the requests coming on port 80 to port 8080
     

Thursday, June 7, 2018

spring boot file upload to amazon s3 on ubuntu

  1. https://medium.com/oril/uploading-files-to-aws-s3-bucket-using-spring-boot-483fcb6f8646 
  2. first sign up or login to your amazon account and create bucket in s3. then create a user and give permission ie programmatic access 
  3. @Configuration
    public class S3Config {

        @Value("${userid.aws.access_key_id}")
        private String awsId;

        @Value("${userid.aws.secret_access_key}")
        private String awsKey;
       
        @Value("${userid.s3.region}")
        private String region;

        @Bean
        public AmazonS3 xyz(){
            System.out.println("Inside s3Client of S3Config ");
            BasicAWSCredentials awsCreds = new BasicAWSCredentials(awsId, awsKey);
            AmazonS3 s3Client = AmazonS3ClientBuilder.standard()
                                    .withRegion(Regions.fromName(region))
                                    .withCredentials(new AWSStaticCredentialsProvider(awsCreds))
                                    .build();
            return s3Client;
          }


    }
  4. @Controller
    public class AController {
       
        @Autowired
        private S3Service s3service;
      
              @PostMapping("/uploadFile")
             
            
              public String uploadFile(@RequestPart(value = "xyz") MultipartFile multipartFile,Model map,HttpServletRequest request) {
                 
                  System.out.println("Inside upload file of bucket controller ");

                  try
                  {
                      String filePath = request.getServletContext().getRealPath("/");
                                     
                      System.out.println("filePath is "+filePath);
                      File f1=new File(filePath+"/"+multipartFile.getOriginalFilename());
                      multipartFile.transferTo(f1);
                      System.out.println("f1 is "+f1);                 
                     
                      String fileName=f1.getName();

                   String fileUrl=s3service.uploadFile(fileName, f1);
                 
                  /**
                   * we should be sure that the file has indeed been uploaded 
                   */
                    map.addAttribute("fileUrl", fileUrl);                         
                   f1.delete();
                  
                 /* for rest request
                   return fileUrl;
                   */              
                  
                   return "uploadSuccess";
                  
                  }
                  catch(IOException e)
                  {
                      e.printStackTrace();
                      return e.toString();
                  }
                 
            }
  5. @Service
    public class S3ServicesImpl implements S3Service {
        private Logger logger = LoggerFactory.getLogger(S3ServicesImpl.class);
        /* (non-Javadoc)
         * @see com.epilen.androidPatient.service.aws.s3.S3Service#downloadFile(java.lang.String)
         */
       

       
        @Autowired
        private AmazonS3 s3client;

        @Value("${userid.s3.bucket}")
        private String bucketName;
       
        @Value("${s3.endpointUrl}")
        private String endpointUrl;
       
       
        /**
         * convert multipart to file
         * @param file
         * @return
         * @throws IOException
         */
       
       
        @Override
        public void downloadFile(String keyName) {
           
            try {
               
               System.out.println("Downloading an object");
               S3Object s3object = s3client.getObject(new GetObjectRequest(bucketName, keyName));
               System.out.println("Content-Type: "  + s3object.getObjectMetadata().getContentType());
               Utility.displayText(s3object.getObjectContent());
               logger.info("===================== Import File - Done! =====================");
               
            } catch (AmazonServiceException ase) {
                logger.info("Caught an AmazonServiceException from GET requests, rejected reasons:");
                logger.info("Error Message:    " + ase.getMessage());
                logger.info("HTTP Status Code: " + ase.getStatusCode());
                logger.info("AWS Error Code:   " + ase.getErrorCode());
                logger.info("Error Type:       " + ase.getErrorType());
                logger.info("Request ID:       " + ase.getRequestId());
            } catch (AmazonClientException ace) {
                logger.info("Caught an AmazonClientException: ");
                logger.info("Error Message: " + ace.getMessage());
            } catch (IOException ioe) {
                logger.info("IOE Error Message: " + ioe.getMessage());
            }
        }

        /**
         * this method will return the fileurl
         */
        @Override
        public String uploadFile(String fileName, File file) {
            System.out.println("Inside upload file of S3ServiceImpl");
            try {
                   
                s3client.putObject(new PutObjectRequest(bucketName, fileName, file));
                logger.info("===================== Upload File - Done! =====================");
               
                String fileUrl = endpointUrl + "/" + bucketName + "/" + fileName;
                return fileUrl;
               
            } catch (AmazonServiceException ase) {
                logger.info("Caught an AmazonServiceException from PUT requests, rejected reasons:");
                logger.info("Error Message:    " + ase.getMessage());
                logger.info("HTTP Status Code: " + ase.getStatusCode());
                logger.info("AWS Error Code:   " + ase.getErrorCode());
                logger.info("Error Type:       " + ase.getErrorType());
                logger.info("Request ID:       " + ase.getRequestId());
                return ase.toString();
               
            } catch (AmazonClientException ace) {
                logger.info("Caught an AmazonClientException: ");
                logger.info("Error Message: " + ace.getMessage());
                return ace.toString();
            }
        }

       
    }
  6. public interface S3Service {
            public String uploadFile(String fileName, File file);
    }

  7. pom.xml entry->.   
        <dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>com.amazonaws</groupId>
          <artifactId>aws-java-sdk-bom</artifactId>
          <version>1.11.327</version>
          <type>pom</type>
          <scope>import</scope>
        </dependency>
      </dependencies>
    </dependencyManagement>

      <dependencies>
     
       <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk-s3</artifactId>
      </dependency>
     
       <dependency>
       <groupId>org.apache.httpcomponents</groupId>
       <artifactId>httpclient</artifactId>
       <version>4.5.2</version> 
     </dependency>
     
      the above reduces the jar size from 90 mb to 35 mb and downloads only s3 dependencies
  8. application.properties entries                                                                          userid.aws.access_key_id=  userid.aws.secret_access_key=                                                                             userid.s3.bucket=
    userid.s3.region=
    s3.endpointUrl=

Monday, May 7, 2018

best coding standard

  1. clean coders by uncle bob martin
  2. tdd by example 
  3. polyglot programming

Friday, May 4, 2018

hiring

  1. take enough time in hiring the right people but when once you have hired them, give them full power n flexibility .

angular 4 spring boot integration issues

  1. routing
  2. cache issue
  3. guard issue
  4.  whitelabel issue
  5. can not read property of controls

mongodb installation on windows

  1. windows key
  2. cmd
  3. ctrl+shift+enter for administrator prompt
  4.  msiexec.exe  /q /i mongodb-win32-x86_64-2008plus-ssl-3.6.4-signed.msi INSTALLLOCATION="(drive or install location):\MongoDB\Server\3.6.4\" ADDLOCAL="all"
  5.  the above also installs compass
  6.  add the bin folder location to the path variable
  7.  create \data\db data directory in the drive from which you want to start mongodb
  8. goto the drive where you have installed mongodb and run the mongodb server as follows:
  9. mongod
    1. this server window will be open and wait to listen for the client connection
  10.  now run the mongodb client as mongo on the same drive
  11. cls clears the screen
  12.  ->
  13. reference: 
  14. https://docs.mongodb.com/manual/mongo/ 
  15. https://docs.mongodb.com/manual/introduction/
  16. https://docs.mongodb.com/tutorials/install-mongodb-on-windows/
  17. https://www.mkyong.com/mongodb/how-to-install-mongodb-on-windows/
  18. its set up failed after it took about around 1 hour.
  19. useful:
    1.  https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/
    2. https://docs.mongodb.com/manual/reference/configuration-options/ 
    3.  

angular 4 integration with spring boot

  1. four build files of angular are placed into static folder of Spring boot project

Sunday, April 29, 2018

cloning github wiki repository to the other

  1. solving error "remote repository already exists"
  2. following are the ways: 
  3. git remote rm origin // to remove the existing repository
     
  4. git remote add origin https://github.com/username/abc.wiki.git

     
  5. git add . //for staging files
     
  6. git commit -m  "first doc commit"
    [master 55a63a5] first doc commit
     10 files changed, 1428 insertions(+), 1 deletion(-)
     create mode 100644 A.md
     create mode 100644 R.md
     create mode 100644 D.md
     create mode 100644 G.md
     create mode 100644 N.md
     create mode 100644 P.md
     create mode 100644 Rn.md
     create mode 100644 S.md
     create mode 100644 n.md
  7. git push origin master
    fatal: HttpRequestException encountered.
       An error occurred while sending the request.
     
  8. Username for 'https://github.com': 
  9. Password for
    Counting objects: 12, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (11/11), done.
    Writing objects: 100% (12/12), 7.35 KiB | 0 bytes/s, done.
    Total 12 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), done 
https://stackoverflow.com/questions/10904339/github-fatal-remote-origin-already-exists

Monday, April 23, 2018

Project Management

  1. https://www.atlassian.com/software/jira?_mid=0feb0441a976079b827b9d9027d73822 
  2. https://www.timecamp.com/blog/index.php/2015/09/top-6-benefits-using-time-tracking-jira-2/
  3.  https://drive.google.com/open?id=1t0DT1YgfKflw1HaGmhsY0Xyi2B3-bgxb
  4.  https://www.zoho.com/projects/
  5.  free tools
    1. google hangout for live video sessions
    2. whatsapp group for the team

  6. https://www.backblaze.com/
  7. https://www.zoho.com/mail/
  8. https://www.invisionapp.com/
  9. https://mlab.com/

  10. Bitbucket
    JIRA
    Bamboo
    Confluence
    AWS
    =============================================
    technology architecture
    Microservices
    ==============================================
    technology stack
    Spring boot
    Angular js
    Mongdb
    Express js
    Nodejs
    ===============================================
    Android
    ================================================
    UML
    documentation
    ================================================
    Testing
     unit testing
     automation testing
     performance testing
     security testing
    =================================================
     Clean coding
    =================================================
    scrum
    =================================================
    Design Patterns
    =================================================
    task management
    people management
    project management
    revenue management
    change management
    skill management
    document management
    code management
    ==================================================
    google docs
    whatsapp group
    ===================================================
    UML
    {
    use cases
    }

    Testing
    {
    unit testing
    }
    CI/CD
    AWS
    Maven

    Angular4
    Mongodb
    Spring boot
    ==========
    MSg91
    IBM Watson
    ===========

    * Github
    * JIRA
    * CI/CD
    *  travis
    *  jenkins
    * AWS

    ==========
    QA
    * testing
    * unit testing
    * automation testing
    * performance testing
    * security testing
    * code review
    *  
    * DevOps
    *
    * ===========
    Domain Expert
    * UML
    * OOAD
    * Design Patterns
    * documentation
    =====================
    * AI
    * python
    * machine learning
    * Tensor flow
    ======================
    * AWS technologies
    =======================
    * Mobile User Experience
    * Web User Experience
    * =======================
    * Security Expert
    * =======================
    * IBM Watson Application
    ==========================
    * SMS gateway application
    * interaction through SMS
    * login through SMS
    * auto response through SMS
    ===============================
    Revenues
    =================================
    Risk Management
    ===================================
    People Management
    ===================================
    Task Management
    ===================================

JPA Latest

JPA derived identifier

Wednesday, April 18, 2018

security

IDE speed up

aws codecommit

aws deployment from codecommit to elasticbeanstalk environment

recaptcha v2

git add-all-files-to-a-commit-except-a-single-file

Friday, April 13, 2018

spring data jpa reference

Table 4. Supported keywords inside method names
Keyword Sample JPQL snippet
And
findByLastnameAndFirstname
… where x.lastname = ?1 and x.firstname = ?2
Or
findByLastnameOrFirstname
… where x.lastname = ?1 or x.firstname = ?2
Is,Equals
findByFirstname,findByFirstnameIs,findByFirstnameEquals
… where x.firstname = ?1
Between
findByStartDateBetween
… where x.startDate between ?1 and ?2
LessThan
findByAgeLessThan
… where x.age < ?1
LessThanEqual
findByAgeLessThanEqual
… where x.age <= ?1
GreaterThan
findByAgeGreaterThan
… where x.age > ?1
GreaterThanEqual
findByAgeGreaterThanEqual
… where x.age >= ?1
After
findByStartDateAfter
… where x.startDate > ?1
Before
findByStartDateBefore
… where x.startDate < ?1
IsNull
findByAgeIsNull
… where x.age is null
IsNotNull,NotNull
findByAge(Is)NotNull
… where x.age not null
Like
findByFirstnameLike
… where x.firstname like ?1
NotLike
findByFirstnameNotLike
… where x.firstname not like ?1
StartingWith
findByFirstnameStartingWith
… where x.firstname like ?1 (parameter bound with appended %)
EndingWith
findByFirstnameEndingWith
… where x.firstname like ?1 (parameter bound with prepended %)
Containing
findByFirstnameContaining
… where x.firstname like ?1 (parameter bound wrapped in %)
OrderBy
findByAgeOrderByLastnameDesc
… where x.age = ?1 order by x.lastname desc
Not
findByLastnameNot
… where x.lastname <> ?1
In
findByAgeIn(Collection<Age> ages)
… where x.age in ?1
NotIn
findByAgeNotIn(Collection<Age> ages)
… where x.age not in ?1
True
findByActiveTrue()
… where x.active = true
False
findByActiveFalse()
… where x.active = false
IgnoreCase
findByFirstnameIgnoreCase
… where UPPER(x.firstame) = UPPER(?1)

recording screencast

loading four most recent pictures


  1. <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>jQuery.getJSON demo</title>
    <style>
    img {
    height: 100px;
    float: left;
    }
    </style>
    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
    <body>
    <div id="images"></div>
    <script>
    (function() {
    var flickerAPI = "https://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
    $.getJSON( flickerAPI, {
    tags: "mount rainier",
    tagmode: "any",
    format: "json"
    })
    .done(function( data ) {
    $.each( data.items, function( i, item ) {
    $( "<img>" ).attr( "src", item.media.m ).appendTo( "#images" );
    if ( i === 3 ) {
    return false;
    }
    });
    });
    })();
    </script>
    </body>
    </html>

spring recaptcha integration

Monday, April 9, 2018

Saturday, April 7, 2018

Spring and Mongodb and Java

object references an unsaved transient instance

  1. https://stackoverflow.com/questions/2302802/object-references-an-unsaved-transient-instance-save-the-transient-instance-be
  2. i was getting the error when i was instantiating country which was not linked to database row and using this country as a parameter for fetching states. so i  used string country name and got the reference of country in the database and used this country as parameter to fetch the states then it worked.

thymeleaf with servlet

spring boot ajax example

spring boot json thymeleaf fragment example

JPA doubts

  1. what happens when new entities and attributes are defined in a production database that has thousands of data. what are the implications?

json in spring boot

spring boot thymeleaf example

Monday, April 2, 2018

aws useful resources

  1. route 53 
  2. IAM role
  3. s3
  4. elastic beanstalk
  5. sns
  6. cloudwatch
  7. rds
  8. ec 2


aws sms through sns

aws elastic beanstalk application deletion

  1. when the aws elastic bean application is deleted rds instance is automatically deleted
  2. ec2 instance is also deleted
  3. s2 bucket content should be deleted because it is not deleted automatically

Tuesday, March 27, 2018

linux

rest payload max limit

spring boot rest api

Labs

spring boot angular json example

Spring boot exception handling

debugging json

freelancer guide

contribution required

  1. apache
  2. JSR
  3. shopizer
  4. eclipse
  5. firefox
    1. mdn
  6. tomcat
  7. spring
  8. hibernate
  9. android

Monday, March 26, 2018

http

Spring Security

geofencing

Ajax

debugging in browser

domain modellig techniques

Saturday, March 24, 2018

enabling enum inheritance

date time formatting

next

  1.  JPA
    1. mapping inner class
    2. mapping inner interface
  2. save data in database
  3. apply dynamic fileds functionality in registration
  4. accept the values into collection
  5. save the values in database
  6. validation
  7. check for duplicacy
  8. type conversion
  9. all the form should be populated with values from database. not the present case where values are hardcoded.
  10. applying sms gateway 
  11. mobile verification through otp
  12. apply reactjs
  13. apply redux with reactjs

dynamic field creation

doubt is out

  1. accepting multiple values e.g mobile numbers in to a collection

Thursday, March 22, 2018

spring boot hibernate validator dependency

spring boot starter web dependency already includes hibernate validator dependency.