Wednesday, August 19, 2020

Ad-blocking for MIUI and other Android Devices

Many of MIUI users have been suffering from issues of "Ads" shown practically everywhere across the phone. Well not only MIUI, but many other phones from other manufacturer too share similar kind off problem. Sometimes such issues also arise due to various apps we install that show plenty of ads. 

These continuous flow of ads not only ruins the end user experience but also ruins the battery life. So regardless of whether your phone has 4000Mah battery or 5000Mah, It doesn’t seem to last the way it should. Now amongst several solutions available out there many of the solutions require rooting of phone which is not a easy task for an average end user. In this post I will share a method which does not require end user to root the device. 

To begin with we need to install an app named "Blockada" ( Please make sure you install the app from this website and not from the Google playstore. The version on Google Playstore only allows changing of DNS as ads play important role in Google's Business model. Once downloaded, install the apk onto your phone and launch the app. 

As soon as the app launches you will be greeted with several options like "Ad Blocking", "DNS" and "Blockada Plus". You will also see an icon at bottom which will launch settings for the app. Now lets begin with setting up the ad blocking: 

Step 1. Open 1st option of ad blocking:

Step 2. Open Host List and select the host configuration as shown in the below screenshot.

I have come up with this selection basis of my surfing habits and apps that I have present on my phone that have ads in them. You can choose to ad or remove these host basis of your requirement.

Step 3. Open Adblocking Settings and enable  "[BETA] Advanced adblocking rules"

Step 4. Go to VPN options in the system found in network settings. Make the VPN "always-on". This will help in preventing auto disconnections.

Step 5. Disable "Private DNS" from network settings as well. Incase on some versions of MIUI this setting may not be directly accessible. In that case you can install "Hidden Settings for MIUI" ( and access this setting as shown in the screenshot below.

Please note that this is very important. The adblocking may or may not function properly if it is left enabled. You can further ignore this app from battery optimization to make sure that it does not get killed automatically. 

Tuesday, January 21, 2020

Eco-friendly note taking for old school

While digital note taking is gradually catching up with next gen, earlier generation still prefers the pen and paper approach. Note taking many a times in our day to day routine, is very ad-hoc and unstructured. This leads to notes getting scattered across various books or pages which have high chances of getting misplaced. Plus gradual accumulation of lot and lot of old books. With many individuals doing note taking in similar manner we end up cutting more and more trees and damaging the nature with every passing moment.

So what can we do in order to make our note taking eco-friendly as well as not requiring extreme changes in our note taking habits? In this article I talk about my eco-friendly note taking habits. For this we use following things:

With all this in place how do we go about note taking? Here is what I usually do:

  • I take notes as per my requirement (daily/weekly)
  • Scan to PDF using the app suggested above and share it if notes are to be shared
  • Then on every weekend erase the book using eraser.

This way I'm able to reuse a single book for several months there by reducing stack of notebook which would pile up otherwise. Plus scanning the articles helps me maintain the notes for long term basis without worry about loss and wear and tear of pages.

If more and more people follow similar approach or something on these lines we can certainly reduce the amount of trees that need to be cut there by protecting nature.

Sunday, April 10, 2016

Finding difference between two dates in JS

"Finding difference between two dates" is not a new topic in JavaScript world, however with this post, i wish to go one step ahead by providing this ability as an extension of Date object itself and in a configurable manner.
In this code we extend Date object prototype with a new method named "difference". This method take another date (Created using "new Date()") and "unit" for comparison result i.e in what units do you want to know the difference e.g "seconds","minutes","hours","days" or "months"

Wednesday, December 3, 2014

How to fix: Smart watch 2 won't install apps on MIUI

Many people trying to connect Sony smartwatch to phones with MIUI or Xiaomi Phones have faced issue where even after downloading and installing apps for smartphone from Google play store, the apps are not seen on the watch for use.

In this post i will provide simple steps for solving this issue. Please note that this fix requires rooting your phone.

Step 1: Root your phone.

Step 2: Install Lucky patcher (

Step 3: Install all the smartphone apps you need from Google Play Store.

Step 4: Select the specific app from lucky patcher's list. Click on tools and select "Move the app to "system/app""

Step 5: Reboot the phone

After phone reboot you should see the installed app on phone. :)

Monday, August 4, 2014

Can't download App's from Google play via 3g network

This is a short post describing a solution for a very common problem on android phones. One of the common problem with android is that, Apps cannot be downloaded over 3G connection. This problem is not only there with the play store, but with other applications dealing with media. The solution for this is very simple!
Go into Settings/...More settings/Mobile networks/Access Point Names. Choose your Access Point name and empty Proxy and Port. And that should fix your problem!

Wednesday, April 9, 2014


A Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and widely known encryption techniques. In this type of substitution cipher each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.

As with all single alphabet substitution ciphers, the Caesar cipher is easily broken and in modern practice offers essentially no communication security.


The transformation can be represented by aligning two alphabets; the cipher alphabet is the plain alphabet rotated left or right by some number of positions. For instance, here is a Caesar cipher using a left rotation of three places, equivalent to a right shift of 23 (the shift parameter is used as the key):

When encrypting, a person looks up each letter of the message in the "plain" line and writes down the corresponding letter in the "cipher" line. Deciphering is done in reverse, with a right shift of 3.
Plaintext:  the quick brown fox jumps over the lazy dog

Breaking the Cipher

The Caesar cipher can be easily broken even in a cipher text-only scenario. Two situations can be considered:

  1. An attacker knows (or guesses) that some sort of simple substitution cipher has been used, but not specifically that it is a Caesar scheme;
  2. An attacker knows that a Caesar cipher is in use, but does not know the shift value.
In the first case, the cipher can be broken using the same techniques as for a general simple substitution cipher, such as frequency analysis or pattern words. While solving, it is likely that an attacker will quickly notice the regularity in the solution and deduce that a Caesar cipher is the specific algorithm employed.

In the second instance, breaking the scheme is even more straightforward. Since there are only a limited number of possible shifts (26 in English), they can each be tested in turn in a brute force attack. One way to do this is to write out a snippet of the cipher text in a table of all possible shifts — a technique sometimes known as "completing the plain component".

Candidate plaintext

The example given is for the cipher text "EXXEGOEXSRGI"; the plaintext is instantly recognizable by eye at a shift of four. Another way of viewing this method is that, under each letter of the cipher text, the entire alphabet is written out in reverse starting at that letter. This attack can be accelerated using a set of strips prepared with the alphabet written down them in reverse order. The strips are then aligned to form the cipher text along one row, and the plaintext should appear in one of the other rows.
Another brute force approach is to match up the frequency distribution of the letters. By graphing the frequencies of letters in the cipher text, and by knowing the expected distribution of those letters in the original language of the plaintext, a human can easily spot the value of the shift by looking at the displacement of particular features of the graph. This is known as frequency analysis.

Enhancing the Cipher

Based on the explanation provided we see that main problem with Caesar cipher is predictability. Two main issues that cause this predictability are:

  1.  Fixed index for shifting characters
  2.  Knowledge about character at a given index.
We can enhance the strength of the cipher by overcoming these 2 issues. Let us look into these 2 issues and how we can overcome them:

Fixed index for shifting characters

As you read earlier in Caesar cipher each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. Thus if attacker manages to figure out shift index he can easily break the cipher text. We can overcome this making the shift index variable. Consider the example shown in the table above. Instead of using a fixed index of 4, the index could be length of the string I.e 12. Using such variable index will make the cipher text difficult to predict. In addition to this advantage, two similar word/phrase with different lengths would have different cipher texts. For example attackatonce and attackonce will have no pattern in common even though the word “attack” and “once” are being repeated. This happens because the string length is different thus the shift index will be different.

Knowledge about character at a given index

In our previous example we also observed while shifting the alphabets, the alphabet at new position occurs as per alphabetical order of A-Z. Thus if attacker manages to figure out the shift index he can easily find out all the characters in the given cipher text. Besides making the shift index dynamic we can also shuffle the alphabetical order by which the alphabets won’t be substituted as per the default alphabetic order. For example on a shift index of 4 if we were suppose to substitute character “a”, by alphabetical order the new character would be “d”. However if we do not follow alphabetical order and replace the characters basis of shuffled set of characters it will make it difficult for attacker to derive the plain text. For this we need to have a shuffled set of alphabets.


Enhanced Caesar cipher can be implemented in following manner:

  1. Determine the shift index on the basis of string length.
  2. Determine the position of character to be replaced in the shuffled string.
  3. Add the shift index to the position to determine the position of new character.
  4. Determine the character at new position. If the new position is more than the length of the shuffled set then loop again after the loop index reaches the length of shuffled set.
For example
The plain text to be ciphered is “america”. The shuffled subset is “adwxyzefijklmnoghpqrstbcuv”. The cipher for this will be “frnagyf”. In this example “a” is substituted with “e”. For this substitution we 1st determine the position of “a” in shuffled subset. This is 1. Now we need to determine the shift index, which is length of string i.e. 7. Thus with a right shift of 7,”a” gives “f” as per the shuffled set. Similar substitution process will be applied to each character in the given word.

The Outcome

An enhanced cipher technique derived from a simple substitution cipher is much effective compared to its original version.

Wednesday, November 27, 2013

Using jshybugger to debug HTML, CSS and javascript on native Android browser

Debugging web applications on android device as been a challenging issue. This becomes further challenging when the debugging is to be done on native browser of Android.
The debugging tools provided by native android browser are insufficient to perform detailed analysis of the problem. (In case you're not aware about these tools and wish to check em out type "about:debug" in your native browser's address bar and then check your settings menu for debug options).
While looking for solution of one of my problems on native android browser i came across this tool which does the job brilliantly! Its name is jsHybugger (!/).

When you use jsHybugger App, jsHybugger runs on your device and provides two things:
  • a proxy between the native Android browser and the web server where your mobile web pages are hosted
  • a communication endpoint for the debugging frontend on your development machine
Using this very simple and straight forward. Steps for it are as follow:

  1. Download and install the APK file for jsHybugger App, either through a direct download on your device or from your development machine using ADB.
  2. Start jsHybugger App on your device and adjust the configuration (see parameters below).
  3. Open the native Android browser via Open browser. The browser automatically navigates to the specified URL.
  4. Connect to jsHybugger.
  5. Set port forwarding to enabled in ADB interface. For more information on how to use ADB extension please refer to my earlier blog post (

  • Remote host: IP address or hostname of the remote web server
  • Remote port: HTTP port of the remote web server (usually 80)
  • URI: URI of the start page, e.g. /index.html
  • Stop service: Stop service on device
  • Start service: Start service on device
  • Open browser: Start the Android browser with the configured URL
  • Clear cache: Clear jsHybugger cache
  • Log viewer: Display HTTP access log

Happy Debugging!!!