<?xml version="1.0" encoding="UTF-8"?> <Configuration status="INFO"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> </Console> <File name="MyFile" fileName="all.log" immediateFlush="false" append="false"> <PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </File> </Appenders> <Loggers> <Root level="debug"> <AppenderRef ref="Console" /> <AppenderRef ref="MyFile"/> </Root> </Loggers> </Configuration>
Friday, November 27, 2015
Very Simple Log4j2 xml Configuration Example
Thursday, November 26, 2015
Simulating Network TCP Delay Using Linux Commands
Keep in mind that this only works for outbound traffic, so choose your network interface accordingly.
sudo tc qdisc add dev eth0 root netem delay 100ms
To check status
sudo tc -s qdisc
sudo tc qdisc del dev eth0 root
To add 100ms to all outbound traffic on etho
sudo tc qdisc add dev eth0 root netem delay 100ms
To check status
sudo tc -s qdisc
To remove the delay from eth0
sudo tc qdisc del dev eth0 root
Tuesday, November 17, 2015
How to deploy a local jar to maven repository
mvn install:install-file
-Dfile=<path-to-file>
-DgroupId=<group-id>
-DartifactId=<artifact-id>
-Dversion=<version>
-Dpackaging=<packaging>
-DgeneratePom=true
Where: <path-to-file> the path to the file to load
<group-id> the group that the file should be registered under
<artifact-id> the artifact name for the file
<version> the version of the file
<packaging> the packaging of the file e.g. jar
Sunday, October 4, 2015
Working with hashCode and equals methods in java
In this post, I will point out my understanding about hashCode and equals methods in java. I will talk about how their default implementation and how to override them correctly.
hashCode() and equals() methods have been defined in Object class which is parent class for java objects. For this reason, all java objects inherit a default implementation of these methods.Configuring a remote for a fork
To sync changes you make in a fork with the original repository, you must configure a remote that points to the upstream repository in Git.
- Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
- List the current configured remote repository for your fork.
git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
- Specify a new remote upstream repository that will be synced with the fork.
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git - Verify the new upstream repository you've specified for your fork.
git remote -v # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch) # origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch) # upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
Saturday, October 18, 2014
Wild Card Paramters in Java
In this post I'm going to give you a small introduction about Wild card parameters used is java.
In java, Type parameters for generics have a limitation. Generic type parameters should match exactly for assignments. for example, If we use following statement in a java program, it will give a compilation error of incompatible types.
List<Number> intList = new ArrayList<Integer>();
If we slightly change the above statement to use wildcard parameter, it will compile without any errors.
List<?> wildCardList = new ArrayList<Integer>();
So, what does a wildcard mean? It's just like the wildcard, you use for substituting for a card in a card game. In java, you can use a wildcard parameter to indicate that it can match any type. With List<?>, you can mean that it is a List of any type. But when you want a type a indicating "any type", you may use the Object class, don't you? How about the statement, but using the Object type parameter?
List<Object> wildCardList = new ArrayList<Integer>();
No luck, you will get same compilation error you got when you used the first statement. In this case you are still trying to use subtyping for generic parameters. As you can see, List<Object> and List<?> are not same. In face List<?> is a super type of any List type. which means you can pass List<Integer>, or List<String>, or even List<Object> where List<?> is expected.
Thanks
In java, Type parameters for generics have a limitation. Generic type parameters should match exactly for assignments. for example, If we use following statement in a java program, it will give a compilation error of incompatible types.
List<Number> intList = new ArrayList<Integer>();
If we slightly change the above statement to use wildcard parameter, it will compile without any errors.
List<?> wildCardList = new ArrayList<Integer>();
So, what does a wildcard mean? It's just like the wildcard, you use for substituting for a card in a card game. In java, you can use a wildcard parameter to indicate that it can match any type. With List<?>, you can mean that it is a List of any type. But when you want a type a indicating "any type", you may use the Object class, don't you? How about the statement, but using the Object type parameter?
List<Object> wildCardList = new ArrayList<Integer>();
No luck, you will get same compilation error you got when you used the first statement. In this case you are still trying to use subtyping for generic parameters. As you can see, List<Object> and List<?> are not same. In face List<?> is a super type of any List type. which means you can pass List<Integer>, or List<String>, or even List<Object> where List<?> is expected.
Thanks
Wednesday, August 20, 2014
How to Configure Embedded Jetty Server with Maven
Hi Guys,
Through this post, I will show how to configure the embedded jetty server plugin with maven projects. First let's see what is Jetty. Jetty is a light weight web server. In it you can deploy your web application during the development phrase.
The Jetty Maven plugin is useful for rapid development and testing. You can add it to any webapp project that is structured according to the usual Maven defaults. The plugin can then periodically scan your project for changes and automatically redeploy the webapp if any are found. This makes the development cycle more productive by eliminating the build and deploy steps.
Lets see how to setup the jetty server into maven projects
First step, Create a maven web app project. use the following command in to create a new hello world project.
Once your project creation successful, a new web application project named “hello-webapp“, and the entire project directory structure is created automatically. Then go to that project root directory and open the pom.xml and then add the following code block within the build tag.
Through this post, I will show how to configure the embedded jetty server plugin with maven projects. First let's see what is Jetty. Jetty is a light weight web server. In it you can deploy your web application during the development phrase.
The Jetty Maven plugin is useful for rapid development and testing. You can add it to any webapp project that is structured according to the usual Maven defaults. The plugin can then periodically scan your project for changes and automatically redeploy the webapp if any are found. This makes the development cycle more productive by eliminating the build and deploy steps.
Lets see how to setup the jetty server into maven projects
First step, Create a maven web app project. use the following command in to create a new hello world project.
Once your project creation successful, a new web application project named “hello-webapp“, and the entire project directory structure is created automatically. Then go to that project root directory and open the pom.xml and then add the following code block within the build tag.
Once you add this plugin, you can deploy your hello-webapp application into jetty-server. To deploy the webapp in to jetty server, you the command as follows
then to view your web app in your browser localhost:8080/hello-webapp then try more complicated examples.
Saturday, July 26, 2014
Intro about D3js
In this post I'm going to write an introduction about one of the JavaScript library called D3js.
The D3js JavaScript library helps us to make beautiful, interactive, browser-based data visualizations. And this D3js allows us to manipulate elements of a web page in the context of a data set. These elements can be HTML, SVG (Scalable Vector Graphics) , or Canvas elements, and can be introduced, removed, or edited according to the contents of the data set.
Before moving to an example on this, we should know some fundamentals things when we developing a web page. such as HTML, CSS, JavaScript, SVG ans Canvas elements. I assume that you know about those fundamentals.
Let's look at a basic code structures
<!DOCTYPE html> <html> <head> <meta charset="utf-8">
<style>.........</style><script src="d3.js"></script> (1) <script> function draw(data) { (2)// D3 visualization code goes here} </script> </head> <body> ...... <script> d3.json("data/some_data.json", draw); (3) </script> </body> </html>
Have a look at the following description of the about blocks
(1) The D3js library is included to give our visualizations access to the D3js methods.
(2) Here, we always call draw function. Once it is called the data has been downloaded to the client. It will contain the bulk of the code necessary to create the visualization.
(3) The d3.json() function makes an HTTP GET request to a JSON file at the URL described by its first argument and once the data has been downloaded, will then call the function passed as the second argument. This second argument is a callback function (which we will always call draw), which is passed, as its only parameter, the contents of the JSON having been turned into an object or an array, whichever is appropriate.
Look at the following codes
Let me explain by showing an example. Here we will make a simple horizontal bar chat with use of D3js. I'm going to use the following code block which is a common standard structure for HTML page with JavaScript and CSS.
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Bar Chart</title> <style> .chart div { background-color: steelblue; text-align: right; padding: 3px; margin: 1px; color: white; } </style> <script src="d3.js"></script> </head> <body> <div class="chart"></div> <script> var data = [4, 8, 15, 16, 23, 42]; var x = d3.scale.linear() .domain([0, d3.max(data)]) .range([0, 420]); d3.select(".chart") .selectAll("div") .data(data) .enter().append("div") .style("width", function (d) { return x(d) + "px"; }) .text(function (d) { return d; }); </script> </body> </html>
Copy and paste above code into a html page. and open it in the browser.
Enjoy with the Graph.
Monday, January 13, 2014
Tuesday, January 7, 2014
Do You Know?
1. Your shoes are the first thing people subconsciously notice about you. Wear nice shoes.
2. If you sit for more than 11 hours a day, there's a 50% chance you'll die within the next 3 years
3. There are at least 6 people in the world who look exactly like you. There's a 9% chance that you'll meet one of them in your lifetime.
4. Sleeping without a pillow reduces back pain and keeps your spine stronger.
5. There are three things the human brain cannot resist noticing - Food, attractive people and danger
6. Right-handed people tend to chew food on their right side
7. You can survive without eating for weeks, but you will only live 11 days without sleeping.
8. People who laugh a lot are healthier than those who don’t.
9. Laziness and inactivity kills just as many people as smoking.
10. A human brain has a capacity to store 5 times as much information as Wikipedia
11 Our brain uses same amount power as 10-watt light bulb!!
12. Our body gives enough heat in 30 mins to boil 1.5 litres of water!!
2. If you sit for more than 11 hours a day, there's a 50% chance you'll die within the next 3 years
3. There are at least 6 people in the world who look exactly like you. There's a 9% chance that you'll meet one of them in your lifetime.
4. Sleeping without a pillow reduces back pain and keeps your spine stronger.
5. There are three things the human brain cannot resist noticing - Food, attractive people and danger
6. Right-handed people tend to chew food on their right side
7. You can survive without eating for weeks, but you will only live 11 days without sleeping.
8. People who laugh a lot are healthier than those who don’t.
9. Laziness and inactivity kills just as many people as smoking.
10. A human brain has a capacity to store 5 times as much information as Wikipedia
11 Our brain uses same amount power as 10-watt light bulb!!
12. Our body gives enough heat in 30 mins to boil 1.5 litres of water!!
Monday, January 6, 2014
Power digit sum
If you are a best programmer, can you able to find the answer for the following question?
Q. 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 21000?
I found the answer using Scala programming.
BigInt(2).pow(1000).toString().map(_.asDigit).sum
Can you able to write code to find the answer using your preferred programming language except Scala?
Sunday, January 5, 2014
Saturday, January 4, 2014
Friday, January 3, 2014
Free Version Control Hosting for private repositories
You may have used any Version Control System to keep and maintain your multiple versions of your projects or any related documents. For that you may also have used several hosting servers.
But regardless of what Version Control System you use, you have to think about where you intend to store your code. It’s likely you’ve have heard of GitHub. That’s not surprising. GitHub is used by individuals and enterprises to host code, collaborate on documentation and track issues. It has some pretty big names using it.
Since last 3 years I was using Gihub to host my projects. It is simple and provides free hosting services for public projects. For a long time I was searching for a free hosting services for privates repositories. Finally I found a hosting server that they are providing free hosting servers for privates repositories named Bit Bucket
Here we can manage unlimited number of private repositories. It allows to contribute 5 users together as free. Otherwise we need to pay. Finally I started to using BitBucket for my projects hosting.
Thursday, January 2, 2014
Copyright statements on some websites
Today is 2nd of January 2014. I unexpectedly saw one of the world famous well know microsoft website's copyright statement. http://www.microsoft.com/en-us/default.aspx . It was year of 2013. I confused why they are showing past year in their copyright statements.
Then I went to some other well know websites. They also used the static copyright statements.
This is the copyright statement of Google.
http://epay.lk/
http://www.linux.org/
Saturday, October 12, 2013
Viber available for Linux
Viber is cross-platform application (iPhone, Android, Windows Phone, Blackberry, Windows, Mac, Symbian, Nokia and Bada devices), it allows users to send free messages and make free calls to other Viber users, on any device and network, anywhere in the world.
Previously viber team released viber application for Linux but it is still in development (beta version) and available for everyone to test it. So we build package for this application to install it in Debian/Ubuntu/and it's derivatives easily.
To install Viber (64bit only) in Debian/Ubuntu/Linux Mint open Terminal (Press Ctrl+Alt+T) and copy the following commands in the Terminal:
wget -O viber64-NoobsLab.com.deb http://goo.gl/wCKnDV
sudo dpkg -i viber64-NoobsLab.com.deb
rm viber64-NoobsLab.com.deb
Tuesday, September 17, 2013
Linux File & Folder Permissions
File & folder security is a big part of any operating system and Linux is no exception!
These permissions allow you to choose exactly who can access your files and folders, providing an overall enhanced security system. This is one of the major weaknesses in the older Windows operating systems where, by default, all users can see each other's files (Windows 95, 98, Me).
For the more superior versions of the Windows operating system such as NT, 2000, XP and 2003 things look a lot safer as they fully support file & folder permissions, just as Linux has since the beginning.
Together, we'll now examine a directory listing from our Linux lab server, to help us understand the information provided. While a simple 'ls' will give you the file and directory listing within a given directory, adding the flag '-l' will reveal a number of new fields that we are about to take a look at:
Creating Simple RSS Reader as an Android Application
RSS is a family of web feed formats used to publish frequently updated works. Such as blog entries, news headlines,audio and video in a standardized format. - wikipedia-
Basically RSS are xml files. We can read RSS files using applications called RSS Readers. In this post, I am going to write about how to create a simple RSS Reader application in Android platform.
In this example, I have used an external 'xml'(RSS) of the website.
RSS Link: http://www.mobilenations.com/rss/mb.xml
Basically RSS are xml files. We can read RSS files using applications called RSS Readers. In this post, I am going to write about how to create a simple RSS Reader application in Android platform.
In this example, I have used an external 'xml'(RSS) of the website.
RSS Link: http://www.mobilenations.com/rss/mb.xml
Tuesday, September 10, 2013
Installing Nodejs in Ubuntu
Simply execute the following commands in Ubuntu Terminal
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Saturday, July 6, 2013
Introduction to shell script
Before going to start the shell script programming we mush know what is kernel? , what is shell?, what is process?, and what is redirection, pipe and filter?
What is kernel?
Kernel is heart of Linux OS. It manages resources in Linux OS. The resources means the facilities available in Linux. For example, facility to store the data, print data on printer, memory and file management and etc.Kernel decides who will use this resource, for how long and when.
What is Linux Shell?
In early days of computing, instructions are provided using binary language, which is difficult for all of us to read and write. So, in Linux, there is a special program called Shell. Shell accepts our instruction or commands in English and translate it into computers native binary language.
What is Process?
Process is a kind of program or task carried out by our PC. For example, $ ls is the command to list files and folders in current directory. It a kind of process. A process is a program to perform some job.
What is Redirection?
Mostly all commands gives output on screen or takes input from keyboard, but in Linux it is possible to send output to file or to read from file. This is called redirection.
For example,
What is kernel?
Kernel is heart of Linux OS. It manages resources in Linux OS. The resources means the facilities available in Linux. For example, facility to store the data, print data on printer, memory and file management and etc.Kernel decides who will use this resource, for how long and when.
What is Linux Shell?
In early days of computing, instructions are provided using binary language, which is difficult for all of us to read and write. So, in Linux, there is a special program called Shell. Shell accepts our instruction or commands in English and translate it into computers native binary language.
What is Process?
Process is a kind of program or task carried out by our PC. For example, $ ls is the command to list files and folders in current directory. It a kind of process. A process is a program to perform some job.
What is Redirection?
Mostly all commands gives output on screen or takes input from keyboard, but in Linux it is possible to send output to file or to read from file. This is called redirection.
For example,
Subscribe to:
Posts (Atom)


