Thursday, June 16, 2022

cloc – Count Lines of Code in Many Programming Languages

 

While working on different projects, sometimes you might be required to provide a report or statistics of your progress, or simply to calculate the value of your code.

There is this simple yet powerful tool called “cloc – count lines of code” that allows you to count all number of your code and exclude comments and blank lines at the same time.

It is available in all major Linux distributions and supports multiple programming languages and file extensions and does not have any specific requirements to be used.

In this tutorial you are going to learn how to install and use cloc on your Linux system.

 

Use this  link  to  complete  article    :-  https://www.tecmint.com/cloc-count-lines-of-code-in-linux/

Wednesday, January 12, 2022

Using Special Characters in Strings in Java

When a string is being created or displayed, its text must be enclosed within double quotation marks to indicate the beginning and end of the string. These quotation marks are not displayed, which brings up a good question: What if you want to display double quotation marks?

To display them, Java has created a special code that can be put into a string: \". Whenever this code is encountered in a string, it is replaced with a double quotation mark. For example, examine the following:

System.out.println("Jane Campion directed \"The Piano\" in 1993.");

This code is displayed as the following:

Jane Campion directed "The Piano" in 1993.

You can insert several special characters into a string in this manner. The following list shows these special characters; note that each is preceded by a backslash (\).

Special characters

Display

\'

Single quotation mark

\"

Double quotation mark

\\

Backslash

\t

Tab

\b

Backspace

\r

Carriage return

\f

Formfeed

\n

Newline


The newline character causes the text following the newline character to be displayed at the beginning of the next line. Look at this example:

System.out.println("Music by\nMichael Nyman");

This statement would be displayed as the following:

Music by
Michael Nyman
 
Reference :-  https://www.informit.com/articles/article.aspx?p=30241&seqNum=3 

Thursday, December 23, 2021

Spring Boot File Download Example

 From  below  documentations  have  good  articles  about   file  download .

 

 

  • https://javadeveloperzone.com/spring-boot/spring-boot-download-file-example/


  • Basically there is no need to add produces = "application/pdf" in RequestMapping as it seems to try to convert the ResponeBody internally. You can just add MediaType to response headers which is what you need.
@ResponseBody
@RequestMapping(value = "get/pdf/{id}", headers="Accept=*/*", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> getPdfContractById(@PathVariable("id") Long id){
        // Get the remove file based on the fileaddress
        RemoteFile remotefile = new RemoteFile(id);

        // Set the input stream
        InputStream inputstream = remotefile.getInputStream();
        // asume that it was a PDF file
        HttpHeaders responseHeaders = new HttpHeaders();
        InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
        responseHeaders.setContentLength(contentLengthOfStream);
        responseHeaders.setContentType(MediaType.valueOf("application/pdf"));
        // just in case you need to support browsers
        responseHeaders.put("Content-Disposition", Collections.singletonList("attachment; filename=somefile.pdf"))
        return new ResponseEntity<InputStreamResource> (inputStreamResource,
                                   responseHeaders,
                                   HttpStatus.OK);
}
Reference :- https://stackoverflow.com/a/33877513/5802185 

Thursday, December 16, 2021

Can I Email… Useful tool when creating email templates

 While I’m 85% certain you’ve seen and used Can I Use…, I bet there is only a 13% chance that you’ve seen and used Can I Email…. It’s the same vibe—detailed support information for web platform features—except instead of support information for web browsers, it is email clients. Campaign Monitor has maintained a guide for a long time as well, but I admit I like the design style pioneered by Can I Use….

 

 

 

 

References Used :-  https://css-tricks.com/can-i-email/

 

 

 

 

 

 

 

 

 

Monday, October 11, 2021

Model Tree Structures in Mongo DB

Hope this  document will  help  to model   hierarchical or nested data relationships with mongoDB .

MongoDB allows various ways to use tree data structures to model large hierarchical or nested data relationships.

Tree data model for a sample hierarchy of categories.
Model Tree Structures with Parent References
Presents a data model that organizes documents in a tree-like structure by storing references to "parent" nodes in "child" nodes.
Model Tree Structures with Child References
Presents a data model that organizes documents in a tree-like structure by storing references to "child" nodes in "parent" nodes.
Model Tree Structures with an Array of Ancestors
Presents a data model that organizes documents in a tree-like structure by storing references to "parent" nodes and an array that stores all ancestors.
Model Tree Structures with Materialized Paths
Presents a data model that organizes documents in a tree-like structure by storing full relationship paths between documents. In addition to the tree node, each document stores the _id of the nodes ancestors or path as a string.
Model Tree Structures with Nested Sets
Presents a data model that organizes documents in a tree-like structure using the Nested Sets pattern. This optimizes discovering subtrees at the expense of tree mutability.
 
Reference  Used :-   https://docs.mongodb.com/manual/applications/data-models-tree-structures/
 

Sunday, August 29, 2021

Solve the challenges and pursue ICT career opportunities by showcasing your skills to the IT/BPM companies in Sri Lanka.

This is  some  thing  interesting  I  seen ,  for  our  career growth.

 These challenges are there for you to learn the basic skills required by any IT related profession. You should be able to lean and complete a single challenge within 1 or 2 days. Please solve the challenges in sequence. Once you solve a particular challenge you will have to submit the results and take a small assessment to demonstrate your understanding.

 

Solve the challenges and pursue ICT career opportunities by showcasing your skills to the IT/BPM companies in Sri Lanka. 

Monday, August 23, 2021

RabbitMQ vs Kafka | Trade-off's to choose one over other

Here  are  some  good videos  I  have seen  about  " RabbitMQ vs Kafka "



2.   RabbitMQ & Kafka  by  VMware Tanzu


Features of Kafka :- 




Some  important  tips captured  from  above  videos  are :-  



 




Version   1.0.1



Some interesting things to explore more

 Here  some  some  things  to  study  more ,     How Google Search works               https://developers.google.com/search/docs/fundamental...