Backup your backups
February 12th, 2010
Yes, that is the lesson I learned after my recent 1 TB external hard drive crash. I bought this Seagate FreeAgent Pro external drive couple of years back thinking that I am buying "peace of mind" for my personal data storage & backups. I guess I was totally wrong. Lately I started seeing some hiccups on this drive and it finally crashed with bad sectors.
I have 5 years warranty on this drive. I called the manufacturer and talked to them about my case. They are ready to replace the drive, obviously not the data. So, what is gonna happen to my almost 1 TB worth of data? I started looking up online to see how I can rescue data from this drive. I tried many of Windows & Linux based tools. But, none of them helped me recover any data at all. I guess, the drive is damaged heavily and none of the recovery tools could do any good.
Here are some of the things to consider...
If I am going to have a backup/external drive, I would go for RAID based drives, preferably with RAID 1 or RAID 5 settings. And, I need to pro-actively perform periodic health checks on the external drives just to make sure its not gonna have heart attack or brain damage soon. May be it's not a good idea to go for a huge capacity like >= 2 TB in a single drive, because of limitations on hardware storage machanism working within a confined physical limits.
In this digital world of inexpensive electronics & technologies, we trust so much on them in our day to day life. At some point in time, what we have in those are worth much more than 1's and 0's to us, personally.
Let's do some command line JavaScripting...
January 11th, 2010
I know JavaScript is a client side browser-buddy language. But, just for kicks I wanted to try out JavaScript on command line. Here is the story...
I was working on a codebase in Windows machine where we have very very long file names. As you may know, Windows XP don't support file names longer than 260 characters. It was very annoying when a maven build fails due to the file name length limitation. So, I wanted to write a script which can recursively loop through the project codebase and list out the files which exceeds certain length limit, so I can work on shortening their names. I could write that script in different ways like batch script, shell script, groovy script etc. But, I just wanted to write it in plain simple JavaScript and see how it plays.
If you want to try out the script. Copy the following code block in a JS file (For ex. FileNameLengthChecker.js).
/*
Simple utility script to look for file names exceeding certain length restriction.
(esp. for Windows XP - http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx#maxpath).
If you want to run check for a folder other than the current folder, change the value of
rootDir variable.
*/
var filenameLengthThreshold = 260;
var headerPrinted = false;
var totalFilesFound = 0;
function runFileNameLengthCheck() {
var rootDir = new java.io.File(".");
echo("Checking file name length check in '" + rootDir.getCanonicalPath() + "' for threshold limit = " + filenameLengthThreshold + " ...");
checkFilePathRecursively(rootDir);
if (!headerPrinted) {
echo("\n----------------------------------------------------");
echo("No files found with the given threshold limit !!!");
echo("---------------------------------------------------");
}
else {
echo("Total files found = " + totalFilesFound);
}
}
function printHeader() {
if (!headerPrinted) {
echo("\n------------------------------------------------");
echo("Following files exceeded the file name length check...");
echo("------------------------------------------------");
headerPrinted = true;
}
}
function checkFilePathRecursively(currentFolder) {
var files = currentFolder.listFiles();
for (var i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
checkFilePathRecursively(files[i])
}
else {
var path = files[i].getCanonicalPath();
if (path.length() > filenameLengthThreshold) {
printHeader();
echo("Filename = '" + path + "', length = " + new java.lang.Integer(path.length()));
totalFilesFound++;
}
}
}
}
runFileNameLengthCheck();
The simplest way to run the script file from a command line is through jrunscript tool bundled within JDK.
C:\ProjectCodeBase\jrunscript FileNameLengthChecker.js
If you use IntelliJ IDE and Script Monkey plugin installed, you can directly run the script from IDE.
This is just a trivial example, but the possibilities of what we can do using the same technique is endless. Thoughts? Comments?
Why Open-source software?
December 23rd, 2009
If you are an open-source fan like myself, then you will love this awesome article - The meaning of open
Often times, I tend to have heated discussions with my friends & colleagues regarding open-source software and how it changed the software development industry & information technology overall. I try explaining the evolution & significance of open-source community, standards & software and without which we wouldn't have been in a place, where we are in the information technology today. There are tons of examples to quote ranging from Linux, Apache, Java etc. etc.
But, unfortunately not every big companies realise the importance of open-source sofware, atleast not from a giving-end perspective. It's a cliche to say that every companies will be using open-source software either directly or indirectly. But, how many of them would be actively participating or contributing to the open-source community. I think that should grow.
Open source is not altruism, it is a culture to drive innovation and promote better competition. I am glad that article discusses breadth & depth of open-source both from technical & business perspective.
Script Monkey - IntelliJ plugin contest winner
February 4th, 2009
I am very excited to announce that Script Monkey won this years IntelliJ plugin contest. JetBrains had selected Script Monkey IntelliJ plugin as a honorable mention winner, which technically means third place in the contest.
Script Monkey, a Java plugin paradigm shift...
November 12th, 2008
I am pleased to announce the release of Script Monkey. It's a Java based open-source plugin/tool/framework aimed to take Java to the next level by ahieving the power & flexibilities of interpreted/dynamic languages. Currently, it is available as IntelliJ plugin. Hopefully in the near future, I like to bring in more flavors of this tool.
I am not going to discuss the pros & cons of compiled vs. dynamic languages. Because, you may have already came across tons of articles discussing that. The key point which I would like to highlight in this article is how Script Monkey shifts the paradigm of Java plugin architecture.
Well, we all know what plugins are. Almost, every software products whether it's browser, IDE or consumer app that is released in the market today would have some form of plugin/addon support. Plugins help the software tool to be expandable, customizable or tailorable for a niche user.
Alright, let's get to the real meat of this article and discuss some underlying implementation that can help make my case. In good old days, the way we write plugins, whether it's for Eclipse, IntelliJ or Netbeans is by creating a metadata/manifest file (maybe some .xml configs) that would contain the specifics of classes(controllers,actions etc.) involved and the plugins would be coded against the Plugin API (IntelliJ has something called OpenAPI. Eclipse & Netbeans have some similar API's as well) provided by the tool. If you think abt it, there are lots of boiler plate code involved in running every plugin. Like, the code used to load, unload, assign or delegate actions to the plugins. The most important of all is that the plugin is kind off closed. If you want to perform a slight variation in what a plugin is doing, then you need to checkout it's source (if it's open-source), make changes to the code, recompile and deploy it to wherever it's supposed to go. In my opinion, one of the key reason why dynamic languages are pretty useful is because of not needing to write these kind of boiler plate code and the ability to perform lot of things during runtime. And, that is the exact same reason why Java has Scripting API & tools like Rhino, Jython, JRuby etc. are created for.
With that introduction, what Script Monkey is trying to offer is, we don't need to write plugins for every small feature or functionality we are looking for. We can have one plugin, which is Script Monkey at the center and for every feature we need, we can get it done with the help of "plugin-scripts"(simple Javascript, ruby or python code) at runtime. The plugin-scripts doesn't always need to make just Plugin API call, it can also do things specific to projects we are working on, like cleaning up temp files, backing up the folder or auto checking in to CVS etc. I am not saying Script Monkey will replace every plugin we use in a tool, there may be complex features/functionalities, which is better off to be a plugin on it's own than to be plugin-scripts.
Another important thing I want to stress here is, the tool we are using, whether its Eclipse, IntelliJ or Netbeans, already has millions of lines of code running inside. If the API is designed well, we should be able to exploit/invoke the methods we need at runtime. Which in other words, code re-usability in steroids :).
Obviously, I didn't want to overload too much details on Script Monkey in one article. Hopefully in my future articles, I'll discuss more on other aspects of this tool as well.
Like I said before, currently it is available only as IntelliJ plugin. With the help of open-source community, I have confidence that I will be able to take it to Eclipse,Netbeans etc. users as well.
Thought, comments, questions?
