I have an old hard disk with corrupt NTFS volumes and I want to recover the data. I'm not sure how the drives got corrupt but they cannot be fixed by chkdsk /f. Fortunately, there's a plethora of open source data recovery tools available. Two such tools are foremost and photorec which specialize in combing through hard drive partitions to recover files based on header information. They can even recover files after accidental reformatting.
Foremost is a tool originally developed by the U.S. Air Force and is available via sudo apt-get install foremost. It can recover common file types such as txt, jpg, avi, and etc.. Foremost was last updated in 2008 which means that its knowledge of file headers is, at best, two years dated.
Photorec is part of the testdisk suite and is available via sudo apt-get install testdisk. Testdisk is a tool that not only "tests your disk" but also rebuilds your partition table. This is the tool to use if your hard drive's master boot record or partition table is corrupt. Photorec, like testdisk, is a poorly named command-line tool. Like foremost, photorec recovers files (not just photos) based on file headers. In fact, photorec supports more file types and is more up-to-date than foremost, which is evident by the fact that I was able to recover more files with photorec than foremost.
The problem with both foremost and photorec is that they recover file content but not file names. So you end up with directories of randomly named files with only the file extension preserved. It's not ideal but it's still better than not having the data at all.
See also:
http://help.ubuntu.com/community/DataRecovery
Saturday, June 19, 2010
Saturday, June 5, 2010
Towards a Universal VM
Alex Buckley talks the features and progress that should make the JVM the universal run-time environment for languages. Interesting discussion in the talk include:
- the distinction between the roles of the byte-code compiler and JVM compiler.
- a high-level overview of how the JVM does method inline optimizations.
- the introduction of dynamicinvoke in the new JVM.
Sunday, February 28, 2010
Ubuntu Linux on a Syntax Olevia LT30HV
The Syntax Olevia LT30HV, like many off-brand low cost LCD HDTV, does not provide accurate EDID information which prevented me from running the LCD at the native resolution 1280x768. After extensive Googling, I finally found the necessary configuration to put in my /etc/X11/xorg.conf.
1. First, make sure you have the proper Modeline in your Monitor Section:
1. First, make sure you have the proper Modeline in your Monitor Section:
Section "Monitor"2. Make sure your Screen include the Option UseEDID and ExactModeTimingsDVI like so:
Identifier "Default Monitor"
HorizSync 31.5 - 80.0
VertRefresh 56.0 - 75.0
DisplaySize 722 406
Modeline "1280x768" 79.464 1280 1360 1488 1664 768 771 778 798 -Hsync +Vsync
EndSection
Section "Screen"3. And of course, make sure you use the nvidia driver:
Identifier "Default Screen"
DefaultDepth 24
Monitor "Default Monitor"
Option "UseEDID" "false"
Option "ExactModeTimingsDVI" "true"
SubSection "Display"
Depth 24
Modes "1280x768"
EndSubSection
EndSection
Section "Device"
Identifier "Default Device"That's it.
Driver "nvidia"
Option "NoLogo" "True"
EndSection
Sunday, January 17, 2010
New features in Spring MVC 3.0
This webcast gives an overview the new features in Spring MVC 3.0. The data binding and validation has been improved dramatically. This talk is useful if you are using version 2.5 and also want a sense of good practices to follow.
Wednesday, December 30, 2009
REST-style URLs for older Java web applications using UrlRewriteFilter
Say you have an old old Java Web application that uses URLs like this:
/queryVehicles.jsp?make=Ford&model=Fusion
You want your URLs to be pretty and more RESTful like so:
/vehicles/ford/fusion
Well, you have two options. You can re-write your web application to use newer web frameworks that supports REST-style URLs such as Spring MVC 3.0, which will probably take months to do. Or you can use UrlRewriteFilter which should take no more than 30 minutes and will work with any existing Java web application.
UrlRewriteFilter very easy to use. You basically:
UrlRewriteFilter is extremely powerful. It supports regular expression pattern matching, allowing you to perform pretty complex mapping. Check out the manual page for details.
/queryVehicles.jsp?make=Ford&model=Fusion
You want your URLs to be pretty and more RESTful like so:
/vehicles/ford/fusion
Well, you have two options. You can re-write your web application to use newer web frameworks that supports REST-style URLs such as Spring MVC 3.0, which will probably take months to do. Or you can use UrlRewriteFilter which should take no more than 30 minutes and will work with any existing Java web application.
UrlRewriteFilter very easy to use. You basically:
- Add UrlRewriteFilter as a servlet filter in your WEB-INF/web.xml
- Populate WEB-INF/urlrewrite.xml with mappings of REST-style URLs to the corresponding URLs of your legacy web application (with query params and what not).
UrlRewriteFilter is extremely powerful. It supports regular expression pattern matching, allowing you to perform pretty complex mapping. Check out the manual page for details.
Monday, December 14, 2009
Remove ifs/switches from your JSPs through feature labeling
In this post, I outline a technique I call "feature labeling" as a means of organizing your web application's HTML views into features that can be selectively enabled and disabled without unmaintainable if/switch statements. I will use JSP and Spring in my example though this technique can be generalized to any view technology that allows for custom tags and any dependency injection container.
Say we are writing a prototypical blogging web application. All blogging applications give authors the ability to edit a blog entry. One straightforward way to implement this is to check if logged user is the author of the blog and then displaying the edit link to the user like so:
First, remove the if logic and replace it with the custom JSP tag "dm:feature" (to be created) like so:
Second, create a custom JSP tag that will:
Third, create your FeatureService interface and implementation. In this example, the implementation would need to be aware of the current user and the current blog so you can do the check "if current user is the blog author." Leave a comment if you want more details.
This should dramatically reduce unnecessary logic in your view and make it more testable because you are pushing the logic into a middle-tier.
Keep in mind that this only eliminates blog editing from the view. You still need to disable the controllers/services for blog editing as well. This is where Spring's Aspect Oriented Programming comes in. Here's a brief outline of what you need to do:
Helpful? Let me know.
Say we are writing a prototypical blogging web application. All blogging applications give authors the ability to edit a blog entry. One straightforward way to implement this is to check if logged user is the author of the blog and then displaying the edit link to the user like so:
Months later, say we decide that the administrator should also have the ability to edit blogs. We can add an 'or' condition to the if statement like so:<c:if test="${user == blog.author}"><a href="/blog/233/edit">Edit Blog</a> </c:if>
The good developer, however, should see that we are going down the path of littering our JSP/HTML view with too much logic, which will ultimately become harder to test and less maintainable. The "right thing" to do is to push this logic to a middle tier.<c:if test="${user == blog.author || user.role == 'admin'}"><a href="/blog/233/edit">Edit Blog</a> </c:if>
First, remove the if logic and replace it with the custom JSP tag "dm:feature" (to be created) like so:
Note the attribute name="blogEditing" which will effectively label the inside body as the blogEditing feature.<dm:feature name="blogEditing"><a href="/blog/233/edit">Edit Blog</a> </dm:feature>
Second, create a custom JSP tag that will:
- Get a FeatureService object from your Spring web application context.
- Do a featureService.isEnabled(featureName) to determine whether the body should be evaluated or skipped.
context = (ApplicationContext)pageContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,PageContext.APPLICATION_SCOPE );
Third, create your FeatureService interface and implementation. In this example, the implementation would need to be aware of the current user and the current blog so you can do the check "if current user is the blog author." Leave a comment if you want more details.
This should dramatically reduce unnecessary logic in your view and make it more testable because you are pushing the logic into a middle-tier.
Keep in mind that this only eliminates blog editing from the view. You still need to disable the controllers/services for blog editing as well. This is where Spring's Aspect Oriented Programming comes in. Here's a brief outline of what you need to do:
- Create an @Feature annotation that requires feature name (e.g., @Feature("blogEditing"). This annotation will basically label methods as being part of a feature.
- Create a FeatureAspect bean with FeatureService as a dependency.
- Create an around advice (method in the FeatureAspect bean annotated with @Around). This advice should check if the feature specified in the @Feature is enabled. If enabled, execute the method. Otherwise, throw a runtime FeatureNotEnabledException and add top-level handlers to redirect user to a 403 unauthorized page.
Helpful? Let me know.
Wednesday, December 9, 2009
Usability findings: You look where they look -- False!
I came across this article on 10 Useful Usability Findings and Guidelines. Points listed are not too surprising. However, I disagree with #2. Essentially, the author is concluding that you can increase people's attention if you have a picture with a face looking at the target text. I think the "study" lacks the proper control to warrant such conclusion.
It could be that a frontward face draws attention away from the text. In other words, the frontward face has a negative affect on attention as opposed to directional face having a positive affect. A simple control stimulus with a face looking in the opposite direction of the text would have revealed whether a directional face actually increases attention. There should have also been a control stimulus of no face or a non-face image to establish a baseline.
The author is also concluding that glances directly translates into attention. The peer-reviewed eye tracking literature have shown that while this is generally true, there are many levels of attention that must be considered. The level of attention desired by content providers is one where the user is reading and comprehending the text, in other words, a high level of attentional processing. It could be the case that a significant number of the glances are accidental or reflexive glances as a result of being steered by the directional face. One way to tease out these accidental glances is to subtract the data from the first few glances across all the images. The glances remaining would be the more intentional ones, the ones that reflect higher level processing.
This is a demonstration of the lack of rigor in non-peer reviewed studies.
It could be that a frontward face draws attention away from the text. In other words, the frontward face has a negative affect on attention as opposed to directional face having a positive affect. A simple control stimulus with a face looking in the opposite direction of the text would have revealed whether a directional face actually increases attention. There should have also been a control stimulus of no face or a non-face image to establish a baseline.
The author is also concluding that glances directly translates into attention. The peer-reviewed eye tracking literature have shown that while this is generally true, there are many levels of attention that must be considered. The level of attention desired by content providers is one where the user is reading and comprehending the text, in other words, a high level of attentional processing. It could be the case that a significant number of the glances are accidental or reflexive glances as a result of being steered by the directional face. One way to tease out these accidental glances is to subtract the data from the first few glances across all the images. The glances remaining would be the more intentional ones, the ones that reflect higher level processing.
This is a demonstration of the lack of rigor in non-peer reviewed studies.
Subscribe to:
Posts (Atom)