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
Wednesday, December 22, 2010
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 underlyingFile
object deleted.
*/
private boolean isDeleted;
/**
* Creates a fileInputStream wrapped around the given file and deletes the
* file when theFileInputStream
is 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 underlyingFileInputStream
and 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.
Subscribe to:
Posts (Atom)