Programming
Fri
22
Jan
2010
Wordpress to Drupal
by VyomaI know I have not posted at KalaaLog.com for quite a long time (a little more than a year). The reason for this, is not the subject matter of this post. The things that I started to ponder when I was upgrading the Wordpress installation is the subject matter.
Mon
11
May
2009
C++ vs Java
by VyomaThose who have been following me on twitter, would have realized that I have started to dabble in C++ recenlty. Those who know me personally, would know that I did quite a bit of my programming antics in that language. It is only for the past couple of years that I had gotten involved into Java.
Not to say that I have quit Java, but I find it quite refreshing to work in C++ again. There are some new constructs and features that the language is providing since I stopped working on it. Moreover, it seems like there are lot more standardization effort that has taken place.
Here are some to and fro articles in terms of Java and C++:
- The Java is Faster than C++ and C++ Sucks Unbiased Benchmark
- 'The Java Faster than C++' Benchmark Revisited
- The Java (not really) Faster than C++ Benchmark
I am not really sure of the credibility of these authors, so please do your research before taking them as facts.
Speaking of C++, I do feel obligated to link to the Bjarne Stroustrup - the designer and implementor of C++.
Mon
02
Feb
2009
deviantART Embed - Drupal Module - Beta Release 2
by VyomaThe deviantART Embed Drupal module version 1.0-beta2 is released.
In terms of user features, there is nothing new. But in terms of going the Drupal way, a major overhaul has been done on the module.
The dependancy list now includes the CCK, Embedded Media Field and Views modules. The project itself is split into two modules: deviantART Embed, and deviantART blocks.

This project is mainly the glue between core Drupal and the other reliable contributed modules. In fact, all the current features of deviantART module can be installing and enabling these dependent modules and manually configuring them. The module aims at providing the 'out of the box' experience in terms of integration with deviantART.com with a Drupal powered website.
The 6.x-1.0-beta2 release is usable, and I would release the final 1.0 version after some feedback.
The next item on my TODO list for this project is to provide user account association with a deviantART account.
Tue
02
Dec
2008
On Ubuntu and Eclipse
by VyomaI have been working on C++ again after a break of more than two years, and I found that Eclipse can be a good tool to do so. I have learned to get myself to be more productive in Java projects, but translating that knowledge to developing C++ in Eclipse requires at least Eclipse Europa - it is for me of course, because I have gotten used to that simultaneous release of Eclipse at work.
Sadly, Eclipse is at a older version - Callisto - in Ubuntu, even after the latest upgrade to the distribution itself - Ubuntu Intrepid Ibex.
Being open source, it lets me dig quite deep to find the status on this project:
It is actually nothing new for me - at my day job, I deal with a lot of proprietary tools, and support - even when paid for - is quite flaky. At least, here I get some transparency.
Going through the Debian bug does give a bleak feel on the situation. Now, I have a choice:
- Live with it.

- Live with an encumbered process of installing it myself and maintain it - but I am quite addicted to Synaptic Package Manager (read it as I am lazy).
- Dual boot (triple boot) to Fedora 10
- Help those maintainers to package Eclipse into Ubuntu/Debian repositories
I am not keen on option two. I might try out option three sometime. Since I am at the moment so fond of Ubuntu, I should be going for option four - but I do not know where to begin with to package an application and create a deb. I think I should start learning about it, so I guess I will be choosing option one for a while. 
Sun
24
Aug
2008
SQLite - Amalgamated Size
by VyomaIn my earlier post (SQLite - Embedable Database), I mentioned that a SQLite program takes about 26kB. This is not entirely true, since I think I had forgotten the exact nature of the linker.
The excutable program that resulted when I compiled and linked the test program, I had to use the -lsqlite3. The library resided in my system, and I am not sure if it was packaged into the resulting executable object. To check how much SQLite really took in terms of space, I got the SQLite3 Amalgamated source code, got the sqlite3.c and sqlite3.h into the test project and recompiled it.
The resulting program is 938779 bytes (~917kB), still less than 1MB. Not sure if I can calculate this way, but the SQLite3 takes about 891kB when embedded into a program. I think it also depends on the compiling and linking environment, but I am not sure of that.
Sun
24
Aug
2008
SQLite - Embedable Database
by VyomaA must visit site for all the C/C++ programmers out there: SQLite.org
From their homepage:
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
I just fired up Eclipse (with CDT plugins), copied one of the example C programs, and I could create database and run SQL queries against them in a jiffy. Agreed that running Ubuntu made getting the SQLite3 development libraries easy. But it should be almost as easy in getting the libraries installed from their downloads seciton.
The example program I compiled is just 26577 bytes (~ 26 kB) and I can pass along large subset of SQL commands to it along with the database filename. (Update: See SQLite - Amalgamated size for more information)
If you need a robust database for your application, but cannot opt for larger databases, SQLite is the answer. And best of all, it is in public domain - you are free to use if for any purpose.
Wed
06
Aug
2008
Splitting tokens from delimited string in Java
by VyomaNeed to get a particular field from a pipe delimited string in Java?
Say you have a string like "alpha|beta|gamma|delta" and want the third token. Here is how you do it in Java.
Code
public class StringSplit {
public static void main(String[] args) {
String inputString = "alpha|beta|gamma|delta";
System.out.println("Input String: \n" + inputString);
System.out.println("Splitting...");
// Here is the core - replace the regex with
// whatever delimiter you have. Since '|' is
// a special character in regular expression,
// we need to escape it.
String tokens[] = inputString.split("\\|");
int numTokens = tokens.length;
System.out.println("Number of tokens: " + numTokens);
for (int i = 0; i < numTokens; i++) {
System.out.println("[" + i + "] " + tokens[i]);
}
// 3rd field?
System.out.println("Third field: " + tokens[2]);
System.out.println("...done!");
}
}
Output
Input String:
alpha|beta|gamma|delta
Splitting...
Number of tokens: 4
[0] alpha
[1] beta
[2] gamma
[3] delta
Third field: gamma
...done!
The delimiter in this example is the pipe (|) character. It can be any character or set of characters - just pass it to the String.split() method as a regular expression.
Wed
16
Jul
2008
JAXB not generating setter method for Lists
by VyomaFew days back, I had been working with JAXB 2.0 to marshall some objects into XML. That was when I realized that JAXB did not generate setter methods for lists in the members (which was the result of having unbounded elements).
After being frustrated about it, and a little searchinga round, I was able to figure it out.
Even though the solution is small, explaining it ended up being a relatively large article. Hence, I posted it at WiseTome.com: JAXB - Handling Lists in Generated Proxy Classes
Mon
07
Jul
2008
Eclipse Plugin development articles
by VyomaI came across some good articles on Eclipse Plugin development at ONJava.com:
Thu
20
Mar
2008
PERL Script To Find How Many Seconds Back Was A File Updated
by VyomaA lot of times in Unix, you would want to find out how many seconds (or minutes, or hours) back a particular file was updated. You would want to do it for several reasons - find out the last time some configuration file was changed, or may to track some update done by a different system, or anything that fancies your mind.
Though the script can be written as a Unix shell script, I found it a bit cumbersome. Moreover, the PERL solution was much more flexible, elegant and readable.
So, here is the PERL script that calculates the time period between the modified date of a file, and the system date.
#!/usr/bin/env perl use File::stat; # Declare variables my $filename; my $FILE_HANDLE; my $file_stat; my $current_time; my $diff_seconds; $filename = '/path/of/file/filename.ext'; # Open the file open ($FILE_HANDLE, $filename) or die "Can't open $filename!"; # Get the file status structure $file_stat = stat($FILE_HANDLE); # Get the current time $current_time = time; # Get the elapsed time in seconds $diff_seconds = time - $file_stat->mtime; # Do whatever you want with the $diff_seconds print "\n$filename was modified $diff_seconds seconds back.\n"; # All done
Note:
- Instead of the $file_stat->mtime, you can use $file_stat->ctime to get the time from creation of the file.
- To get the elapsed time in minutes, divide $diff_seconds by 60. For hours, divide by 3600. And so on.