Paytm AndroidTerminal – Seamless recharge via linux

Paytm AndroidTerminal – Seamless recharge via linux

download (4)

In continuation to my previous attempt to control Whatsapp via command line (If you haven’t read that, Please do before continuing), This guide will allow you to recharge your mobile number via command line using Paytm.

 

Prerequisites:

With all prerequisites as in previous guide still valid (including Android phone attached via data cable to Linux machine), couple of additional ones are

  1. Paytm app – Download here.

  2. A logged in user with paytm wallet balance – Yeah, this guide is not a free recharge guide and will be using Paytm cash from user’s account.

Terminal Commands

1. To unlock your phone

adb shell input keyevent 82

If your phone is locked, this command will unlock it for you. For those who are using screen-locks, it can also be automated but it is again beyond scope of this tutorial.

2. Open Paytm app

As we did for whatsapp, we can open paytm app via stop-start machanism to ensure it to work even though it was open already.

adb shell am force-stop net.one97.paytm
adb shell am start -n net.one97.paytm/.AJRHomePage

3. Ask Recharge number

After reading the recharge number, Tap on recharge number coordinates (270, 650) found by hit and trial.

echo -n "Enter Number:"
read number
adb shell input tap 270 650
adb shell input text $number

4. Ask user for amount he wants to recharge with.

Similar to Number, Tap on coordinates for amount and fed the desired amount in it.

adb shell input tap 270 1050
echo -n "Enter Amount:"
read amount
adb shell input text $amount

5. Get the recharge done

Now to proceed further, you need to tap on back button once to remove keypad screen and then press on Proceed buttons and subsequently tapping on pay with path cash button.
adb shell input tap 270 1850
adb shell input tap 270 1350
adb shell input tap 270 1450
adb shell input tap 990 1650
adb shell input tap 990 1650
adb shell input tap 990 850

6. Close the Paytm app.

Echo a thanks message before closing the app.

echo "Thank you for recharging with Paytm AndroidTerminal \m/"
adb shell am force-stop net.one97.paytm

 

PS: If your android phone is connected to internet via a slow connection, you might need to add appropriate sleep command to make it work.

This entire experience can be automated by saving below commands in a file

adb shell input keyevent 82
adb shell am force-stop net.one97.paytm
adb shell am start -n net.one97.paytm/.AJRHomePage
echo -n "Enter Number:"
read number
adb shell input tap 270 650
adb shell input text $number
adb shell input tap 270 1050
sleep 2
echo -n "Enter Amount:"
read amount
adb shell input text $amount
adb shell input tap 270 1850
adb shell input tap 270 1350
adb shell input tap 270 1450
sleep 2
adb shell input tap 990 1650
sleep 2
adb shell input tap 990 1650
sleep 2
adb shell input tap 990 850
echo "thank you for recharging with command line paytm \m/"
adb shell am force-stop net.one97.paytm

Save it in a file named paytm and make it executable with global access. Now next time you need to recharge, Paytm CommandLine will be at your service.

Using Javascript for mass invitation for a Facebook page

Using Javascript for mass invitation for a Facebook page

funnyjavascript

Recently, For a friend’s Facebook page, We need to send invitations to all of his friends. So instead of clicking Invite button for every single person, I preferred to write a small javascript for this.

Script:

var a = Array.prototype.slice.call(document.getElementsByClassName("_5tef"))[0];if(a)a.click();setTimeout(function(){Array.prototype.slice.call(document.querySelectorAll("ul._5kwh li")).forEach(function(c){var d = $(c); var e = d.getElementsByTagName("button")[0]; if(e) e.click();})}, 1000);

 

How to use it

Open Facebook page for which you need to send invites, Make sure there is a peoples section on that page though which invites can be sent.

open console. via right click –> Inspect element –> Console. and pasting above script followed by enter.

How it works

It works as a daemon which will first click on show more friends button and then click invite against all friends listed in that list, one by one.

Key elements to write such scripts or modify this script

You need to know specific components of this script and their usage to modify it

1. document.getElementsByClassName – To select all elements with given class name, which in this case is 5tef (Use inspect element to get this).

2. document.querySelectorAll – To select all friends with specified selector, child <li> with parent class as _5kwh in our case.

3. getElementsByTagName – To get all child buttons which we target to click on.

 

Future of Search – a naive analysis

Search, by far most elementary part of internet which helped shaping company like Google to be Internet giant. As per stats, Google owns roughly 86% of entire search done globally.search-engine-market-shares-global.1

 

Even with a market share as huge as 86%, Google must be worried about future of search. It can be taken from their ad-campaign which was aired in late last year.

[embedplusvideo height=”500″ width=”768″ editlink=”http://bit.ly/1qapfx8″ standard=”http://www.youtube.com/v/gHGDN9-oFJE?fs=1″ vars=”ytid=gHGDN9-oFJE&width=768&height=500&start=&stop=&rs=w&hd=0&autoplay=0&react=1&chapters=&notes=” id=”ep7595″ /]

Behind  a very sensitive track, Google embedded their plans very beautifully. Mobile. Yes, Search has now moved from desktops and laptops to Mobile and expected to bypass desktop users by huge margin in coming years.

Future

MobilevsDesktop

 

Looking at future predictions, Mobile is future. But Google pioneers mobile search too, isn’t it? Yes, but it is an interesting study in itself.

But what worries Google?

When asked “What will you do if you want to find a restaurant nearby?”, 3 out of 5 users preferred Zomato instead of google search.Similarly, If you need to find price of latest i-Phone, you will preferably go to E-Commerce sites like Flipkart, Amazon or Paytm instead of Googling it. You will still be preferring MakeMyTrip for your travel related search even if Google provide flight search option from their search box itself.

This trend is not only for search, it can be extrapolated to all domains including e-commerce. Sachin Bansal (flipkart) and Vijay Shekhar Sharma (Paytm) cleared this in their strategies in past few weeks.

Google is looking to acquire the user base that is shifting to apps like Flipkart, MakeMyTrip and Zomato for specific results. google-mobile-search-450x277

Having said that, Google has seen 400% rise in mobile searches and is targeting retention of these users.

Future of search will be personalised results (apart from what is mentioned in search keyword) which may include social network, past search history and individual’s preferences.

Coin Flipping brainstorming

Coin Flipping brainstorming

 

 

coinHere is a brainstorming session on coin flipping. It involves a game of pattern choosing. You have to choose a pattern which have better probability to occur.

    • Flip a fair coin twice. What is the probability that you get two heads (HH)? What is the probability that you get heads followed by tails (HT)? Are these probabilities the same?

Yes, sure they are. No confusion yet.

    • Flip a fair coin repeatedly until you get two heads in a row (HH). On average, how many flips should this take? What if we flip until we get heads followed by tails (HT)? Are the answers the same?

Based on the previous problem, most folks assume that the answer is Yes, but the answer is No.

    • Let’s play a game: we flip a coin repeatedly until either HH emerges (I win) or HT emerges (you win). Is the game fair?

Based on the previous problem, most folks assume that the answer is No, but the answer is Yes.

    • We play the let’s-flip-a-coin-until-a-pattern-emerges game. You pick HHT as your pattern, I pick THH. We flip a fair coin repeatedly until we get heads-heads-tails in a row (you win) or tails-heads-heads in a row (I win). Is the game fair?

Based on symmetry, most folks assume that the answer is Yes, but the answer is No. I’m winning 75% of the games

  • Seeing as THH is a better pattern, you request to pick it as your pattern. I graciously agree, and switch to TTH. I keep beating you most of the time. You switch to my TTH. I switch to HTT. I keep beating you. You switch to HTT. I switch to… HHT, your original losing pattern. Who’s winning now?

Most folks are by now expecting trouble, and guess correctly even though they feel it’s impossible. Indeed, HHT is better than HTT, which is better than TTH, which is better than THH, which is better than HHT.

This delightful result is known as Penney’s game

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.

Whatsapp Command line tool – Linux developer version

Whatsapp Command line tool – Linux developer version

wa

Whatsapp, a popular cross-platform mobile messaging app can now be used via simple command line tool too. Whatsapp linux chat client, WA, can be coded in a few minutes from scratch if you have adb installed and ready.

Prerequisites:

adb must be installed and set to environment path. To those who arent familiar with adb, It is a command line interface to interact with android phones and is shipped with developer toolkit.
Once downloaded, it can be added to path variable by updating bash_profile file with below line (located at ~/.bash_profile).

export PATH="$PATH:/Users/hitesh/Documents/personal/adt-bundle-mac-x86_64-20140321/sdk/platform-tools"

Command line tool:

Once your system is ready to interact with android device, we can proceed to make whatsapp command line interface. It will be 11 commands tutorial which I will cover step by step

1. To unlock your phone

adb shell input keyevent 82

If your phone is locked, this command will unlock it for you. For those who are using screen-locks, it can also be automated but it is beyond scope of this tutorial.

2. Restart whatsapp

adb shell am force-stop com.whatsapp

This is done just to avoid running into previously opened whatsapp chat client. We will restart this activity in very next step to avoid any issue.

adb shell am start -n com.whatsapp/.Main

3. Ask for name to which you need to send message

echo -n "Enter Name:"
read name

4. Feed the input name to whatsapp

adb shell input text $name

5. Tap to open chat activity*

adb shell input tap 270 350

6. Ask for message which is to be sent

echo -n "Enter Message:"
read message

Feed the message to whatsapp

adb shell input text $message

It is all set now.

7. Send the message by tapping send button*

adb shell input tap 990 1650

and message is sent.

 

This entire experience can be automated by saving below commands in a file

adb shell input keyevent 82
adb shell am force-stop com.whatsapp
adb shell am start -n com.whatsapp/.Main
echo -n "Enter Name:"
read name
adb shell input text $name
adb shell input tap 270 350
echo -n "Enter Message:"
read message
adb shell input text $message

save this file as wa.sh

It can now be triggered via below command

sh wa

to make it more user friendly,

add this path (can be checked via command pwd) to PATH variable as done for adb command earlier

Now your client is ready to send all messages just by typing wa anywhere

 

Bonus:

If you want to lock out your phone as soon as this is done, Use below command

adb shell input keyevent 26

Or you can remove step 1 too to enter full stealth mode.

 

Disclaimer:

1.This post was written for nexus 5 device and was tried via MacBook. You may need to change parameters in step 5 and 7 if your device is not nexus or prerequisites to set environment variable if you are on a different linux version.

  1. Use Pushbullet to receive messages if you can want that too on your mobile.

 

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.