Posts

Showing posts from 2017

how to run node js file

Image
Hey Friends! How are you ? I think you all are fine if not then I pray to God for your good health and happy life.I got a lot of mail from readers about nodejs. So I have decided to prepare couple of post to clear basic concepts of node.js and I have prepared few posts and I promised you that from these posts you can be able to clear your basic concepts. Now, at first we set up our system so that it can be able to run node js file. You are not launching rocket just running a node js file. Don't worry because you are not launching rocket in which you have to consider a lot of parameters.Your problem is just to run  node js file. Sharp your axe. Once Abraham Lincoln had said "Give me six hours to chop down a tree and I will spend the first four sharpening the axe." So before run node js file at first we have to prepare system so that it can be able to run node js file. for this purpose  at first consider we have to consider about node js setup. n

Java Web Scraping

Image
Today I introduced you from a new word i.e. Web scraping this word is used for extracting data from a website for some purpose. In this technique we extract large amount data from website and store inside our local file or we can also store these data inside our database for personal use .Now this technique is widely used all around the world because in the age of Information data is every thing.As much amount of you have as much power you have.Most of programming languages contains package for Web Scraping such in python we used BeautifulSoup.  BeautifulSoup is a fantastic tool of python for web Scraping. I don't know much about python and I am good in java so, here I am discussing here  how we can scarp data from website using concepts of Java? Now, we are presenting a little package for Java web Scarping. Jsoup is an open source Java HTML parser. Jsoup is an open source HTML parser which is used for scraping in Java.It uses DOM,CSS and Jquery-like methods for extra

Java Variable Types

Image
Variables are name of reserved memory location inside Program.  Based on Position of Declaration and behavior all Variables are divided into three categories. Local Variable Instance Variable Static Variable                                                                               Local Variable : Variable that is declared inside method is called Local Variable. Instance Variable : If a variable value varied from object to object then such type of variable are called Instance Variable. In case of Instance Variable a separate copy of instance variable is created. Where we have to declare Instance Variable ?  Instance Variable should be declared within class directly, but outside of any method or block or constructor. Note: As we discussed previously variable declared inside any method or block or constructor as known as Local Variable. class InstanceVariable{ int x=10; public static void main(String a[]){ } } When Instance Variable wi

Subsequence Equality

Image
Hey guys, This problem I have taken from www.codechef.com to speed up our coding practice skills and now regularly add a new problem with its solution to clear our Java concept and sharp our logical skills. Problem :  Chef Tobby is playing a rapid fire with Bhuvan. He gives Bhuvan a string  S  and each time, Bhuvan has to guess whether there exists  2  equal  subsequences  in the string or not. Bhuvan got a perfect score in the game with Chef Tobby. However, Chef Tobby has now asked Bhuvan to write a program that will do this automatically given a string  S . Bhuvan is an intelligent man but he does not know how to write a code. Can you help him? Find two different subsequences such that they are equal in their value, more formally, find two sequences of indices (a 1 , a 2 , ..., a k-1 , a k ) and (b 1 , b 2 , ..., b k-1 , b k ) such that: 1≤ a i , b i  ≤ |S| a i  < a i+1  for all valid i b i  < b i+1  for all valid i S a i  = S b i  for all valid i there exist

Secure Database Connectivity in node.js with mysql

Image
Hi Everyone! Yesterday my friend Andrea from Italy asked me a question about secure Database connectivity in node.js with mysql i.e. he wants to a secure database connection in node.js for some secure keys like username,password,database name that we use during database connectivity.His problem is obviously right from security point of view as we know that JavaScript is client side scripting knowledge so it is compiled on client side so after inspecting page some one can be able to view these secure keys which I discussed previously. I surf internet and found there are various ways to solve this problem I am not discussing all of them here but also I discussing here two of them and after this discussion I think Andrea and other reader who are facing with same problem can be able to resolve their problem. I choose two ways to solve this problem. Connection code in app.js file Create a Json file Connection code in app.js file : Javascript is client side language and code i

node.js web server module

Image
What is web server ? Web servers can refer to hardware or software or both of them working together. Web servers are computers that are usually setup in facilities called Data Centers and operated by hosting companies.The files stored on web servers are read by browsers.Browsers communicates with web servers to bring you information from internet. Purpose of Web server Store website so that people can visit them on internet. It serves file as per request. It can send same or different file to one or more than one user at the same time. Today I am discussing a small node.js application probably you are familiar with this example but it is mandatory to create a base.During this example I will discuss about starting a web server using node js.In node js one thing is very interesting that you need not install any other setup like Apache Tomcat or any other for node js application.You can run your application with node js setup that you have already install during your first

Sieve of Eratosthenes

Image
Steve of Eratosthenes is an ancient and very important algorithm for finding all primes number up to a given limit. this algorithm  is named after great Greek mathematician “ Eratosthenes”. Principle of Steve of Eratosthenes algorithm is removing all prime numbers i.e. composite numbers from array and now remaining numbers are Prime numbers. For more about algorithm go to Wikipedia . Now without wasting your time I like discuss steps for Steve of Eratosthenes and a simple code in Java to find all prime numbers up to a limit. Algorithm : Step 1: Make an array from 2 to n [2 , 3 , 4 , 5 , 6 , 7 ,8 , 9 ,........ n] Step 2: Beginnings from 2 delete all of its multipliers in the array except itself. for 2 [2 , 3 ,  4 , 5 , 6 , 7 , 8 , 9 ,......n] Step 3: Repeat the step 2 till square root of n. for 3 [2 ,3 , 5 , 7 , 9 , ............ n] . . . . Repeat till sqrt(n) Source Code import java.util.*; public class SteveOfEratosthenes { pu

Abstraction in Java

Image
During learning of Java programming a term comes Abstract and that term attached with several other terms like class, methods and introduced with a new concept called Abstraction. Abstraction is a process to hide certain details from user and only show essential feature of objects. Abstract class Abstract class is such type of class that contains abstract methods although Abstract classes may contain abstract and concrete both methods but a class which contains abstract method must be declared as Abstract class. Abstract method Abstract terms introduced during Inheritance for hiding unwanted information from user and in case of Inheritance parent and child class terms are introduced during which child class inherit property of parent class and process will be continued but in this case Abstract methods are declared in Abstract class but that does not contains its definition, child class that inherit Abstract class must be contained definition of Abstract method.

Microsoft Excel shortcut keys

Image
Today I am delivering some important excel keyboard shortcuts.By using these shortcut keys we can make our work more easy. Shortcut Key Description ctrl+A Select complete Sheet ctrl+C copy selected content ctrl+X cut selected content ctrl+V paste selected content ctrl+A Select complete Sheet Ctrl+Alt+V activate the Paste Special dialog box ctrl+Z Undo Last Action ctrl+Y Redo Last Action ctrl+P Open a Dialogue box to give print order ctrl+S save workbook ctrl+U Underline selected content Ctrl+1 activate the Format Cells dialog box Ctrl+;(semicolon) enter the current date into the current cell like, 4/10/2017 ctrl+shift+;(semi-colon) apply current Time,like 11:28 PM Ctrl+Shift+&

Mobile Validation Using Java Regular Expression

Image
We discussed here to validate Indian mobile number using concept of regular expression and Indian mobile numbering convention follows a particular protocol 1.India mobile number contains 10 digits 2.First digit of any number is either 7,8,9 and rest 9 lies between 0-9 3.if we include country code then number will be either 11 or 12 digits  a) In case of 11 digits First digit will be 0  b) In case of 12 digits First two digits will be 91 So at first we design regular expression which follows above rules At first we write a rule which follow first number will be either 7,8 or 9 and for this we will write [7,8,9] or in short we can write like this [7-9] after that we have to write rest 9 digits between 0-9 and for this in case of regular expression we can write like this [0-9][0-9].........[0-9] either [0-9] 9 times or in short [0-9]{9} And when we want to write std code then in case of 11 digit i.e to write 0 and in case of 12 digits we write std code as 91 and to full

Java Regular Expression

Image
Java Regex or Regular Expression is an API to define Pattern for searching or manipulating Strings, In simple word we can say that Regular expression is a representation of a group of String object according to a particular Pattern. Java provides the java.util.regex package for pattern matching with regular expressions. java.util.regex package consists of following three classes : Pattern Class In Pattern class Pattern object is a compiled version of a regular expression. It contains a compile() method which is used to create a Pattern. Pattern class provides no Public constructors.              Public static Pattern compile(String) Matcher Class Matcher object match the given pattern in the  target String Matcher object is created by matcher() method of Pattern Class     Public Matcher matcher (String target) Important Methods of Matcher class S. No. Method Description 1 boolean find() Returns boolean value after mat

Excel VBA Tricks

Image
If you are working in Excel and want to make your work easy then today I am providing some VBA tricks and from these few lines of can definitely divide your task in to small chunks. So now without wasting your and my time I am coming to the point. Here I am discussing Some tricks    Find Number of tabs between two tabs using Excel VBA   Find Empty Sheet using Excel VBA             Find header of sheet using Excel VBA Find Number of tabs between two tabs using Excel VBA  I am providing  a simple trick by which you can perform this task easily for this purpose I am using excel index function , As we know that index function provides number of that tabs like  This is my working sheet as given below and I want to know index value of given sheet then I will write down few lines of code and it will provide me index value of that sheet as shown below Sheet shows I am working inside tab1 and if I want to know index value of that tab then I will perform this operati