Menu bars

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 19 September 2018

Spring important links to check out

If you want to read about Spring life cycle, how to add actions in between the spring life cycle methods or how to use *aware interfaces like ApplicationContextAware interfaces -  Read this link

Do you want to understand how dependency injection works ? Or want to know about the types of DI ? Or even why one should not use @autowired ? See this link

Want to look at different annotation available ? here it is

Java Thread : Brush up links

Threads are most important topics for any java interviews. Knowing thread deeper will give you extra impression on the interviewer as threads are relatively untouched & difficult section of java for most of the java developers. I am listing the basic thread related links that i have came across and hopefully this will help you to prepare for your next java interview.

First of all we need to get hold on the basics of the thread concepts in java including creation, race conditions, locks etc. You can refer this article for basics. Before that if you want to learn how OS deals with threads and what are the different types of concurrency available then this article will give you an excellent write up about the back ground. The blog callicoder has listed all the major topics very clearly with examples with Java 8. Please check all the blog series in the left panel. It talks about executor service, callable, synchronization and locks. Atomic variables are thread safe option as well. So we need to understand how atomic variables take of thread safety. You can find the article here.

Java 1.5 has introduced a number of concurrent collections and it is very important to know about these utilities during interviews.

ThreadLocal - In Details
BlockingQueue
Counting Semaphore




This article will help you write your own thread pool from scratch. It's worth reading.



Wednesday, 16 May 2018

Natural Language Processing Notes

Natural language processing is one of widely used area with a lot of real word applications. This is my notes related to NLP. Mostly i will be noting down the links that are needed for detailed analysis of the same.

Lets get into the basics

First thing first !! if you want to get to know the very basics of the here is the best starting point with hands on course : See the links.

Oh wait !! how do we create features ? bag of words ? look into this blog for details on how can we extract features.

Okey. Now i understand that the need of knowing the grammar of  english language. Here is some basic concept needed for grammars. See the link

But i need to get some strong basic concepts of NLP. Lets learn from the Stanford guys:
1) http://web.stanford.edu/class/cs224u/
2) Search for CS224N and CS224D

This particular link provides some good learning links - https://www.quora.com/How-do-I-learn-Natural-Language-Processing

Some general Reading about NLP - https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3168328/


Examples of NLP based Sentiment Analysis

http://www.vikparuchuri.com/blog/natural-language-processing-tutorial/
https://www.kaggle.com/c/word2vec-nlp-tutorial/details/part-1-for-beginners-bag-of-words
http://streamhacker.com/2010/05/10/text-classification-sentiment-analysis-naive-bayes-classifier/
https://github.com/cjhutto/vaderSentiment




grammer : 
http://www.ps.uni-saarland.de/~niehren/oz-natural-language-script.html/vorlesung/node49.html

Important Nodejs packages

I wanted to note down important nodejs packages that i am using daily which will solve many of the common issues that we face frequently.


Moment

Date manipulation is a headache in every programming language and nodejs is no different from its peers. Moment will be helping you out for all your date format issues, difference between dates kind of problems. Certainly this is a package that you need to have.

Tutorial - Moment.js

Mongoose

Want to use mongodb ? It is always advised to use a ORM for that which will reduce your work and make your life easier. Mongoose is the best option for mongodb ORM.

Check these links for details : kompulsa.com and scotch.io

Child Process

This is one of the most important package in the nodejs where it is responsible for creating another process from the nodejs code so that it wont block the single thread of the nodejs.

Check the details : krasimirtsonev.com 






Monday, 2 April 2018

System Design 1 - MapReduce

I was always wondered the difference between clusters and horizontal scaling. I was under an impression that both are same. Recently i was reading this link about the Map reduce that forced me to think again on the difference between clustering and horizontal scaling. I have discussed the same with one of my peer as well to get the clarity. This is what my understanding regarding the same.




Horizontal scaling is used in the case of scalability. If your application getting more traffic than usual then you need to scale the system to handle more requests like you add more suppliers in the restaurants when there are more people visiting the same. So each supplier can independently work to attain his goal. In our case we will add more hosts to the application which will handle requests completely independent. But who will tell these requests to go to this particular host ? load balancer comes into the picture now. Load balancer will route the request to hosts which having lesser load at that point of time. Load balancer is the external facing server , so it has to be highly available. So we must need to keep a backup node for the load balancer. So the time when the main load balancer dies then the backup should take the control.

Clustering is used when we have a computationally large problem and we need more resources to solve it parallel. So we will break the problem into subtasks and assign different tasks to different nodes and the results will be combined together to make the final result. This is distributed computing. MapReduce is helping us to create these distributed tasks.

Map will break down the tasks and give to all the mapping node, there will be a aggregator which will aggregate and give the result to the reducer. Reducer will reduce the map results to the final result.

You can read more about the map reduce function in this article.
Want to understand mapreduce through an example, this article is a good start.
  

Sunday, 18 June 2017

Building a Spring boot application in Ubuntu 16.04 using gradle and Running a headless chrome from selenium

Hello everyone, this is my side by side blog on how to build my spring boot application in Ubuntu 16.04. I have already a project with basic spring boot specification which has build using gradle. This is my learning project on gradle and spring boot. So we all need a unix based os for deploying these to a cloud based hosting like digital ocean. So lets start.

These are the steps that i have already done.
1. Installed gradle in ubuntu 16.04 by following this article.
2. Copy the spring boot project to ubuntu box.
3. Installed Mongodb on Ubuntu machine by following this article
4. Installed Java 1.8

Oh.. Gradle !! Yeah it is a build automation tool that will take care of all the dependency and build tasks that we need to do while creating a project. Of course you can use other build tools like Maven,ant etc. But gradle comes with more power that other build tools in java.

Heard about gradlew ? It is worth looking into this if you are using gradle which will reduce your headache of installing gradle and will escape you from the version mismatch drama. Gradle vs gradlew ? . Gradle wrapper command will create gradlew.

Ok. lets come back to our Ubuntu Box. Our objective is to run spring boot in Ubuntu machine and the boot application is having a dependency on mongodb services. So we need to setup that as well.

You just need to go to the root directory where the build.gradle file exist and execute the command gradle bootRun. This will launch the spring boot process and you will something like below.


Yay !! spring boot has started !!.

One of my requirement for this spring boot project is that i want to run a selenium scrapper from this project that too headlessly using chrome. This link provides you more information on how can you install headless selenium.

Luckily Chrome has rolled out chrome-59 with headless feature which we can use for our experiment. Get the latest version of the chrome from this link.

So  i have installed google-chrome 59 and all ready for running my headless chrome instance with selenium with spring boot. I have tested my application code in my windows machine and it worked like a charm. Now i am testing it on my Ubuntu server. fingers crossed !

It throws me unable to start exception. Mostly its because Ubuntu server is not able to start it on a graphical way. Lets investigate.


woo.. after a long 3-4 hours i could run the chrome 59 headless from selenium. Initially i was getting the same above error whatever i changed. I did a lot of googling to find out why the same exception coming. It was due to one of my big blunder of adding the wrong system property. I was adding the actual chrome installation path in the webdriver.chrome.driver property. Everything started working once i replaced the same with chrome-driver location.

For that i have downloaded the chrome-driver from the Chromium.org download site. And i did something similar including the symlink like this.

This particular script written in Github shows all the steps that we need to do to install the Chrome+selenium combo in your Unix boxes.

So here is my complete java code that running the selenium which invoke the headless google-chrome in Ubuntu machine.


And we need to pass the extra arguments for running the chrome in headless mode(Note that this feature available only google-chrome-59 onwards). The versions of the applications that used as follows.

Java - 1.8
Selenium - 3.*
google-chrome - 59
chromeDriver - 2.3

That's it guys. We have successfully ran our spring boot application which can invoke chrome instance headless way from selenium. Tune in for more. Thanks a lot.  

Sunday, 30 April 2017

Pointers for Spring boot + Mongodb applications

Connecting the mongodb database to spring boot is very important and powerful. The most easy way to persist your application data is to store it somewhere. We all do it by storing it into some kind of databases. In these types of databases i found out that mongodb is very easy to handle and configure as it is schema-less. So i dont need to create any sort of database design instead i can send my json file for saving it and i can retrieve it back.

First of all, lets look into some basic links that needed.

1a. Install mongodb on ubuntu 16.04 - Link
1b. Install mongodb on windows 7 -  Link

2. You can use mongo command to see the CLI of mongo instance that is running, a few basic         commands as follows.
    - show dbs
    - show collections
    - db.{collection_name}.find()

If you want to understand how MongoDB can be used in spring boot then this link will give you a good idea to do it.  In this article you can see that there are two types of connection that can be used to connect to mongodb and i found out that mongotemplate is having much more flexibility.

More complex mongoTemplate queries can be made by following this article.


============================== References==================================
It is a good starting point for starting spring boot applications. It follows very good design patterns to follow. Check here

You might also need to get some of the annotations that are needs to be used. check this