Screenreader for chrome

A chrome extension to read aloud web pages with a very simple interface.
Get it from the chrome webstore

The operation is very simple. To read any text just select the text BEFORE it and press ,(comma) key. The text selection automatically jumps to the line and reads it out aloud. And similiarly keys are there for prev/next sentence, word and paragraph.

RECOMMENDED: Install the free high quality tts voice from google for better results from : https://chrome.google.com/webstore/detail/us-english-female-text-to/pkidpnnapnfgjhfhkpmjpbckkbaodldb It also works offline

KEYMAP(also on welcome page and options page, after installing)

, key goes to next line and ‘reads it'(i.e upto next full stop)
‘m’ key goes to previous line and reads it.(i.e upto previous full stop)
‘ key to go upto next punctuation mark
; key to go upto previous punctuation mark
shift+i to invert colors
[ key to go to previous word
] key to go to next word
. key to jump back an entire paragraph
/ key to jump forward an entire paragraph
.press enter key to stop speech

If already speaking. pressing any other key will speak the currently selected text again.  The important thing is that everything is done using single key presses so you can comfortably close your eyes and use one hand to operate it. All the required keys are very adjacent to each other.There is absolutely no additional interface added. you press a key and the text selection moves around and is read aloud. That is all. Also pressing ‘ key moves upto next punctuation mark . This is a very important feauture as most logical breaks are along punctuation marks.

Currently continious reading is not supported , i.e you need to press next/prev sentence/paragraph buttons etc everytime you need to go to a new sentence/paragraph etc and also keymap cannot be customised and additionally if offline , there are a few issues. Also with safaribooksonline.com it does not work properly. To disable/enable for any specific page just click the screenreader icon.  This project is hosted on github at
https://github.com/sktguha/screenreader_deploy_ready_standalone . (Not the cleanest and well-structured of codes :p but it was my first slightly complex project ). For better offline reading experience (like reading ebooks in html or converted to html from pdf etc) you can try out a windows specfic version at https://github.com/sktguha/screenreader-dependant also one for mozilla firefox mobile android https://github.com/sktguha/screenreader_mozilla_mobile

‘Youtube I am feeling lucky’ chrome extension

A great chrome extension to use if you are want to jump right to a video/song in youtube you frequently watch/hear without the intermediate hassle of clicking the first search result. This extension adds the functionality of I am feeling lucky button in google.com to youtube.com, i.e redirects to first video in youtube search result. To use it click the I am feeling lucky button next to search button or press shift enter after typing your query in the search box.

Get it on the chrome webstore
Source code on github
Covered by The Next Web
Featured on Product Hunt

Closures in JavaScript

So in this post I will try to explain javascript closures.
I will try to explain the concept of closures in a very practical oriented way.
so simply put javascript closures allow you to define some kind of privacy, sort of like private fields in java, c++ etc.
So anyway we know that javascript has no direct notion of private variables. so variables are either public scope or local.
More specifially , what I mean is that there is no simple way to do the following in javascript

//a java example
class Counter
{
private int counter=0;
public int add(){
counter++;
return counter;
}
}
//okay so in java we could use this class as
public class myclass
{
public static void main(string args[])
{
Counter ct=new Counter();
ct.add();
ct.add();
int res=ct.add();
system.out.println(res); //so result is 3
ct.counter=23423; //wrong . you cannot access a private variable directly
}
}

so if we were to do this example in javascript we could do this as (using the google chrome console)

var counter=0;
function add(){
counter++;
return counter;
}
//so we use as
add();
add();
var res=add();
alert(res);
counter=45235; //THIS IS ALLOWED

you see the problem?. we can have access directly to the counter variable in javascript whereas in java we cannot
so how do we make the counter variable private .
okay so we will use concept of local scope in javascript.
what I mean is

function Counter()
{
var counter=0;
}

so now we cannot do this

counter++; //WRONG. counter is not defined in global scope

oh cool. But but how do you access the counter variable at all ?
remeber we still need to increment the counter variable from outside.
okay for that we will create a function inside the function Counter

function Counter()
{
counter=0;
function add()
{
counter++;
return counter;
}
}

yes this is allowed in javascript, in case you were wondering
oh good. so we have a private variable, a function to modify that.
so now can we do this?

add();

No we can’t , as add() is local to the Counter() function.
so what we do is , we need a reference to the add function. Then we can call it
What I mean by the above line was this

function message()
{
alert("hello world");
}
var a=message; //get a reference or pointer to the above function, whatever you like to call it
a(); //so alert is displayed

Again in case you were wondering, yes this is possible in javascript. functions are treated as normal variables.
so in the example of Counter() function , we need to get out a reference to the add funcion to the outside world.
so we have, finally

function Counter()
{
var counter=0;
function add()
{
counter++;
return counter;
}
var a = add; // get a reference to the function add
return a; //and send it to the outside world, by way of specifying it as the return value
}

So in the above function, we are returning a reference to the function
That is function Counter() does not return a string, number etc. It returns another function.
Or more precisely, a reference to the another function
so now we can use this as

var a=Counter(); // Counter() executes and returns a reference to the add function inside it
a(); //so the variable a points to function add() defined inside the function counter
a();
var res=a();
alert(res): //so displayes 3