Project Naptha – Images text simplified

Project Naptha – Images text simplified

Screenshot 2014-08-06 23.37.22

Have you ever experienced need to copy some text but found that it’s actually an image and you cant copy text from it? If yes, world isn’t same anymore. Introducing Project Naptha, According to its author,

Project Naptha automatically applies state-of-the-art computer vision algorithms on every image you see while browsing the web. The result is a seamless and intuitive experience, where you can highlight as well as copy and paste and even edit and translate the text formerly trapped within an image.

Simply put, Project Naptha is a college project build by Kevin Kwok which offers a chrome extension to allow users highlight, copy-paste, edit and translate on the go.

How it works:

It runs a text detection algorithm, Stroke Width transform along with Optical Character recognition. This project also uses algorithms like connected components analysis (identifying distinct letters), Otsu thresholding (determining word spacing), disjoint set forests (identifying lines of text). 

Over and above applying these algorithms, this project also watches cursor movements all the time to get the words you might be looking for.

Next time, when you go to web and find any image, be it informative or just an internet meme, with naptha in your armour, you know you can copy its text on the go.

Tweet Race between Modi and Rahul – A programmer’s Eye using Node/Redis

Tweet Race between Modi and Rahul – A programmer’s Eye using Node/Redis

download-300x163

In this article I will discuss about making a sample app which pulls out live stream of tweets around specific keywords, stores them in database or publish them on web page. Here we will be targeting Keywords like Rahul Gandhi and Narendra Modi and saving number of occurrences of each as Key-Value pair.

Technologies used: Node.js with Express framework, Redis as key value storage, Twitter API for collecting tweets.

Tutorial level: Beginner.

Setup

First thing first, Install Node.js and Express framework into your working directory using instructions given at their website. Next, we need to install Redis to store key value pairs. For Ubuntu users, run following set of instructions to install it.

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make

Assuming you have express installed in your current directory, it should have automatically created a package.json file, and directories like routes and views. Edit your package.json file in any text editor and update dependencies as below.

"dependencies": {
"express": "3.4.8",
"ntwitter": "0.5.x",
"jade": "*"
}

Now use Node Packet Manager to install the newly introduced ntwitter module. Run below command in terminal and let NPM do its job.

npm install

Redis configuration and setup

Now, As the setup part is complete, lets start the coding part.

If you are new to express framework, It provides basic MVC architecture to build your app with defined routes and views. We will be using these routes to develop our app. Firstly, we will add a new route (tweetapp) and as the application size is small, we will be writing our logic in route itself.

Add following code to routes/tweetapp.js (new file)

var twitter = require('ntwitter');
var redis = require('redis');

This will add redis and twitter module to our route. Next thing is to initialize the Redis client which can be done using

var client = redis.createClient();

Now all Redis related operations are available using this client. Simple Redis operations which we will be using here are (for exhaustive list of operations, please refer Redis Documentation)

  1. SET – To set a key value pair.
  2. GET – To retrieve a key value pair from Redis.
  3. MGET – To retrieve multiple values corresponding to keys passed as array
  4. INCR – Increment the value of given key by 1. (Note: This is only applicable to integer values)

Now coming back to our
tweeter app, To create a key, we first need to check if it already exists or not. This can be done via

client.exists();

It takes two arguments, Key to be searched and a callback function which will be called after look-up in redis is done. So our code will look like this.

client.exists('rahul', function(error, exists) {
  if(error) {
    console.log('ERROR: '+error);
  } 
  else if(!exists) {
    client.set('rahul', 0);
  };
});

It is checking for existence of a key named rahul in Redis and creating it in case it is not present with initial value as 0. Create a similar key for Modi.

Twitter API

Now as our Redis Key-Value pair is ready to accept entries, we will be moving to Twitter. Twitter Development API is open and powerful tool. We will be using it to collect all tweets on run time via streams. To connect with Twitter API, we need authentication tokens which can be taken from Twitter Dev plateform. Login to your twitter account and register for an app. Once you are done with filling required information, It will provide you four important parameters which will be required to pass authentication.

  1. Consumer key
  2. Consumer secret
  3. Access token
  4. Access token secret

Coming back to our app, we need to pass authentication tokens to twitter, which can be done as initializing our token variable,

var token = new twitter({
   consumer_key: 'QroiweVrj5CvfqSglv07Rg',
   consumer_secret: 'LdUxYEq8R01YhuzqKW6Kq1Evr2zdCtZt7CT8qbF6QI',
   access_token_key: '28957080-lzbIl9Wo9P0p3UGP66wTkKmJNJL30tm1QIhLCVbdn',
   access_token_secret: '9HakcRvSp4EC5G3ECCIDUTw9MbJlYW2Qd6omzGkgiASRO'
});

Now to start reading the stream we need to call stream function as below,

token.stream(
  'statuses/filter',
  { track: ['rahul', 'modi'] },
  function(stream) {
    stream.on('data', function(tweet) {
      console.log(tweet.text);
      if(typeof tweet.text!='undefined' && tweet.text.match('modi')) {
          client.incr('modi');
          //console.log('modi++');
      }
      if(typeof tweet.text!='undefined' && tweet.text.match('rahul')) {
          client.incr('rahul');
      }
    });
  }
);

This code simply reads a stream from twitter and tracks for keywords like rahul and modi, As a callback function, in case of text match this callback will be called with tweet as its parameter. This tweet parameter contains all information related to tweet among which we are interested in only its text. In case of a match with either keyword which we are interested in, we will increment its key value using Redis’s incr. As an additional log, above code is also logging all tweets parsed, in terminal.

redis.mget(["rahul", "modi"], function (error, count) {
  if (error !== null) {
    // handle error here
    console.log("ERROR: " + error);
  } else {
    var jsonObject = {
      "modi":count[1],
      "rahul": count[0]
    };
  // use res.json to return JSON objects instead of strings
  res.json(jsonObject); 
  }
});

This will return a Json response with both counters in response and we are done with our app.

Frontend JQuery & AJAX

In case you want to go ahead and show this on browser window, you can make AJAX calls in loop from browser via JQuery and show these values out there. Following code will do this basic version

var timeoutid;
clearTimeout(timeoutid);
timeoutid = setTimeout(function(){
    $.ajax({
        url: '/counttweets',
        success: function(response) {
                $("body").html("<p>Modi:"+response.modi+"</p>");
                $("body").append("<p>Rahul:"+response.rahul+ "</p>");
                main();
        }
    },5000);
});

 

Let me know in case you have any idea to improve this.

Happy Coding!!

 

 

Heartbleed – Everything you need to know

Heartbleed – Everything you need to know

heartbleed (1)Heartbleed, recently called as Internet’s biggest security leak, is a serious vulnerability in the popular OpenSSL. OpenSSL is the ‘s’ of ‘https’ that we use for logging in almost all authentic sites including Gmail and facebook. If you are not sure, open Gmail and note the address bar, it will change to https. Till now, it was considered to be certificate of security and this is where heartbleed resides.

Wait, I still don’t get anything. Is it a hack or something?

Heartbleed is not a hack, it is eventually a silly mistake done in OpenSSL where programmer missed marking correct checks over buffer overflow. In simple words, Whole heartbleed resides in single line of code,

memcpy(destination, origin, size);

Yes, Its just this line. For non programmers, memcopy is a library function which copies data equal to size to destination from origin. the whole problem arises when this payload size is not what it should be, i.e. size of original data. So given this knowledge, an attacker can send a request where request size is 50 bits and data is just 1 bit. Server will start copying for 50 bits and then return them as acknowledgement. Attacker has now access to remaining 49 bits which might be someone’s password!

In more simpler words, it can be understood in this hypothetical conversation between user and server.

Normal Scenario:

User: Hey server, I am sending 50 bits, please process them.

--User sends 50 bits--

Server: Sure man, Its done.

-- server acknowledge it with returning 50 bits that were copied.--

Attacker's scenario:

Attacker: Hey server, Please process my 50 bits too. 


--Attacker sends just 1 bit--

Dumb Server: Sure man, Here it is what i copied.

-- server acknowledge it with returning 50 bits --

In second scenario, Server responded with data which doesn’t belong to Attacker. This way, Attacker might get access to sensitive informations like passwords from affected server or helps someone fake you using these certificates.

This looks silly. Which sites were doing this?

If this sounds silly to you, Checkout the big names and what they have to say below.

Here is what Mashable reported

Was it affected? Is there a patch? Do you need to change your password? What did they say?
Facebook Unclear Yes Yes “We added protections for Facebook’s implementation of OpenSSL before this issue was publicly disclosed. We haven’t detected any signs of suspicious account activity, but we encourage people to … set up a unique password.”
Instagram Yes Yes Yes “Our security teams worked quickly on a fix and we have no evidence of any accounts being harmed. But because this event impacted many services across the web, we recommend you update your password on Instagram and other sites, particularly if you use the same password on multiple sites.”
LinkedIn No No No “We didn’t use the offending implementation of OpenSSL in www.linkedin.com or www.slideshare.net. As a result, HeartBleed does not present a risk to these web properties.”
Pinterest Yes Yes Yes “We fixed the issue on Pinterest.com, and didn’t find any evidence of mischief. To be extra careful, we e-mailed Pinners who may have been impacted, and encouraged them to change their passwords.”
Tumblr Yes Yes Yes “We have no evidence of any breach and, like most networks, our team took immediate action to fix the issue.”
Twitter Unclear Yes Unclear Twitter wrote that OpenSSL “is widely used across the internet and at Twitter. We were able to determine that [our] servers were not affected by this vulnerability. We are continuing to monitor the situation.” While reiterating that they were unaffected, Twitter toldMashable that they did apply a patch.
Google Yes Yes Yes* “We have assessed the SSL vulnerability and applied patches to key Google services.” Search, Gmail, YouTube, Wallet, Play, Apps and App Engine were affected; Google Chrome and Chrome OS were not.*Google said users do not need to change their passwords, but because of the previous vulnerability, better safe than sorry.
Yahoo Mail Yes Yes Yes “As soon as we became aware of the issue, we began working to fix it… and we are working to implement the fix across the rest of our sites right now.”
Amazon Web Services(for website operators) Yes Yes YesYes Most services were unaffected or Amazon was already able to apply mitigations (see Aadvisory note here). Elastic Load Balancing, Amazon EC2, Amazon Linux AMI, Red Hat Enterprise Linux, Ubuntu, AWS OpsWorks, AWS Elastic Beanstalk and Amazon CloudFront were patched.

Source: Mashable Website

To add more salt to the wound, There is nothing you can do till the affected website applies the patch. Even changing password will not make you safe as it can again be extracted via Heartbleed. Also if your certificates (generated after you entered your password via OpenSSL) are compromised, it can always be used to spoof you weather or not you changed your password.

For a security relief, None of the banking site seems to be affected through this.

What should I do then?

A website Flippo claims to detect vulnerability of any site. It actually go to the site, send them a malformed heartbeat and extract ~80 bytes of memory as proof, just like an attacker would.

All you can do is keep a check for the site you are interested in and change your password as soon as it says site is unaffected.

Till next time,

Stay Safe, Stay Secure!

 

 

 

5 Most Expensive Tech Acquisitions

5 Most Expensive Tech Acquisitions

acquisition

Tech Acquisitions are smart business moves which are taken to either maintain one’s supremacy in the field or to curb possible competition right before it may occur. Thought in past decade there are some rather expensive acquisitions done be tech giants like Google and Facebook. Here we will be enlisting 6 most expensive acquisitions.

5. Microsoft buys Nokia

Cost of Acquisition: $7.2 Billion

microsoft-nokia

After lagging behind the likes of Android against its own Windows operating system, Microsoft paid $7.2 Billion to acquire Nokia phone division to give another life for Windows operating system. Going on the lines of Apple, Microsoft now owns complete solution including both hardware and software under the same roof.

4. Oracle Buys Sun Microsystems

Cost of Acquisition: $7.4 Billion

sun

Considering Mysql as a threat to its own DBMS solution and keeping Java away from clutches of IBM, its main competitor, Oracle paid $7.4 billion to acquire Sun Microsystems, taking the complete ownership of JAVA, Open solaris and MySQL.

Oracle Chief Executive Larry Ellison, however described this acquisition as bringing complete tech-stack under one roof.

“Java is the single most important software we’ve ever acquired, with the acquisition of Sun, Oracle is now able to make all of the pieces of the technology stack fit together and work well.” – Larry Ellison on Acquisition of SUN Microsystems.

3. Microsoft Buys Skype

Cost of Acquisition: $8.5 Billion

skype-microsoft

In mid 2011, Microsoft shocked the industry by announcing its acquisition of VoIP company Skype. Reportedly, Skype was earlier bought by EBay in 2005 for $3.1 Billion but sold later to a investment group at mere 1.8 Billion. Microsoft home grown tools like Windows messenger and Lync were considerably overlapping the functionalities of its acquisition Skype which just had 124 million monthly active users as compared to 330 million monthly users of Windows messenger

Incidentally Microsoft paid on average $1000 for each  skype user, who were on an average just $30 profit.

2. Google Buys Motorola Mobility

Cost of Acquisition: $12.5 Billion

google-motorola

In a deal finalised in early 2012, Google played a trump card by buying Motorola Mobility and along with it, 17000+ patents which boosted its already active market share of Android OS. A deal which was also considered to be a master stroke to market its Nexus series, Google sold its smartphone division to Lenovo later acquiring close to 6% of the buyer (Lenovo) to clear its intentions. Lenovo’s acquisition is by far China’s largest ever tech deal.

1. Facebook Buys WhatsApp

Cost of Acquisition: $19 Billion

fb-whatsapp

At whopping price of record $19 Billion, Facebook latest acquisition of phone messaging app, WhatsApp, tops the list of most expensive tech acquisition of past decade. In order to gain its control over socio-communication market, this deal comes after this social giant acknowledged the concerns of its investors about slow growth rate. This acquisition came after an “overrated purchase” of Instagram by Facebook at $1 Billion couple of years back which now is worth 10x its acquisition price.

Engineers : A prize-catch or the worst-dump of the society

Engineers : A prize-catch or the worst-dump of the society

engineer

Engineers – Life in India

What created Engineering?

Engineering was created by mere delusions of mind. The boy soon after his birth in India is married with the goal to be an Engineer and thus it becomes his destiny and prolonged identity. His parents teach him Mathematics and no Literature, Physics and no Biology. His diversions are focused to perks after engineering. And then he firmly believes that upon the completion of his engineering, he will be handed over a ‘Kingfisher model meets Arundhati Roy’ kind of bride along with his degree. Forget about the girl part. He thinks he can en-cash his degree to earn millions. But such delusions are what keep the economy going. No delusion means no engineering. No engineering means no engineers. No engineers mean no investment bankers, no authors, no social workers, no ad makers, no janitors etc. Get the point?

10 statements defining Engineering students

1.       2 Mbps Internet connection is utmost necessary than 2 liters of water per day for survival.

2.       Seeing sunrise is a sin. Even if the sun gods defer by an hour or two still one won’t wake up.

3.       Bunking classes, proxy, running out of the classroom when the teacher is teaching… C’est la vie!

4.       No effect of crap grades. They occur with such regularity; you can do nothing but ignore them.

5.       One night stands. I wish i could say it means the way it is meant to mean. It is in relation to exams, blokes.

Engineer_2

6.       Deodorants and face wash- I do not want to piss you off by providing the exact data of the interval between their successive baths. These people really save water.  

7.       Use their creativity in charting and managing to attend the minimum no. of classes needed for a pass grade.

8.       Their efficiency is inversely proportional to the number of days left to the deadline.

9.       Engineers can share everything from books to boxers. They are adept at adapting to unadoptable situations.

10.   Engineering students have been known to suffer from epileptic fits and seizures if they are unable to find the torrents for the latest episodes of American sitcoms and Movies. The only backlog an engineer actually dreads is a backlog in sitcoms. Again, an engineer’s method of watching sitcoms is entirely opposite to the conventional ‘one episode-per week-for several years’ approach that lesser mortals follow.

No aspect of human life has been left untouched by engineers. From call centers to novels, from Wheeler’s to Wall Street, from Pixar to Actors, from technicians to terrorists, you will find engineers all around you. The boogeyman under your kid’s bed-he’s a computer engineer who failed to make it to IBM. Engineers diversify and multiply faster than any bacteria or virus known to man. This is what an Engineer is. A prize-catch or the worst-dump of the society.

5 Projects where Google Failed

5 Projects where Google Failed

Google, the innovative internet search based company, is constantly working on various future based ideas. Not all of which achieve glories of GMail, Maps and android. Here we will showcase 5 failures of this search giant which failed to click practically.

g2

5. Google Answers

Go Online, Ask Questions, Get Answers from pioneers of that field. After immense success of Yahoo answers (well, sarcastically!), Google tried its hand in this glowing field of online QnA with Google Answers. However due to constant criticism of plagiarism and homework assignments posted as Question, Google took back this service in late 2006 under the shadow of putting more effort in finding other ways to help users find information.

Current status: Quora, A social networking integrated QnA site finally emerged as pioneer  of this field and gaining popularity every day with its large user base and tight social integration.

 

4. Google Print Ads

After a successful implementation of online advertising program, Google tried same approach in offline print ads too.

However, the metrics used by Google for finding target audience failed miserably in offline world. Tracking and implementation of its various parameters were a hard task and thus Offline world was reluctant to accept the fact.

google_ad_

3. Google Video

Before buying YouTube, Google attempted to crush it using Google Video. However, a proprietary file type and an out of world player made it almost impossible for a common man to stream his videos online. With likes of YouTube in hindsight, it was destined to be a failure right from start. After buying YouTube, Google again tried its hand  in Google video via video rental service and were again beaten clearly by NetFlix.

Current status: bought YouTube and closed Google Video.

2. Jaiku

Jaiku

Before Twitter gained popularity, Google acquired a little less known micro blogging site, Jaiku. Even at the time of this acquisition in October 2007, Twitter was progressing to a clear winner spot. Google changed its mind in Early 2009 and declared Jaiku, and hence Google’s attempt at Micro blogging was closed forever.

Current status: Beaten by Twitter and closed.

1. Google Wave

wave

Most anticipated, and hence biggest failure in terms of reputation, Google wave as quoted by Guardian,

“The Wave idea was a centralized communications tool that combined the real-time advantages of Twitter with the aggregation of your email and chat, with collaborative documents too. Easy to dismiss as something too ambitious and far reaching, but perhaps the difficulty in describing its function was its biggest downfall.”

Current Status: Closed.

Apart from above, Google Squared, Google Radio, Google Lively, Google Health, Google Notebook and Dodgeball are among Google’s other failure attempts.

 

EDIT:

0. Google character search

Though putting search as Google failure is as dumb as a rock, Still Google search fails miserably when used with special characters (Try <=) and other mathematical symbols. Apparently, Google’s no results to <= query is good enough to make it stand in this failure list.

Current status: Still ruling the world of Internet.

 

Project loon – Up and Away – Balloon powered Internet

Project loon – Up and Away – Balloon powered Internet

loon2

Project loon, Technology giant Google’s attempt to provide balloon powered internet to two third of worlds population. Project Loon is a network of balloons traveling on the edge of space, designed to connect people in rural and remote areas, help fill coverage gaps, and bring people back online after disasters.

[embedplusvideo height=”281″ width=”450″ editlink=”http://bit.ly/11PQnTh” standard=”http://www.youtube.com/v/m96tYpEk1Ao?fs=1″ vars=”ytid=m96tYpEk1Ao&width=450&height=281&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=¬es=” id=”ep8990″ /]

Why the name Loon?

Being driven by balloons, there could not be any crazy name as the idea itself is crazy enough,  thus the name, Project Loon.

What is the plan?

Google is aspiring to cover whole stratosphere with connectivity loons and thus when one balloon moves away, other will cover it up in planned ways ensuring constant connectivity. These balloons will be able to connect with each other and thus to ground base station.

Project loon How it connects

How will it work?

A set of the balloons, transceivers, terrestrial control equipment, on-board battery, solar panels and GPS, network monitoring equipment and terrestrial antennas will be powering this project to physical world. With bare minimum manual intervention, Google is aiming to completely automate the process. Results? Seamless connectivity.

How much money will it take?

As always, Google dint provided any information on how much money they are investing but it takes huge amount to start with such ambitious project.

How fast it will be?

Google says the balloons will provide mobile data connectivity equivalent to today’s 3G speeds, or possibly greater. However, the project may face several challenges in providing high speed connectivity to remote areas and in disastrous situations.

But WHY?

[pullquote]Google is giving away hugely expensive fiber-based Internet access (in the U.S.), but not because it’s a charity. Google knows that the more people that spend time online, the more likely they will spend money with Google.[/pullquote]

Why would Google want to invest huge amount in such huge project? Is it just a pilot project to publicize and sell ads or it is a genuine attempt to bring remaining two-thirds of worlds population? Well, either ways, more internet users directly means more users and bigger market for Google. Going by the way Google made its current market, Don’t be Evil will answer most of raising eyebrows.

OK, So by when this can be expected?

It already had a pilot test, Project Loon started in earlier June, 2013 with an experimental pilot with Thirty balloons, New Zealand. A small group of Project Loon pioneers tested the technology in Christchurch and Canterbury. However, no test results are out yet and no further plan is shared about its next pilot run.

So I can say goodbye to my current Internet plan then?

Wait. You probably won’t get it any soon. As per Google’s intentions, this will only be meant for regions where Internet connectivity is either very costly or not available. Thus the target for this project is the remaining two-third of population only and chances are, you will not be a part of the project in its initial phase to say the least.

Source: http://www.google.com/loon/