Monday, November 28, 2011
Monday, September 19, 2011
TIP: How to save images from Facebook gallery
In Facebook, while browsing shared photos of your friends, if you like some photos and want to save them to your computer you would normally e.g. in Firefox (FF), right click on the image and use Save As option. But this does not work as expected. You do not see an option to save the image only. This happens because the image is "hidden" behind script which loads it. To overcome this, do the following steps:
1) Right click on the image
2) Use inspect element(opens a little window area at the bottom with the html source)
3) Look for tag <img src="xxx"/> xxx is the url of the image.
4) Copy and paste xxx in the address bar of FF and load page.
5) Now right click and save image on your disk.
Note: this tip might work for other sites too which use similar gallery features to display images.
1) Right click on the image
2) Use inspect element(opens a little window area at the bottom with the html source)
3) Look for tag <img src="xxx"/> xxx is the url of the image.
4) Copy and paste xxx in the address bar of FF and load page.
5) Now right click and save image on your disk.
Note: this tip might work for other sites too which use similar gallery features to display images.
Thursday, September 15, 2011
Finally, DLNA at Home !
DLNA stands for Digital Living Network Alliance. In a nutshell, it is like running a small network and sharing data (video, audio, pictures etc) between different devices (TV, Computer, Game console, video player etc) at your home through this network. Minimum you need a TV (display unit) and a media server (e.g. a computer running some DLNA software). No problem if the TV is not DLNA compatible. You can add a DLNA compatibe player like DVD/Blueray player connect same to the TV.
DLNA is almost 7-8 years old but the technology has become popular (and affordable) now. At my home, I've been adding up components for a DLNA home for over a year now. I have following things now:
1) Linksys E3000 wifi router (N+ with MIMO)
2) 42" LG Infinia LED HD TV (non DLNA)
3) Sony PS3 game console and Sony BDP S-370 Blueray player (both are DLNA players)
4) Acer laptop running Windows 7 Home premum (DLNA server)
5) 320 GB Buffalo USB 2.0 for storage (upgrading soon to 1TB Western Digital USB3.0)
Setup and execution
1) Start Linksys router (ensure UPnP is enabled)
2) Start computer and enable media streaming
3) Switch on TV
4) Switch on PS3 (or player) and configure to use DLNA
5) Choose DLNA Media Server option in PS3 XMB
6) The name of the computer (DLNA server) is shown select it and use further online options to view media. See the picture below.
That's all for a basic DLNA at home. I was able to play some MP3 and view pictures (average size 3MB) without much problem. However, video display was breaking frames. Probably because PS3 uses only b/g and was not able to exploit higher WiFi capacity of N+ network. Also, the concrete walls and other radio in my house is probably interfering with WiFi waves.
DLNA is almost 7-8 years old but the technology has become popular (and affordable) now. At my home, I've been adding up components for a DLNA home for over a year now. I have following things now:
1) Linksys E3000 wifi router (N+ with MIMO)
2) 42" LG Infinia LED HD TV (non DLNA)
3) Sony PS3 game console and Sony BDP S-370 Blueray player (both are DLNA players)
4) Acer laptop running Windows 7 Home premum (DLNA server)
5) 320 GB Buffalo USB 2.0 for storage (upgrading soon to 1TB Western Digital USB3.0)
Setup and execution
1) Start Linksys router (ensure UPnP is enabled)
2) Start computer and enable media streaming
3) Switch on TV
4) Switch on PS3 (or player) and configure to use DLNA
5) Choose DLNA Media Server option in PS3 XMB
6) The name of the computer (DLNA server) is shown select it and use further online options to view media. See the picture below.
That's all for a basic DLNA at home. I was able to play some MP3 and view pictures (average size 3MB) without much problem. However, video display was breaking frames. Probably because PS3 uses only b/g and was not able to exploit higher WiFi capacity of N+ network. Also, the concrete walls and other radio in my house is probably interfering with WiFi waves.
Windows 7 Media Server in PS3 XMB.
Friday, September 02, 2011
Programming verbiage
Which is a better style?
Style 1:
boolean checkNum(int x) {
if (x > 10) {
return true;
}
else { // actually else {} is unnecessary
return false;
}
}
Style 2:
boolean checkNum(int x) {
return (x > 10);
}
Though I find style 1 more often, specially in the code written by rookies, I prefer style 2. It is short and crisp.
Style 1:
boolean checkNum(int x) {
if (x > 10) {
return true;
}
else { // actually else {} is unnecessary
return false;
}
}
Style 2:
boolean checkNum(int x) {
return (x > 10);
}
Though I find style 1 more often, specially in the code written by rookies, I prefer style 2. It is short and crisp.
Monday, August 22, 2011
Efficiency of EMS Speed Post by Indiapost
My daughter sent rakhi to her little cousins in my native town at Laheriasarai (Darbhanga) in Bihar on 4th, August 2011. The parcel was finally delivered on 20th, August 2011. It took two weeks for "speed post". Wonder how much would it take for an ordinary post? I do not understand the route log above, however, it appears very amusing to me:: Pune -> Mumbai -> Pune -> Patna -> Muzaffarpur -> Kishanganj ->Patna -> Darbhanga/LHR.
Sunday, April 10, 2011
Sweet child of mine
Reviving this old genset was daunting without proper tools and spares. However, Dhruv was cheering with gusto... waiting for him to grow up and share the wrench :)
Wednesday, December 22, 2010
Love the wikipedia
Dear Bimalesh,
Thank you for your gift of USD xxx to the Wikimedia Foundation, received on December 22, 2010. I’m very grateful for your support.
Your donation celebrates everything Wikipedia and its sister sites stand for: the power of information to help people live better lives, and the importance of sharing, freedom, learning and discovery. Thank you so much for helping to keep these projects freely available for their more than 400 million monthly readers around the world.
Your money supports technology and people. The Wikimedia Foundation develops and improves the technology behind Wikipedia and nine other projects, and sustains the infrastructure that keeps them up and running. The Foundation has a staff of about fifty, which provides technical, administrative, legal and outreach support for the global community of volunteers who write and edit Wikipedia.
Many people love Wikipedia, but a surprising number don't know it's run by a non-profit. Please help us spread the word by telling a few of your friends.
And again, thank you for supporting free knowledge.
Sincerely Yours,
Sue Gardner
Executive Director
Thank you for your gift of USD xxx to the Wikimedia Foundation, received on December 22, 2010. I’m very grateful for your support.
Your donation celebrates everything Wikipedia and its sister sites stand for: the power of information to help people live better lives, and the importance of sharing, freedom, learning and discovery. Thank you so much for helping to keep these projects freely available for their more than 400 million monthly readers around the world.
Your money supports technology and people. The Wikimedia Foundation develops and improves the technology behind Wikipedia and nine other projects, and sustains the infrastructure that keeps them up and running. The Foundation has a staff of about fifty, which provides technical, administrative, legal and outreach support for the global community of volunteers who write and edit Wikipedia.
Many people love Wikipedia, but a surprising number don't know it's run by a non-profit. Please help us spread the word by telling a few of your friends.
And again, thank you for supporting free knowledge.
Sincerely Yours,
Sue Gardner
Executive Director
Wednesday, December 08, 2010
Memory leak in Firefox 3.6.12
Why is Firefox eating up so much memory and after sometime it becomes virtually unresponsive. Look at the memory footprint at startup:

And, memory usage after running a while (opened about 5 tabs). At this stage, it became unresponsive too :-(

My Firefox version:

Many people have reported this issue, but, no solution yet?
And, memory usage after running a while (opened about 5 tabs). At this stage, it became unresponsive too :-(
My Firefox version:
Many people have reported this issue, but, no solution yet?
Wednesday, November 24, 2010
Upgrade JPivot 1.8 to Mondrian 3.3.x
Like me, if you are stuck with last (old) release of Jpivot 1.8 with embedded Mondrian version 3.0 and want to upgrade to latest Mondrian (community version) release 3.3.x then, I have a solution. JPivot sourceforge site is not uptodate with the Mondrian ROLAP engine and there are several bugs which have been fixed in latest release of Mondrian.
In my environment (Struts 1.2, JBoss 4.x, Tomcat 5.x) simply replacing the mondrian.jar with latest jar library from Mondrian Sourceforge project does not work. It fails with several ClassNotFoundException and/or NoSuchMethodError during runtime. Here is what I did and it worked fine:
5. Replace the jpivot.jar inside the expanded mondrian/lib directory with the jpivot.jar created above
6. Copy all the jar files in the lib directory (including new jpivot.jar) to your deployment location. Voila, you have upgraded JPivot 1.8 to the latest mondrian (3.3) release.
Enjoy!
In my environment (Struts 1.2, JBoss 4.x, Tomcat 5.x) simply replacing the mondrian.jar with latest jar library from Mondrian Sourceforge project does not work. It fails with several ClassNotFoundException and/or NoSuchMethodError during runtime. Here is what I did and it worked fine:
- Download latest Mondrian distribution
- Expand the dowloaded jar archive
- Navigate to WEB-INF/classes in the expanded location
- Create jpivot.jar from classes inside WEB-INF/classes directory e.g. using jar command line tool as shown below. Run this command inside WEB-INF/classes directory.
- jar cvfz jpivot.jar com/*
5. Replace the jpivot.jar inside the expanded mondrian/lib directory with the jpivot.jar created above
6. Copy all the jar files in the lib directory (including new jpivot.jar) to your deployment location. Voila, you have upgraded JPivot 1.8 to the latest mondrian (3.3) release.
Enjoy!
Sunday, September 12, 2010
Friday, September 03, 2010
JPivot/Mondrian + Struts 1.x file upload issue
After we integrated JPivot (front-end for Mondrian) library in one of our Struts 1.x based web application, all file uploads working fine so far, started to fail with NullPointerException (NPE). JPivot request filter is configured to intercept all requests for action (e.g. *.do). I could not find direct discussion about this issue on Google.
After debugging for few hours myself, noticed that JPivot RequestFilter intercepts and consumes the HTTP multipart request stream through a MultipartEnabledRequest wrapper even before it reaches Struts controller. Therefore FormFile object is null in FormBean.
The simple solution that worked was to extend the JPivot RequestFilter class and override doFilter(), something like shown below and use this custom filter in place of default JPivot RequestFilter.
...
import com.tonbeller.wcf.controller.RequestFilter;
/**
* This extension modifies default behavior of JPivot controller for file uploads
* (multipart requests) . It allows Struts layer to handle such requests rather
* than processing itself.
*
* @author bjha
*/
public class MyJpivotFilter extends RequestFilter {
@Override
public final void doFilter(
ServletRequest req,
ServletResponse res,
FilterChain fc) throws IOException, ServletException {
if( isMultipartRequest( req ) ){
//let Struts handle upload
fc.doFilter(req, res);
return;
}
super.doFilter(req, res, fc);
}
static boolean isMultipartRequest(ServletRequest req) {
if (req instanceof HttpServletRequest) {
String reqMethod = ((HttpServletRequest) req).getMethod();
if ( reqMethod != null
&&
"post".equals(reqMethod.toLowerCase())) {
String content = req.getContentType();
return (
content != null
&&
content.toLowerCase().contains("multipart/form-data"));
}
}
return false;
}
}
Another option that could work would be to configure JPivot RequestFilter not to intercept requests for upload URIs via web.xml or use commons-fileupload library to handle uploads.
After debugging for few hours myself, noticed that JPivot RequestFilter intercepts and consumes the HTTP multipart request stream through a MultipartEnabledRequest wrapper even before it reaches Struts controller. Therefore FormFile object is null in FormBean.
The simple solution that worked was to extend the JPivot RequestFilter class and override doFilter(), something like shown below and use this custom filter in place of default JPivot RequestFilter.
...
import com.tonbeller.wcf.controller.RequestFilter;
/**
* This extension modifies default behavior of JPivot controller for file uploads
* (multipart requests) . It allows Struts layer to handle such requests rather
* than processing itself.
*
* @author bjha
*/
public class MyJpivotFilter extends RequestFilter {
@Override
public final void doFilter(
ServletRequest req,
ServletResponse res,
FilterChain fc) throws IOException, ServletException {
if( isMultipartRequest( req ) ){
//let Struts handle upload
fc.doFilter(req, res);
return;
}
super.doFilter(req, res, fc);
}
static boolean isMultipartRequest(ServletRequest req) {
if (req instanceof HttpServletRequest) {
String reqMethod = ((HttpServletRequest) req).getMethod();
if ( reqMethod != null
&&
"post".equals(reqMethod.toLowerCase())) {
String content = req.getContentType();
return (
content != null
&&
content.toLowerCase().contains("multipart/form-data"));
}
}
return false;
}
}
Another option that could work would be to configure JPivot RequestFilter not to intercept requests for upload URIs via web.xml or use commons-fileupload library to handle uploads.
Friday, July 02, 2010
Google Search service + Firefox + Adblock Plus plugin
Some websites use customized Google search (powered by Google etc) on their pages. If you try to access search service on such sites using Mozilla Firefox having Adblock Plus plugin (ABP) installed, then sometimes you will not get proper searched results or it may return a blank page. This is because ABP blocks the (third party) Google scripts from loading on the page. To overcome that, you will have to "white-list" such scripts in ABP. Checkout this post for more on this.
PS: this happens with ABP 1.2 and FF 3.6.6.
PS: this happens with ABP 1.2 and FF 3.6.6.
Sunday, May 16, 2010
Help Aashi
This is an unusual post, but very important. Given below is the excerpt of the mail from my friend Yash.
-------------------------------------------------------------------------
Lets fight the cancer- help the little girl.
-------------------------------------------------------------------------
Hey Bimalesh - here is a short writeup.
My niece Aashi is five year old living in Gurgaon, India suffering from blood cancer or Acute lymbhoblastic leukemia with CNS (Central nervous system) involvement. She has already undergone around 2 years of intensive chemotherapy but it is not helping her anymore as disease has relapsed in central nervous system. Only an Unrelated Bone Marrow Transplant (BMT) can save her life.
We have set up a website for her - http://www.helpsaveaashi.com . Details about her and her illness are on the website. Any donation from your end is very valuable. Your financial help will go towards Aashi's bone marrow transplant and treatment. Please let friends and people close to you know about this who may be interested to help.
Latest from 13th May 2010: There is a good news that doctors have found HLA typing match at NMDP. This is extremely positive. However, NMDP is going to do further screening on the donor. This news about initial match has been updated on the website and the doctors' match report will be put up in couple of days as well.
Thanks for your support. Please email me if you have any questions and/or suggestions.
We have set up a website for her - http://www.helpsaveaashi.com . Details about her and her illness are on the website. Any donation from your end is very valuable. Your financial help will go towards Aashi's bone marrow transplant and treatment. Please let friends and people close to you know about this who may be interested to help.
Latest from 13th May 2010: There is a good news that doctors have found HLA typing match at NMDP. This is extremely positive. However, NMDP is going to do further screening on the donor. This news about initial match has been updated on the website and the doctors' match report will be put up in couple of days as well.
Thanks for your support. Please email me if you have any questions and/or suggestions.
Best Regards
Yash
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Lets fight the cancer- help the little girl.
Tuesday, April 06, 2010
Values of javac @SuppressWarnings
Legal values for the annotation @SuppressWarnings are compiler dependent, except unchecked, which is required by JLS.
I could find a listing for supported values in Eclipse IDE here. However, what is supported in Sun's (now Oracle) JDK is not well published. But, a little help from Sun JDK javac divulges the supported list as shown below:
[bjha@xxx]$ uname -rsp
Linux 2.6.13.5 x86_64
[bjha@xxx]$ javac -version
javac 1.6.0_07
[bjha@xxx]$ javac -X
...
-Xlint:{all,cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides,-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides,none}Enable or disable specific warnings
...
...
These options are non-standard and subject to change without notice.
I could find a listing for supported values in Eclipse IDE here. However, what is supported in Sun's (now Oracle) JDK is not well published. But, a little help from Sun JDK javac divulges the supported list as shown below:
[bjha@xxx]$ uname -rsp
Linux 2.6.13.5 x86_64
[bjha@xxx]$ javac -version
javac 1.6.0_07
[bjha@xxx]$ javac -X
...
-Xlint:{all,cast,deprecation,divzero,empty,unchecked,fallthrough,path,serial,finally,overrides,-cast,-deprecation,-divzero,-empty,-unchecked,-fallthrough,-path,-serial,-finally,-overrides,none}Enable or disable specific warnings
...
...
These options are non-standard and subject to change without notice.
Monday, February 22, 2010
An auto-deleting FileInputStream
Sometimes, we need to read some data from a FileInputStream and, after reading it, delete the underlying file automatically by calling close(). This is not supported in java as of J2SE v1.6. However, we can achieve this by first calling close() on InputStream and then calling File.delete(). Something like:
File f = new File("c:\\xyz...");
FileInputStream fis = new FileInputStream(f);
//read from fis
...
...
fis.close();
f.delete();
Above works, but it is quite verbose, especially when we have to do this on multiple files. It becomes a chore. I present below a class which encapsulates this behavior in itself. We do not have to call f.delete() separately. Calling fis.close() will also delete the file automatically.
*** =========== ***
Here is the sample output, when this program is run:
File f = new File("c:\\xyz...");
FileInputStream fis = new FileInputStream(f);
//read from fis
...
...
fis.close();
f.delete();
Above works, but it is quite verbose, especially when we have to do this on multiple files. It becomes a chore. I present below a class which encapsulates this behavior in itself. We do not have to call f.delete() separately. Calling fis.close() will also delete the file automatically.
*** =========== ***
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* A {@link FileInputStream} which (optionally) deletes the
* underlying file when the stream is closed.
*
* @author BJ
*/
public class AutoDeleteOnCloseFileInputStream extends FileInputStream{
private static final Logger log = Logger.getAnonymousLogger();
/**
* Underlying file object
*/
private File fileObj;
/**
* Flag to control auto-delete of file on close()
*/
private final boolean deleteOnClose;
/**
* Is underlying file stream closed. Becomes true afterclose()
* is invoked.
*/
private boolean isClosed;
/**
* Was underlyingFileobject deleted.
*/
private boolean isDeleted;
/**
* Creates a fileInputStream wrapped around the given file and deletes the
* file when theFileInputStreamis closed.
*
* @param file
*
* @throws FileNotFoundException
*/
public AutoDeleteOnCloseFileInputStream(File file)
throws FileNotFoundException {
this(file, true);
}
/**
* Creates a fileInputStream wrapped around the given file.
*
* @param file
* @param deleteOnClose
*
* @throws FileNotFoundException
*/
public AutoDeleteOnCloseFileInputStream(
final File file,
final boolean deleteOnClose) throws FileNotFoundException {
super(file);
this.fileObj = file;
this.deleteOnClose = deleteOnClose;
isClosed = false;
isDeleted = false;
}
/**
* @return boolean flag, true if the file should be deleted on close().
* Default is true.
*/
public final boolean isDeleteOnClose() {
return deleteOnClose;
}
/**
* @return is file deleted (after close)
*/
public boolean isDeleted() {
return isDeleted;
}
/**
* Closes the underlyingFileInputStreamand also deletes the
* file object from disk if, theisDeleteOnClose()
* is set to true.
*
* @see java.io.FileInputStream#close()
*/
@Override
public void close() {
if( isClosed ) {
log.finer("close()- already closed: "+ this);
return; //no-op
}
log.fine("close()- closing: "+ this);
isClosed = true;
try {
super.close();
if( isDeleteOnClose() ) {
isDeleted = fileObj.delete() ;
}
}
catch (IOException e) {
log.log(Level.WARNING, "Failed to close() stream: " + this, e);
}
catch (RuntimeException e) {
log.log(Level.WARNING, "Failed to delete(): " + fileObj, e);
}
log.info("close()- file [" + fileObj + "] deleted: "+ isDeleted);
fileObj = null;
}
@Override
public String toString() {
String defaultStr = super.toString();
try {
StringBuilder sb = new StringBuilder();
sb.append(defaultStr)
.append("{")
.append("File=").append(fileObj).append(", ")
.append("File size=").append(fileObj == null ? -1L : fileObj.length()).append(", ")
.append("deleteOnClose=").append(deleteOnClose).append(", ")
.append("isClosed=").append(isClosed).append(", ")
.append("isDeleted=").append(isDeleted)
.append("}");
return sb.toString();
}
catch(RuntimeException e){
log.log(Level.INFO, "Failed to stringify", e);
return defaultStr;
}
}
//For testing. Can be removed w/o any loss of functionality
public static void main(String[] args) throws IOException {
File f =File.createTempFile("temp_file", ".tmp");
FileInputStream fis = new AutoDeleteOnCloseFileInputStream(f);
System.out.println("*** Before close: " + fis);
System.out.println("Temp file exists: "+ f.exists());
fis.close();
System.out.println("*** After close: " + fis);
System.out.println("Temp file exists: "+ f.exists());
}
}
Here is the sample output, when this program is run:
** Before close: AutoDeleteOnCloseFileInputStream@42e816{File=C:\DOCUME~1\BIMALE~1\LOCALS~1\Temp\temp_file49625.tmp, File size=0, deleteOnClose=true, isClosed=false, isDeleted=false}
Temp file exists: true
Feb 22, 2010 2:24:34 PM AutoDeleteOnCloseFileInputStream close
INFO: close()- file [C:\DOCUME~1\BIMALE~1\LOCALS~1\Temp\temp_file49625.tmp] deleted: true
*** After close: AutoDeleteOnCloseFileInputStream@42e816{File=null, File size=-1, deleteOnClose=true, isClosed=true, isDeleted=true}
Temp file exists: false
Friday, February 12, 2010
Remove trailing white-spaces in Eclipse
Often, we need to quickly remove the trailing spaces (at the end) in the line. Eclipse does not come pre-configured with a shortcut for this in (java) editor perspective (I am using Europa release 3.3.2) . However, it is very easy to create one yourself, like following:
1. On menu choose Window -> Preferences ->General ->Keys
2. Filter the shortcuts for "remove"
3. Follow the image below. I have chosen ctrl+alt+backspace as shortcut key.
That is all you need. Now, while editing any source file, just hit the combo ctrl+alt+backspace to remove the (unnecessary) white-spaces from end of lines.
1. On menu choose Window -> Preferences ->General ->Keys
2. Filter the shortcuts for "remove"
3. Follow the image below. I have chosen ctrl+alt+backspace as shortcut key.
That is all you need. Now, while editing any source file, just hit the combo ctrl+alt+backspace to remove the (unnecessary) white-spaces from end of lines.
Sunday, January 31, 2010
Added JBLs on WagonR
This is my eight year old Suzuki WagonR.

A pair of new JBLs made her sound peppier :)

Also, eliminated some rattles in the dash.
A pair of new JBLs made her sound peppier :)

Also, eliminated some rattles in the dash.
Monday, December 14, 2009
Friday, December 11, 2009
Work away from work
Did not want the accumulated leaves to lapse at the year end. Hence took few days off from work. Staying at home whole day on a week day means- I will have to spend time in the garage :). Just finished servicing the bike today. Overhauled the gear box and primary drive and also the front forks. It rides like new now. Pleased with the effort and saved about 600/- rupees that is about 12 beers :P
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
+%28Medium%29.jpg)
Subscribe to:
Posts (Atom)



