Sunday, January 25, 2009

NetBeans IDE Delivers For C/C++ Development

For more than a couple of years, I haven't done any serious C/C++ development work - until now. After a brief search and test of various compilers, debuggers, make utilities, and editors, I think the NetBeans 6.5 IDE delivers best in a centralized integrated environment. I also considered both the current Microsoft and Borland offerings (they are unnecessarily too huge and cost money - and these two conflict e.g. debugging with DLLs built in Turbo C++ will not work when using the MS version), CodeBlocks, and DevC++ (both are good). When I last tried the NetBeans IDE, C/C++ support was serious lacking and I was gravely disappointed.

This time around, the people at Sun have built a separate NetBeans IDE for C/C++ development. It integrates with Cygwin tools much better than I remember. It can't be easier than this.
After installing the NetBeans IDE, you only need to download the Cygwin installer and install (at a minimum) the following tools from the Devel node: binutils, gcc-core (C compiler), gcc-g++ (C++ compiler), gcc-mingw-core (MingW32 support headers/libs for GCC), gcc-mingw-c++ (MingW32 support headers/libs for C++), gdb (GNU debugger), make (GCC version of the make utility), makedepend (makefile dependency tool), and mingw-runtime.
Finally set the system environment variable "Path" to include the location of the Cygwin binaries (usually %cygwin_install_dir%\bin) and restart the NetBeans IDE. It picks up on the tools it needs, and off you go.
The memory footstamp is minimal, unlike the Java-focused NetBeans IDEs I have tried in the past. It starts up quickly and is quite intuitive and straightforward. Only bit of inconvenience is that even simple programs must be developed as part of a project. Good practice but not necessary to be enforced that way.

Friday, November 07, 2008

Yes, You Can Dump MS Outlook

When you buy a new Windows system, you will likely have Outlook Express preinstalled (I don't know anyone who uses it these days). Worse, you may feel inclined to dish out $85 for MS Office Standard 2007 (which includes MS Outlook) because the Windows office productivity space is crowded by Microsoft products. If that's all your workplace supports (because they use Exchange servers), you have no choice. But what if you could dump all that for a free email, calendar, and task management solution? It's easy and attainable.

For email, install Mozilla Thunderbird. It does everything MS Outlook does as far as sending and receiving emails, and I think perhaps a little smarter in organizing your mail, searching, and customizing. One caution: resist the temptation to import settings from other mail clients - it gets messy within Thunderbird.
You need the Lightning plugin to add task and calendaring features: download and save the .xpi, then from TB, install it using Tools | Add-ons. After TB restarts, viola! Il y a un calendrier.

Since I routinely work on more than 3 computers, I need them all to have my updated schedule at all times. For this, online calendars provide the needed synchronization link. If you use Google Calendar, you can set up Lightning to synchronize with it from Thunderbird, like this:
Download yet another plugin - the Provider for Google Calendar. After installing it as an add-on for Thunderbird and restarting:
  1. Open your Google Calendar from a web browser
  2. Click on Settings, then on the Calendars tab, click on your calendar.
  3. Scroll to the Private Address area (bottom) and right-click the XML link to copy its URL.
  4. In Thunderbird, select File | New | Calendar : On the network : Google Calendar (and paste the URL here) : provide credentials.
That's all. Since all your calendars now feed off the same online calendar, your computers always have an updated copy whenever you run Thunderbird. This is a totally winning solution that's free and effective. At this point I was ready to backup my messages in Outlook and uninstall it from all my computers. I haven't seen issues in a couple of months since I did this.

Sunday, November 02, 2008

Launch OS Applications From Java

It's not a good idea to reinvent the wheel when programming for various platforms; you'll live happier when you can just use what the operating system already offers - straight from your Java application. This is especially helpful if the OS program you are interested in supports command-line invocations: this tip shows how to run those programs and capture the output those programs would produce back into your Java application. Then you could use regular expression or other means to parse the output.
Here's all you need:
    public static List<String> runCommand (String... cmd) {
List<String> output = new ArrayList<String>();
try {
// Create the process
ProcessBuilder pb = new ProcessBuilder(cmd);
Process proc = pb.start();

// Obtain the input stream
InputStream is = proc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);

// Read what is returned by the command
String line;
while ((line = br.readLine()) != null) {
output.add(line);
}

// Close the stream
br.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}

// Return the output
return output;
}
As a utility method, just pass it an array of strings used to build the command, first the fully-qualified name of the program to invoke, followed by program arguments. For example, if I needed to run a Perl script called lockdown.pl and have the Perl interpreter at C:\Perl\perl.exe, then the string array would be something like {"c:\\perl\\perl.exe", "c:\\security\\lockdown.pl"} - notice the use of fully-qualified names everywhere - this process is cross-platform and doesn't look up environment variables to help resolve relative filenames.
The methods returns the output - what you would have seen on the console - as a list line by line. Easy stuff.

Thursday, August 07, 2008

Facebook Browser History Management Bug In Firefox

I had mentioned this issue in a previous blog post, and I think I have identified the root cause. If you use Firefox to browse Facebook, at some point, content will begin to fail to load. This is because of malformed URL often generated by AJAX history management libraries when they do URL replacement or add tags to the URL to help them keep track of history (essentially manage what happens when you click the Back, Forward, or Refresh buttons on the browser). You can do two things about it - either reopen the link in a new tab (so there's no history), or edit the URL as I'll show you.

To reproduce:
(1) Fire up the fox and log into Facebook. Your URL should look something like this:

(2) Click on the "Messages" link. It should open your messaging area, defaulting into your inbox. The URL should look like this:

(3) Click on the "Home" link. It should bring you to your Facebook home page. The URL should look as in the image below. Notice how the URL looks a bit weird - and that's the beginning of the problem. The more you browse around, the more URL chunks are appended at the end of the current URL.
(4) Click on the "Profile" link. The URL looks like that in the image below. This will fail to load content most times, as I described in that blog post.

If you want that URL to work, remove the part between the domain and usually before the last #. So, http://www.new.facebook.com/home.php#/profile.php?id=73002299 becomes http://www.new.facebook.com/#/profile.php?id=73002299, for example, and it will work.

This is only one of many ways Firefox users will run into this issue. Any combination of browsing history will most likely come to the same conclusion, and it's not pretty. Facebook totally needs to fix this bug, or they risk frustration from Firefox users that with think their site sucks when their favorite browser is used.