Showing posts with label Linux Tricks. Show all posts
Showing posts with label Linux Tricks. Show all posts

Topics

1) Code your Server.js - Node.js main file
        i) Importing libraries
        ii) Create Server and Handle Request
        iii) Play with Socket.io to do MultiChatting
2) Develop Webpage with Socket Javascript
3) Download Project here


1) Code your Server.js - Node.js main file

i) Importing libraries


 var http = require("http");
 var url = require('url');
 var fs = require('fs');
 var io = require('socket.io');

ii) Create Server and Handle Request

var server = http.createServer(function(request, response){
 
 var path = url.parse(request.url).pathname;
 console.log('Path='+path);
 switch(path){
  case '/':   
   fs.readFile(__dirname + "/index.html", function (error, data) {
    if (error) {
     response.writeHead(404);
     response.write("opps this doesn't exist - 404");
     response.end();  
    }  
    else{ 
     response.writeHeader(200, {"Content-Type": "text/html"});  
     response.write(data, "utf8");
     response.end();  
    }
   });
   break;
   
  case '/socket.html':
   fs.readFile(__dirname + path, function (error, data) {
    if (error) {
     response.writeHead(404);
     response.write("opps this doesn't exist - 404");
     response.end();  
    }  
    else{ 
     response.writeHeader(200, {"Content-Type": "text/html"});  
     response.write(data, "utf8");
     response.end();  
    }
   });
   break;
   
  default:
   console.log(path +"- Not found");
   response.writeHead(404);
   response.write("opps this doesn't exist - 404");
   response.end();
   break;
 }
 
});
server.listen(8001);

iii) Play with Socket.io to do MultiChatting


var serv_io = io.listen(server);
var textarea="";
var name="";
serv_io.sockets.on('connection', function(socket){
 //send data to client
 setInterval(function(){  
        socket.emit('date', {'date': getCurrentTime()}
 );
  
    }, 1000);
 
 socket.on('client_data', function(data){
  textarea=data.textarea;
  name=data.name;
  console.log("name="+name);
  //socket.emit('textarea', {'textarea': data.textarea});
  emitData(socket);
 });
 
    
});

function emitData(socket){ 
 socket.broadcast.emit('message', 
  {'date': getCurrentTime(),
   'name' : name,
   'textarea':textarea
  }
 );
}

function getCurrentTime(){
 var d = new Date();
 var curr_date = d.getDate();
 var curr_month = d.getMonth()+1;
 var curr_year = d.getFullYear();
 var curr_hour = d.getHours()%12 +"";
 var curr_min = d.getMinutes() + "";
 var curr_sec = d.getSeconds() + "";
 if(curr_hour.length == 1)
  curr_hour="0"+curr_hour;
 if(curr_min.length == 1)
  curr_min="0"+curr_min;
 if(curr_sec.length == 1)
  curr_sec="0"+curr_sec;
 
 //var dateString = sprintf("%2s-%2s-%s %2s:%2s:%2s ",curr_date,curr_month,curr_year,curr_hour,curr_min,curr_sec);
 var dateString = curr_date + "-" + curr_month + "-" + curr_year + "  " + curr_hour +":"+ curr_min +":"+ curr_sec;
 
 return dateString;
}

2) Develop Webpage with Socket Javascript

<html>
  <head>
    <script src="/socket.io/socket.io.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script> 
 <style>
 .common{
  width: 200px;
  height: 30px;
  padding-left: 10px;
  
 }
 #date{
  color: green;
 }
 </style>
  </head>
  <body>
    <script>
  var socket = io.connect();
  socket.on('date', function(data){
   $('#date').text(data.date);
  });
  
  socket.on('message', function(data){   
   message=data.textarea;
   len=message.length;
   if(len > 0){
    printMessage(data.name,message);     
   }
  });
  
  
  $(document).ready(function(){
   $('#textarea').keypress(function(e){
   if ( event.which == 13 ) {
    message=$('#textarea').val();
    len=message.length;
    strname = $('#name').val();
    if(len > 0){
     socket.emit('client_data', {'name':strname,'textarea': message}); 
     printMessage(strname,message);     
    }
    $('#textarea').val("");
   }    
  });
  }); 
  
 function printMessage(strname,message){
  $('#messagearea').html($('#messagearea').html()+"<br/><span style='color:blue;font:18px;'>"+strname+"</span> : "+message);
 }
    </script>
    <div><h1>Welcome to Node.js Socket.io - Simple Multi Chat Application</h1></div>
 <b> Get tutorial here (Post your comments and query)</b> - <a href='http://www.coolcomputerpctricks.com'>www.coolcomputerpctricks.com</a><br><br>
 <b> Get Latest Code here </b> - <a href='https://github.com/karthikeyan98'>https://github.com/karthikeyan98</a>
 <br><br>Current Time: <span id="date"></span><br/>
 <input type="text" id="name" value="Guest" class="common"> - Type Name here<br/><br/>
 <textarea id="textarea" class="common"></textarea> - Type Message here and press Enter.
 <div id="messagearea"></div>
  </body>
</html>

3)  Download Project here

GitHub - https://github.com/karthikeyan98/SimpleMultiChat

Post your comments and query for any help.

Are we trusting Google too much?

Are we trusting Google too much?

1. why should chrome warn us with a message when we clear browsing history?


Whenever we try to clear browsing history, chromes tells that there is incognito mode to use, is Google worried if you clear your entire browsing history from chrome?

What does Google do with your browsing history?
Here's a clear evidence, "YouTube", Google's YouTube shows video contents relevant to our browsing history stored in chrome. that's how your information is used to make you use their product(YouTube) more than what you do normally.
you can find the difference when you go to "YouTube" home page in both conditions
1. first without browsing history - everything cleared in chrome- visit YouTube home page
2. after doing couple of Google searches, let chrome shows some history and visit YouTube, you will feel the difference

2. why should chrome has separate log in session separating it from other google products.

when you logged in chrome, also when you logged in some of other google product like gmail, when you signout of gmail,chrome logged in session wont go.

chrome separate login session stores all your data ( you can control it by visiting settings, how many of us do that, what about people who doesn't have enough computer experience to change the settings ) user specific data stored in each of our google account right from browsing history to form input data's.

3. How does google map works - showing traffic information in the road we travel.



It does collect our location information including in which speed we are traveling, it collects every one who uses android mobile or signed in to google map atleast once and using some algorithm it gives back.


4. What will happen with Google Glass?

                    XX_____XX 

5. Not just above four items, there are lot more things.. like

     At first time when you open Google Chrome, it asks you to sign in with Google account. How many of you signed in without knowing that it is a log in for Google chrome to save your personal browsing data  in your account?
      Many would have no idea initially that it is a log-in specially for Google Chrome. and would have signed in directly thinking it is normal google product sign-in.

 Obviously, we are very much benefited and addicted to all those products, and there are ways we can control sharing our data to a certain level, but how many of us are really concerned about it, going to settings, searching where it is and switching it off?

Google's New Scientific Calculator

Google Launches its New Scientific Calculator.


If you type "Calculator" or "99/9" in google search, you will get the googles All New Scientific calculator.
Or if you do any mathematic calculations right away it will bring its Advanced Mathematical calculator
Try typing these things in google search for getting Google Scientific Calculator

Search it in Google - Calculator , 99/9 , Sin(90) , Sin 90,  log10 , like any mathematical calculations.
Its is as fast as google search results.


Google Restricts Labels in blogger (robot.txt)


Google Search restricts Labels (Categories) for all the blogs in Blogger (BlogSpot)

If you see something like this in your webmaster tools, be cool don’t worry for this.

This is because

Reason: Each Label entries are not sub pages, they are just a well framed search query
For example:
When you click the Label – Windows Trick in coolcomputricks.co.cc, the url pointing to that label is this

http://www.coolcomputricks.co.cc/search/label/Windows%20Trick

If you see this url carefully, you can see “/search/” in it, this means it is not actually a new page to be crawled by the Google search bot, it just a search query url, where all the pages yielded by this search query url is already indexed, so it just says it restricts the labels (search query url), but all the pages in your site is already indexed and included in search engine

The main idea behind having labels in the blogs or website, is to make the users comfortable in selecting categories they wished.

What should you do to make safe browsing, when using your friends laptop or using it in any Internet center.?

What should you do to temporarily erase the trace of what you searched for?

Keep the history unchanged, but temporarily disallow saving of histories, cookies, url names and everything.

Here is what you need to do.

Almost All the browsers has a concept called Private Browsing, Private Browsing helps not to save any information like histories, form entries, username, password, cookies, and everything you browsed for, so all the browsing entries can be unsaved for that particular time of browsing
For Chrome Users
1.       Click Settings ( Tool Icon on the top right corner of chrome)
2.       From the drop down, select “New Incognito Window

3.       You will now see a new window with a Detective Agent Logo on Top Left Corner, where you can make private browsing, credit card transactions, experiments, research, and anything that will not saved forever
4.       And when you close it, it goes normal, If you want to do Private browsing again, need to start from first

For Mozilla Firefox Users
1.       Click Firefox Button on the Left top corner
2.       Click “Start Private Browsing
3.       You will receive a alert box, click “Start Private Browsing” once again

4.       There you go, you will now see a new window that has changed color in the Firefox Button on the Left top corner enjoy private browsing, where you can make private browsing, credit card transactions, experiments, research, and anything that will not saved forever

For Internet Explorer Users
1.       Click Safety Menu on the Top right side of the Internet explorer
2.       Select “InPrivate Browsing

3.       There you go, you will now see a new window that has InPrivate icon on the address bar, enjoy private browsing, where you can make private browsing, credit card transactions, experiments, research, and anything that will not saved forever

Google Chrome gets a new Icon

Google Chrome icon changed


New Chrome ICON
Old Chrome ICON


The new Google Chrome Icon is very simple and looks like it's a 2 dimension of the old chrome icon.

The new Icon has been changed automatically for all the users of chrome browser. it seems like update is going on for the application without the users knowledge.

Simple things are always powerful - secret of Google.

Interesting !!! Google Vs Bing , Unbelievable Trick try it yourself.

Interesting !!! Google Vs Bing , Unbelievable Trick try it yourself.
Have you ever tried Automattic currency Conversion in Google or Bing search, There lies this interesting fact.Just have a look at it.. perhaps wait! how about Exploring this interesting crazy fact on your own with the help of following steps.

Step 1: Open your favourite Web browser twice (two windows or two tabs) open www.google.com in one and www.bing.com In another.


Step 2: Type the following in both the search bar and hit Enter.

1 euros in usd

Step 3: Well I searched at this time December 5 2010 8.24 pm look what I get. Having two different answers for same question

Google said 1 Euro = 1.3382 US $

Bing said 1 Euro = 1.34246 US $


Step 4: Which one is correct??????????!!!!!!!?????????

Step 5: Well According to Yahoo (OMG!!! another search engine) Currency convertion at this page http://finance.yahoo.com/currency-converter/#from=USD;to=EUR;amt=1.3399 says both are wrong.

Step 6: Well Let’s try some other site to verify it http://www.xe.com/ucc/convert.cgi?Amount=1&From=EUR&To=USD&image.x=63&image.y=21&image=Submit which says Google Data is better than bing and yahoo but not Accurate though !!!!!!.
Enable and Disable Thumbnail view (Most visited / Recently Closed) on the New tab of Google Chrome Browser

Disable
By Default you have the thumbnail view enabled, closing or disabling this view is very simple

Step 1: just click X – close button on the right side of the Most Visited or Recently closed frame.

Step 2: After clicking it, the thumbnail view will disappear.

Step 3: Though the thumbnail view disappeared, u can access the most visited and Recently closed items through links on the left down of the page in a simple view.

Enable

And to get back thumbnail view of Most visited or Recently Closed items
Step 1: click the “Most Visited” link (text) in the left down corner

Step 2: You will have your recently visited links poped up, now click the “Most Visited” link in the poped up window.



Step 3: now the Most Visited view will be appearing in the top of the page, click the arrow on the left side of it.



Step 4: That’s it You have your thumbnail view of Most Visited items back.

Step 5: Do the same for Recently Closed items .

Store your Gmail mails in Computer without using any Email Client

Gmail Offline

Gmail Offline is a Feature where you can Store your Mails, Chats, Attachments, labels in your personal Computer without having to use any Email clients like outlook.

Gmail Offline Let you to Synchronize all your Gmail contents to your PC when your connected to internet and makes u to work with your mails while not connected.


Enabling Gmail Offline Feature

1. Log into your Gmail
2. go to Settings->Offline
3. click "Enable offline mail for this Computer" and click "Save changes" button
4. Follow the instructions and Accept to install Google Gears which is less than 1 MB.
5. After this Few minutes Process, u'r Google mail gets synchronized to your PC
6. and you can access all your gmail contets offline by clicking the "Gmail Offline" icon on your Desktop


Advantage of Gmail Offline

1. Very Simple Feature and easy to use
2. No Additional Software to be Installed like outlook express etc..
3. And More Importantly its the Google's Product you can be sure of security of your personal file's

Disadvantage of Gmail Offline
1. You cannot specify selected mails to get saved in your Pc, instead all your mails within specified years are get stored.

Remove Linux From Your Pc Safely


Remove Linux From Your Pc Safely

First of all you need to know where your Linux OS is installed to. that is what drive it is currently living on. Bear in mind that Linux formats the drive as HFS rather than Fat/Fat32 or NTFS. ( These are the file systems used by various Operating Systems).

So HFS Partitions are not seen by windows, so its hidden.

To remove the partitions of Linux in WindowsXP

1. go to your 'Control panel' > Admistrative Tools > Computer Managment

2. Open 'Disk Management' and you will see your Linux drives recognised as 'Unknown Partition' plus the status of the drive. Bearing in mind you know what partition and disk you installed to it will be easier to recognise as the drive/partition where you had installed it to.

3. Once you have identifed the drives, 'right-Click' on the drive/partiton and select 'Delete Logical Drive'

4. Once you have followed this through, you will now have free space.

5. This next part is very important. Once you have formatted the drive, re format it a
s your required file system type. either Fat32 or NTFS. Now the important part is coming up !

5. Fixing your Master Boot Record to make Windows Bootable again.

6. Have a Windows Boot disk with all the basic DOS Commands loaded on to the disk. A standard Windows Boot Disk will work too.

7. Type in the DOS command :
e.g, from your C:\

fdisk /mbr

Or use your Windows XP run the recovery console, pick which xp install you would like to boot in to (usually you will pick #1)

then type: fixmbr. Answer Y to the dialoge.

Your master boot record will now be restored and Windows XP will be bootable once again. Your System will be restored with your original boot loader that you got with Windows XP.