Fix non-stop repeated proxy authentication dialog box in FireFox.

If repeated proxy authentication in Firefox bugging you so much, here is the trick to fix it. I tried and it is working fine.

  1. In FF Location bar, type about:config, and press Enter.
    “This might void your warranty!” warning page may appear. Click I’ll be careful, I promise!, to continue to the about:config page.
  2. In the about:config page, search for the preference “network.negotiate-auth.allow-proxies”.
  3. Double-click on it and will see the value will change to false.
  4. Restart FF and get rid of Proxy Authentication pop up.

Your pen drive bigger than 4GB?

Do you know that pen drives are formatted in FAT32? Do you know that maximum file size supported by FAT32 is 4GB? Did you ever try to copy files bigger than 4GB in your pen drive, only to be confronted by some error?

Today we have pen drives of 8GB, 32GB and more capacity ones are coming. It is natural that we try to copy files which are bigger than 4GB into them. Unfortunately FAT32 does not support single files bigger than 4GB. You need to format your pen drive in NTFS for that.

In Windows (XP) when you try to format the pen drive you are provided with FAT32 as the only option. This is probably because of portable nature of pen drives. In NTFS you can set permissions and encrypt files too. These files then may not open on other computers. Furthermore, NTFS needs more writing than FAT32. This is maybe because of the small cluster size of NTFS.

To be able to format pen drives in NTFS you will need to enable “Optimize for Performance” mode. Ples follow through the steps of this excellent article – http://blog.eches.net/tips/how-to-format-usb-drive-with-ntfs/. Ubuntu users should know that this OS already runs in optimized for performance mode.

Router settings for TATA Indicom Broadband connection.

I have a Netgear ADSL Wifi router. The router provided to me by TATA Indicom was below par so I decided to use my router. Below are the settings you need to configure your router. Note that you need a router with ADSL modem (like my Netgear DG834G).

Multiplexing method: LLC-Based
DSL Mode: ADSL2+
VPI: 0
VCI: 32
Encapsulation: PPPoE (Point to Point Protocol over Ethernet)
Login: (e.g. chitran@vsnl.com, check the receipt given to you for your email ID)
Password: (default is reset123)
That’s it. These the critical values you need. Particularly if you set VPI and VCI values to anything but the ones listed above then you will not be able to connect to the net.
Happy surfing!
PS: If your plan provides static IP address then chances are that you will be using completely different protocol, e.g. maybe MER (MAC Encapsulated Routing) instead of PPPoE. In that case the above giude is not useful for you.

Asynchronously call a remote web page without the complexity of AJAX

Let me first give me my scenario where I needed such a thing, so that it may clear what I mean by the title of this post.

Scenario:-
For a J2EE Online Library project of mine I needed to display a list of books that can be issued. Each book’s entry had a corresponding check box which when clicked by the user is added to the cart of the user. Now the list of items in cart is kept at server side which meant that I have to call a JSP page or a servlet from the client side without actually navigating to that page. This is usually accomplished using AJAX, which is not a trivial task. Hence, I devised simple trick.

The Trick:-
I thought if somehow I could load the called page into an iframe rather than the whole window then that will solve my problem, and it worked! Then make the iframe hidden. Below is the code snippet.

License: GNU Public License version 3.

Code:

[code lang=”html”]
<html>
<pre id="codebox-pseudo-ajax"><code>  <head>
    <title>Pseudo AJAX call trick by AppleGrew</title>
    <script type=’text/javascript’>
        function callUpdate(chkbox) {
                <strong>frames[‘proxy’].location.href = ‘ServletController?pg=updateCart&itemId=’ + chkbox.value + "&chosen=" + chkbox.checked;</strong>
                //alert(frames[‘proxy’].document.body.innerHTML); //Use to retrieve the value returned by ServletController.
        }
        </script>
  </head>
  <body>
            <br/>
            <br/>
            <br/>
            <br/>
            <br/>
            <center>
            <input name="itemId" type="checkbox" value="1" <strong>onclick="javascript:callUpdate(this);"</strong> /> Item1<br/>
            <br/>
            <input name="itemId" type="checkbox" value="2" <strong>onclick="javascript:callUpdate(this);"</strong> /> Item2<br/>
            </center>
           
           
            <!–The purpose of this iframe is to imitate a sort of AJAX call. The javascript calls the ServletController and
            the loaded page is loaded into this iframe w/o replacing the current page –>
            <strong><iframe id="proxy" name="proxy" style="display:none;"></iframe></strong>
  </body>
</html></code>[/code]

Where ServletController is the servelt controller of your project or just any other page. Note that if you need to retrieve any value returned from ServletController then it must return generated page as below.

<html>
<head></head>
<body>Put the value to be returned here.</body>
</html>

Using Airtel Edge/GPRS Micromax MMX 610U USB device to surf the internet from Linux

This has been a major headache for me to reboot to Windows just to surf my net, and to update my Linux machine I had to forward the internet connection from a Windows computer to my Linux machine. None-the-less I eventually managed to make it work to day. 🙂

Note that I managed to make it work, and I provide no guarantee that it will work on your computer, but I will share my computer’s configuration so that it may help you.

So, first my computer’s configuration. I have Kubuntu Hardy Heron installed (8.04). My current kernel is 2.6.24-19-generic (installed from the official Ubuntu server). Mine is a 32-bit system. The USB modem I have is Micromax MMX 610U.

Now the steps to setup your USB modem:-

  1. Plug-in your USB modem. A green light will start blinking. If the light is blue then you have PIN set and I have no idea how to enter PIN code from Linux. In that case, reboot to Windows and from the provided Airtel’s software enter the PIN code and reboot to Linux or disable the PIN altogether.
  2. Now run the command lsusb in the console the output will be like as below.Bus 005 Device 003: ID 0d49:7410 Maxtor
    Bus 005 Device 001: ID 0000:0000
    Bus 004 Device 001: ID 0000:0000
    Bus 003 Device 002: ID 046d:c016 Logitech, Inc. M-UV69a Optical Wheel Mouse
    Bus 003 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
    Bus 001 Device 004: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
    Bus 001 Device 001: ID 0000:0000

    An Important Note:-
    As I have found out that hot plugging of this USB modem doesn’t work. The modem will be detected by the kernel but for some reason wvdial won’t be able to locate the modem, hence, when you insert the modem into your USB drive then reboot your computer (or plug it in before turning on your computer).

    Note the bolded text above. That’s your modem.

  3. Now run sudo wvdialconf. This will create the file /etc/wvdial.conf with some of the necessary values.
  4. Now whatever values the file /etc/wvdial.conf keep that as such except for the ones shown below. If any settings shown below already existed then replace that with the ones below, if they didn’t exist then just add them to the file, but they must appear below the line [Dialer Defaults]. Note that will need to open the file /etc/wvdial.conf as a root. Try using sudo nano /etc/wvdial.conf.Init1 = AT+CGDCONT=1,”IP”,”airtelgprs.com”,””,0,0
    Baud = 460800
    stupid mode = 1
    Phone = *99#
    Password = a
    ;No need to change this to anything else. This is immaterial, and note that no semicolon before Password =.
    Username = a ;No need to change this to anything else. This is immaterial, and note that no semicolon before Username =.
  5. Now create a file connAir in your home directory. Copy and paste the following code into it and give it execute permission.
    [code lang=”bash”]#!/bin/bash
    # BY AppleGrew @ http://blog.applegrew.com (All rigths
    # reserved)

    pid=`pgrep wvdial`
    if [ -z $pid ]
    then

    sudo route del default
    echo "CONNECTING TO Airtel…"
    wvdial &

    sleep 10s

    IP=`ifconfig ppp0|grep -o  ‘inet addr:\([.0-9]*\)’`
    IP=`echo $IP|sed  ‘s/inet addr:\([.0-9]*\)/\1/g’`
    echo "YOUR CURRENT IP IS ‘$IP’".
    if [ -z $IP ]
    then
    echo "CONNECTION TO Airtel TIMED-OUT…….. : ("
    else
    echo "CONNECTED TO Airtel. : )"
    fi
    sudo route add default gw $IP

    else
    echo "A CONNECTION IS ALREADY IN PROGRESS."
    fi[/code]

  6. Now create another file disconnAir in your home directory. Copy and paste the following code into it and give it execute permission.
    [code lang=”bash”]#!/bin/bash
    # BY AppleGrew @ http://blog.applegrew.com (All rigths
    # reserved)

    pid=`pgrep wvdial`
    if [ -z $pid ]
    then
    echo "NO CONNECTION IN PROGRESS."
    else
    echo "DISCONECTTING FROM Airtel…"
    kill -INT $pid

    sleep 6s
    pid=`pgrep wvdial`
    if [ -z $pid ]
    then
    echo "DISCONNECTED."
    else
    echo "DISCONNECTION MAY HAVE FAILED."
    fi
    fi[/code]

Connecting to Airtel:-

  1. Open console and type ./connAir.

Disconnecting from Airtel:-

  1. Open console and type ./disconnAir.

Hope this helps.

Find the number of lines of code your project has.

After completing a big and satisfying project you may want to collect various stats about your project. One of them is the total number of lines of code your project has. As with all big projects it will probably have large number of files tucked into various directories and sub-directories and sub-sub-directories,…. you get the idea; this is very tedious to do manually.

In Linux you have a cool trick to do just that! Run the following in the directory with contains your source code.

find . -type f -exec cat ‘{}’ \;|wc -l

If the directory also contains files other than the source code, e.g. .class files along with .java files, then you can ask find to choose files with a particular pattern using the following command

find . -type f -iname “*.java” -exec cat ‘{}’ \;|wc -l

The above command will choose only .java files.