Wednesday 26 July 2017

When is it a good idea to not use NodeJs? Why?





When is it a good idea to not use NodeJs? Why? 
 
Because:
 
 
 
* If we want to create an application which is not much need OS  
server/user,Then we shouldn't use Nodejs. 
We would be just fine with other technology in very less time.




 
 * If we want to make an application which is required CPU Operations 
 frequently,Then we shouldn't use nodejs, Beacuse Nodejs bynature 
single threaded. When we launch a node process, you are running  
a single process with a single thread on a single core. So your 
 code will not be executed in parallel.
 So long running CPU tasks will block the whole server and are 
 usually a bad idea.
 
 



* If we are going to create a Simple blogs and static sites or Just 
 as a static file server then we shouldn't use Nodejs.


 
* No ability to scale out to take advantage of the multiple cores.






* Every time using a callback end up with tons of nested callbacks
 So using so many callbacks is not a good idea.









Tuesday 25 July 2017

Convert Speech to Text- Nodejs



Hi There ,
I am going to tell you how to convert Audio/Speech/Mp3 and other audio file into Text format.

I will use Nodejs, Bluemix (IBM Cloud Plateform).So let's start.

You should follow below steps to the same:

Step 1: Register on Bluemix (IBM Cloud Plateform).
Step 2: Login on Bluemix.
Step 3: Crete a service for speech-to-text. And get the username and password for speech-to-text.  Link : Create service for speech to text

Step 4:  Start coding.
Step 5:  create a .js file and require speech-to-text and fs just like below code.

 
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
var fs = require('fs');



Step 6: Create an object of SpeechToText just like below code.



var speech_to_text = new SpeechToTextV1({
username: '1234567-8765-4267-9e76-fgff34f',
password: 'ABCdefghiJK'
});

Step 7: Create an array and insert the path of the audio. You can have many audio file in this array.

 
var files = ['./music/hello.flac','./music/somebody2010.flac'];



 Step 8: Create params for every audio, So we will do it in for loop and call speech_to_text.recognize() to convert.Get the response and console it.


for (var file in files) {
var params = {
audio: fs.createReadStream(files[file]),
content_type: 'audio/flac',
timestamps: true,
word_alternatives_threshold: 0.9,
keywords: ['colorado', 'tornado', 'tornadoes'],
keywords_threshold: 0.5
};

speech_to_text.recognize(params, function (error, transcript) {
if (error)
console.log('Error:', error);
else{
console.log(JSON.stringify(transcript, null, 2));
console.log(transcript.results[0].alternatives[0].transcript);
}
});
}

 Congratulation ! You did it.




The complete code is here :



 
 
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
var fs = require('fs');

var speech_to_text = new SpeechToTextV1({
username: '1234567-8765-4267-9e76-fgff34f',
password: 'ABCdefghiJK'
});

var files = ['./music/hello.flac','./music/somebody2010.flac'];

for (var file in files) {
var params = {
audio: fs.createReadStream(files[file]),
content_type: 'audio/flac',
timestamps: true,
word_alternatives_threshold: 0.9,
keywords: ['colorado', 'tornado', 'tornadoes'],
keywords_threshold: 0.5
};

speech_to_text.recognize(params, function (error, transcript) {
if (error)
console.log('Error:', error);
else
console.log(transcript.results[0].alternatives[0].transcript);
});
}
 
 




HOW TO RUN ABOVE PROGRAM:

/***********************************************************************************
 INSTRUCTIONS:

Step 0: Check the environment setup. (Should installed nodejs,Remove all errors if any).
Step 1: Navigate terminal/command prompt to this directory.
Step 2: Run command:  node FILE_NAME.js;
Step 3: See the message  in console log;
Step 4: if executed Step 3 successfully then you have text message according to audio. Otherwise go to Step 0.

**************************************************************************************/





Wednesday 11 January 2017

Use of MYSQL Workbench



Hi friends,
Hope you all are enjoying your work.

Today i am going to show you how to use of mysql workbnch .


before doing this i am sure that you have already installed following things on your machine:

1. MYSQL.
2. MYSQL Workbench.



So now lets do this step by step.

Step 0.  Open your work bench by double clicking on your installed workbench icon.Its look like this :



Now you will have to click on + button nearby on your MYSQL Connections (+).
Then you will have to fill necessary things.


Step 1.  Now click on following place which is in red circle in below image to connect your local MYSQL database.







Step 2. After clicking on Local Instance 3306 you can see this like in below image:



Now you should enter your MYSQL password to connect your local database.


Step 3.  After entering password of MYSQL database , you will see this window :

In the above window , i had opened some sql file before, don't worry about that if the same is not opened on your machine.



Step 4. Now you will have to choose .sql file which you want to import in your database. So select the .sql file after clicking on below icon of this window.



Step 5.  After clicking on this icon you will have to choose file location where you are having your .sql file.

choose .sql file which you want to import on your database. ( Please double click on .sql file accordingly ). see in image :






Step 6. After selecting you desire .sql file you will see that , the window is opened with a tab having respective file name like that :




In the red area ( in  tab window ) you can see that there is many sql command written in that particular .sql file. Which is going to execute in next step.
Make sure that don't alter these sql commands.


Step 7. Now will have to execute these all sql commands which is in red area in above image.

To do this you will to click on this red area ( icon on the red area ) in below image . Click that particular icon in your workbench window:




Step 8. After clicking above icon your sql file will be executing. But it will take very little time to execute your all sql commands.


Ok fine, Your sql file has been executed. Now you can check the results and errors from following :
look just below on your main screen.



In the red area on above image all the sql log is recorded, you can open it by dragging up of action output area. The black arrow shows that it can be dragged up and down to show all errors or results.


Now you can execute all your .sql file one by one as described. You can execute many .sql file once, but doing one file one time is more better and safe.
So i suggest to do one by one.




Step 9. Check your database tables and Stored Procedures in your database. ( Do this after executing your all sql file ).

click on this icon which is in red area on below image:





Step 10:  If you are not able to see all database once then you can increase you view area by dragging this icon which is in red area on below image.







Check your tables in your particular database has been imported or not.
Be sure that all your Stored procedures has been imported or not.
You all database and tables is showing in red area. Also your stored procedures showing on red area in below images.:






If all your tables and stored procedures are showing then it successfully imported otherwise there may some error occurred when you imported or may be some wrong sql queries in .sql file.



 Please feel free to like , share links and comments for any query and support.


All The Best Friends..
Have a good time.




Tuesday 13 December 2016

All about robots.txt of any web site.

Robots.txt is very good things for any web sites. The robots.txt is use for web routing purpose. in the robots.txt file , there are instructions are give for web routes for their wer robots. This is called The Robots Exclusion Protocol.
If you want to go www.abc.com/index.html , then it first checks for http://www.abc.com/robots.txt. if /index.html is allowed in robots.txt then you will be routed for that /index.html otherwise you can not go on index.html page. 

User-agent: *
Disallow: /search
Allow: /search/about
Disallow: /sdch
Disallow: /groups
Disallow: /index.html?
Disallow: /?
Allow: /?hl=
Disallow: /?hl=*&
Allow: /?hl=*&gws_rd=ssl$
Disallow: /?hl=*&*&gws_rd=ssl
Allow: /?gws_rd=ssl$
Allow: /?pt1=true$
Disallow: /imgres
Disallow: /u/
Disallow: /preferences
Disallow: /setprefs
Disallow: /default
Disallow: /m?
Disallow: /m/
Allow:    /m/finance
Disallow: /wml?
Disallow: /wml/?
Disallow: /wml/search?
Disallow: /xhtml?
Disallow: /xhtml/?
Disallow: /xhtml/search?
Disallow: /xml?
Disallow: /imode?
Disallow: /imode/?
Disallow: /imode/search?
Disallow: /jsky?
Disallow: /jsky/?
Disallow: /jsky/search?
Disallow: /pda?
Disallow: /pda/?
Disallow: /pda/search?
Disallow: /sprint_xhtml
Disallow: /sprint_wml
Disallow: /pqa
Disallow: /palm
Disallow: /gwt/
Disallow: /purchases
Disallow: /local?
Disallow: /local_url
Disallow: /shihui?
Disallow: /shihui/

.






Create a /robots.txt file on your web site

Where to put it

At the top-level directory of your web server.

 For example, for "http://www.abc.com/home/index.html, it will remove the "/home/index.html", and replace it with "/robots.txt", and will end up with "http://www.abc.com/robots.txt".

What to put in it

The "/robots.txt" file is a text file, with one or more records. Usually contains a single record as:
User-agent: *
Disallow: /search
Allow: /search/about
Disallow: /sdch
Disallow: /groups
Disallow: /index.html?
Disallow: /?
Allow: /?hl=
Disallow: /?hl=*&
Allow: /?hl=*&gws_rd=ssl$
Disallow: /?hl=*&*&gws_rd=ssl
Allow: /?gws_rd=ssl$
Allow: /?pt1=true$























Thursday 6 October 2016

Prime Minister of India: Hon. PM Narendra Modi.

Narendra Damodardas Modi is the 15th and current Prime Minister of India, in office since 26 May 2014.

Narendra Damodardas Modi is the 15th and current Prime Minister of India, in office since 26 May 2014.
Modi, a leader of the Bharatiya Janata Party, was the Chief Minister of Gujarat from 2001 to 2014 and is the Member of Parliament from Varanasi.

Born: September 17, 1950 (age 65), Vadnagar
Spouse: Jashodaben Modi (m. 1968)
Preceded by: Manmohan Singh
Education: Gujarat University (1983), University of Delhi (1978)
Parents: Heeraben Modi, Damodardas Mulchand Modi
Siblings: Vasantiben Hasmukhlal Modi, Prahlad Modi, Amrit Modi, Pankaj Modi, Soma Modi.


Narendra Modi's qualification:
While Modi holds a Masters in Political Science from Gujarat University, some of his ministers have only studied up to class 10.
Prime Minister Narendra Modi's 23 Cabinet ministers and their educational qualifications.

On 2nd October 2014, Mahatma Gandhi’s Birth Anniversary the PM launched ‘Swachh Bharat Mission’ a mass movement for cleanliness across the Nation.
The scale and impact of the movement are historic.
Narendra Modi’s foreign policy initiatives have realized the true potential and role of world’s largest democracy, India on the world stage.
He began his term in office in presence of all Heads of States of SAARC Nations.
His address to the General Assembly of United Nations was appreciated across the world.
Narendra Modi became the first Indian Prime Minister to embark on a bilateral visit to Nepal after a long period of 17 years, to Australia after 28 years,
to Fiji after 31 years and Seychelles after 34 years. Since taking over, Narendra Modi attended UN, BRICS, SAARC and G-20 Summits,
where India’s interventions and views on a variety of global economic and political issues were widely appreciated.
His visit to Japan marked a momentous chapter to unfold a new era of India-Japan relations. He became the first PM of India to visit Mongolia and his
visits to China and South Korea have been successful in drawing investments to India.


His continued engaging with Europe was seen during his visit to France and Germany.
Shri Narendra Modi has attached great importance to strong ties with the Arab world.
His visit to UAE in August 2015, the first by an Indian PM in 34 years, covered tremendous ground in enhancing India’s economic
partnership with the Gulf. In July 2015 Shri Modi visited the five central Asian Nations in a visit that was seen as path-breaking.
Vital agreements were signed between India and these nations in spheres like energy, trade, culture and economics.
In October 2015 a historic India-Africa Summit was held in New Delhi, in which 54 African nations participated.