Kill Feed – A Simple app to kill Facebook/Quora explained

Kill Feed – A Simple app to kill Facebook/Quora explained

killfeed

Are you among those who spend endless hours on Facebook/Quora? Do you want to save all that time for something useful. Here I will present a simple way to buy back that time wasted doing endless scrolling on popular social networks for chrome users.

If you are not a programmer or not interesting in learning how to do it,  you can use already existing solutions in “Kill News Feed” or “News Feed Eradicator“.

For programmers, I will explain step by step way to create your own chrome plugin which will do this right from scratch.

Prerequisites: Basic CSS and jQuery.

Kill Feed!

  1. Create a new folder and name it KillFeed.

  2. Create a new file and name it manifest.json

  3. Open file and add following code to it.

{

"name": "Kill Feed",
"version": "1.0",
"description": "Saves your precious time by kill Facebook/Quora news feed.",
"manifest_version": 2,
"permissions": [
"http://www.facebook.com/*",
"https://www.facebook.com/*",
"http://www.quora.com/*",
"https://www.quora.com/*"
],
"content_scripts": [
{
"matches": ["http://www.facebook.com/*", "https://www.facebook.com/*",                         "http://www.quora.com/*", "https://www.quora.com/*"],
"js": ["jquery.js", "killer.js"],
"run_at": "document_idle"
}
]
}

This code does following things: Name your new chrome app, gives basic descriptions, asks for permissions for accessing your content on facebook and quora and runs when document becomes idle.

  1. Create a file killer.js and add following code to it.
var html = "
<h1>Your Time is precious!</h1>
";

setInterval(function(){
// Replace feed
$("div#pagelet_home_stream").replaceWith(html);//Facebook
$("div[id^='topnews_main_stream']").replaceWith(html);//Facebook
$("div.feed_col").replaceWith(html); //Quora

// Removes feed
$("div#pagelet_ticker").remove();//Facebook ticker
$("div.feed_wrap").remove(); //Quora Feed
$("div.above_page_banner").remove(); //Quora alert to refresh
$("div#pagelet_trending_tags_and_topics").remove(); //Facebook
}, 1000);

This step creates a nice message to show instead of your feed and than kills the feed via jQuery selectors.

To install this brand new app, Open your chrome to chrome://extensions/ and click Load unpacked extensions. Now browse to your folder KillFeed which you created in Step 1.

And you are done.!

Goodbye Facebook/Quora.!

Note: This app is just a reminder to you that your time is really precious which if  undesired can be revoked by deleting/disabling the app via Chrome extensions link.

For complete code: https://github.com/Hiteshm01/news-feed-eradicator. You can download and load this directly in chrome.

Let us know how much time you saved using this simple app.

 

Apple iPods- Success story

Apple iPods- Success story

pods

How Apple’s iPod became successful than other MP3 players that have been out years before?

Does anybody remember the Sony’s MP3 Walkmans?  The pre-iPod market had a lot of devices, but none of them had larger market share than other. Until Apple introduced iPod and created their monopoly over the market.

What exactly Apply did differently?

One stop solution

By connecting both hardware and software, Apple attempted first of its kind one stop solution to music industry. When quality hardware met elegant software, iPod turned out to
be the need of the market. With an option to buy original music at cheap rates directly on your device, iPod revolutionised the music industry altogether.

Easy Music sharing across devices

Steve Jobs always liked the idea of easy sharing of content with friends. He once quoted that if you design shareability into your product from the beginning it will help you down the line. However, for iPods, Instead of relying on any social media group, Apple created its own iTunes world, where users can share it among other iPod users.

Portability

Apple, for the first time enabled users to enjoy music on the go as well. With  Campaigns of 1k songs in pocket, Apple demonstrated the true power of portable quality music which eventually lead to increasing purchases as demonstrated by their one-billion downloads.

Original-Apple-iPod

Marketing

Now when iPod reached market, it was usually kept in one’s pocket. Challenge was to show others the presence of this cool device.

marketing

Back then, All music players had black ear leads. Apple did the opposite. Instead of black earlead for iPods, they chose white. So Apple’s iPod was the only music player in market which had white earphone leads resulting direct branding even if the iPod is inside your pocket. They took it far enough that major marketing was concentrated on white headphones rather than iPod itself.

dancehq

Success of iPod can be measured by the fact that peoples who owned other (non iPod) music devices, also bought white ear leads separately.

 Lifeline to Online Music Industry

music

When Music industry was certain about online piracy and its effects on actual sale of CDs and dropping revenue, iTunes store showed them path by enabling them to sell it directly to user.

“The genius of the iPod was (and still is, with the iPhone) that, while the music industry actually believed that it had found a good (i.e., closed and controlled) way to extract money from otherwise freeloading consumers, the iTunes/iPod/iPhone ecosystem became the dominant hardware solution for the consumption of free music.” – Gerd Leonhard, author of The Future of Content

 

Considering its success now and connecting the dots backwards, Despite being 3 year late into portable music industry, Apple’s iPod made every other competitor miniature by growing at 616% from 2014 to 2015 and became “the Walkman of the early 21st century.”

 

 

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!!

 

 

10 Most Useless websites of World Wide Web

10 Most Useless websites of World Wide Web


uselesswebsite

1. Is it Christmas?

This website tells you if it’s Christmas or not. i.e. One day a year, the website says “YES”, every other day, it says “NO”. (in your countries language). So thoughtful!

2. Sometimes Red, Some Times Blue!

Surprisingly, it is sometimes Red, sometimes Blue. Nothing else. Never!

3. The magic button – Make Everything OK

Something is not ok in your life, Open this site and it will make it Ok.

4. Pointer-Pointer

You show it your pointer and it will find a picture pointing at your pointer. Point noted?

5. Feed The Head

You want your pointer to be watched in your absence? Probably Feed the Head will help or probably not.

6. Awesome?

Need some motivation? Visit I am Awesome and it will do the trick.

7. I am a Ninja?

Well only Ninja’s are supposed to get this till date. Just kidding, Open website and press Ctrl+A.

8. RGB

A dedicated site which tells you everything obvious about RGB (Red-Green-Blue).

9. A blue Box

~A very own site of the Blue Box~

10. End of Internet?

Who said there is no end to Internet? This site is exactly against the belief and in-fact, the end itself.

Additional Useless site:

If you are still interested in more useless websites, Visit The Useless web. It will take you to some of the most useless sites.

Do you know any use of these sites? Let us know.

 

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!

 

 

 

Find Maximum number of A’s using keys A, Ctrl+A, Ctrl+C and Ctrl+V

Find Maximum number of A’s using keys A, Ctrl+A, Ctrl+C and Ctrl+V


Problem Statement:

Find the sequence of keystrokes which generates maximum number of character ‘A’s using N keystrokes

ctrlcv

Conditions:

  1. Use of only four keys is allowed: ACtrl+ACtrl+C and Ctrl+V.

  2. All Ctrl+ characters are considered as one keystroke, so Ctrl+A is one keystroke.

3. Ctrl+A is Select All, Ctrl+C is Copy, Ctrl+V is Paste.

  1. Ctrl+V will not overwrite the existing selection. It will append to existing content.

 

I would recommend to stop reading here and think about it before reading the solution below.

cpypaste

—————————————————————————————————

Solution:

Given the conditions, Output on screen can be doubled with a sequence of Ctrl+ACtrl+C and Ctrl+V (doubling-sequence). For example if there are 10 characters on screen, with the doubling sequence, 20 characters can be achieved after 3 keystrokes. Using this, with some use cases it can be seen that in sample space,

For N=1, Maximum number of A’s = 1 (Sequence: A )

For N=2, Maximum number of A’s = 2 (Sequence: A A)

For N=3, Maximum number of A’s = 3 (Sequence: A A A)

For N=4, Maximum number of A’s = 4 (Sequence: A A A A)

For N=5, Maximum number of A’s = 5 (Sequence: A A A A A)

For N=6, Maximum number of A’s = 6 (Sequence: A A A Ctrl+A Ctrl+C Ctrl+V)

For N=7, Maximum number of A’s =9 (Sequence: A A A Ctrl+A Ctrl+C Ctrl+V Ctrl+V)

For N=8, Maximum number of A’s = 12 (Sequence: A A A Ctrl+A Ctrl+C Ctrl+Ctrl+Ctrl+V)

For N=9, Maximum number of A’s = 16 (Sequence: A A A A Ctrl+A Ctrl+C Ctrl+Ctrl+V Ctrl+V )

For N=10, Maximum number of A’s = 20 (Sequence: A A A A Ctrl+A Ctrl+C Ctrl+Ctrl+V Ctrl+Ctrl+V ) and so on…

 

On an alternate inspection, it is also observed as, To double a certain input, most visible approach might be looking as Ctrl+A Ctrl+C Ctrl+V but it takes 3 keystrokes. Going by this approach, for N input keystrokes, Output in range of 2^(N/3) can be achieved. Sample run for this approach will be,

A A   Ctrl+A Ctrl+C Ctrl+V  Ctrl+A Ctrl+C Ctrl+V  Ctrl+A Ctrl+C Ctrl+V  Ctrl+A Ctrl+C Ctrl+V ... and so on.

 

This solution can be marginally optimised if last few keystrokes (Calculated by reminder of N/3), can be replaced by  Ctrl+V instead of Ctrl+A Ctrl+C Ctrl+V. Result in order of 2^(N/3+1) can be achieved using this minor optimisation.

Considering the minor optimisation hack we just used, It can be assumed that even higher result can be obtained if Ctrl+V is used smartly.

 

On further inspection, it comes out to be that maximum number can be achieved if Ctrl+A Ctrl+C Ctrl+Ctrl+V is used repeatedly instead of regular Ctrl+A Ctrl+C Ctrl+V used in previous trial as it gives 4x output in 5 steps instead of 6 steps.

Summarising, For Mathematical nerds, this algorithm can be covered in an equation like,
Maximum no of A’s that can be printed =

4 + 4^[(N-4)/5] + ((N-4)%5)*4^[(N-4)/5]

where [] is greatest integer factor and N is number of Keystrokes allowed.

 

This is by far best solutions we could achieve, If you have a better solution, Please write up in comments.

 

 

2048 – A simple game of Mathematics – Simplified

2048 – A simple game of Mathematics – Simplified

2048, A game built on basic multiplication by 2, is played by merging similar tiles (All represented by power of 2) by moving them in any of the four directions. Once merged, final tile will be multiplication of both child tiles. With an ultimate aim of achieving tile labeled 2048, game ends if all tiles are filled and no valid merge is available. Here we will see optimize algorithm to solve this game.

2048-2

Prior to looking at the solution, Please try the game if you already havent. It is available at Bhadak.com and its original version available here. If you are android user, I have arranged an offline version of this game at Google Play store.

Optimal solving approach:

By keeping largest number (2^k) at one corner and arranging next lower numbers at adjacent positions as shown in image below, target value of 2^11 can be achieved. 2048

In order to achieve this state, Out of 4 moves possible (Up, down, left, right), One is to be marked as restricted, i.e. this one move should never be used in course of game. If used, counter reverse should be used to immediately balance it.

Logical explanation of restricted move:

By avoiding one move (Lets say upward), heavier elements can be clubbed in lowermost row. Now for any movement, new element to be introduced should never be introduced below or adjacent to already present heavier elements. By restricting the upward move, lower row is almost always completely filled and thus prevent any chance of this to happen.

Thus, overall these two rules govern the optimal algo.

  • Choose a corner and aim to place tiles with 2^k-1 (where k is current tile) in adjacent side.
  • Restrict one move right from start and stick to avoid using it as far as any of the valid moves in remaining three is available.

If chosen restricted move is up, this entire concept can be understood in terms of Gravity. Heavier element should always be accumulated at lower row and upward movement should only be done in case no valid move is available and as it happens in gravity, as soon as a upward move is done, down move should be executed next.

Algorithmically saying,

 

Initialise local maximum as null
for possible 3 moves(other than restricted move):
        find maximum result yielding move and update local maximum.
if maximum != null
   execute the maximum result move.
else
   execute restricted move and the reverse move to counter its effects

 

Proper implementation of its optimal solver is available online in AI form at github.

And in case you had trouble achieving 2048, below snapshot, taken after running the algorithm on uncapped version of 2048, may help

4096

 

How is your experience with 2048? What is your highest score? Do let us know in comments section below.