What I’ve been doing on my Mac

Posted April 22, 2008 by
Categories: Java

I came across this little script here.

$ history | awk ‘{a[$2]++}END{for(i in a){print a[i] ” ” i}}’ | sort -rn | head
208 mvn
121 cd
97 ls
12 mate
8 history
7 ping
4 sudo
4 rsync
4 ftp
3 ssh

more blogs

Posted November 26, 2007 by
Categories: Blogroll, Digital Photography

I’ve added two blogs on Blogspot since this blog is mostly Java related. I’ve started learning Haskell so I decided to keep a separate blog for other coding topics not related to Java. The links are in the blogroll. I also started a photo blog.

Groovy/Grails in Eclipse on OS X

Posted November 16, 2007 by
Categories: Groovy, Mac

I’ve been working with Grails for just a short time now and so far I’m fully impressed in the time savings it offers for development. The other factor the impresses me is that it all just makes intuitive sense for someone who has worked with a variety of web frameworks before.

I ran into an issue with Grails 1.0-RC1 with the Eclipse plugin on Mac. The framework was complaining that it could not find tools.jar which doesn’t exist on the Mac. I believe Apple for some reason merged the contents of tools.jar with another system jar. Anyhow, so far I have safely commented out a reference to tools.jar in conf/groovy-starter.conf. Other than that issue, I have had far fewer than there might be in setting up a full blown Struts 2/Spring/Hibernate project by hand.

I was just reading about the IntelliJ support for Groovy/Grails over on Glen Smith’s blog and think I will have to try it out. I have never used IntelliJ before but if it has better language support for Groovy than Eclipse currently does it would be worth switching.

Leopard so far

Posted November 6, 2007 by
Categories: Mac

I’ve upgraded two Macs at home without issues during the upgrade. My work MBP is still running Tiger and probably will be for quite a while.

I’ve had issues with Time Machine really dragging down system performance until the first complete sync was completed. For some reason the first synchronization failed for several days. My complaint on Time Machine is that there is no immediate link or callout for viewing its log. There should be. I assume it is someplace in /var but I have not gone there yet.

Terminal is a big improvement.

XDMCP seems broken in some way. Akthough I can connect to my Ubuntu box, the keyboard doesn’t work now on the login screen. Ouch. The old trick of switching the keyboard to extended layout has no affect.

Lack of Java 6 support is of course just a shame.

Overall my impression is that performance sufers just a bit.

Google Usability

Posted October 23, 2007 by
Categories: Google

2 simple things are needed:

  1. Allow for customization of the top-level menu. Some items, like Reader, are buried in the drop down and it would be helpful if these could be moved or reordered.
  2. Add Notebook as an available item in the top level menu.

date puzzler explained

Posted September 15, 2007 by
Categories: Java

As someone pointed out the unexpected behavior really is coming from the parse method. Looking in the JavaDocs the behavior is likely coming from the DateFormat class:

By default, parsing is lenient: If the input is not in the form used by this object’s format method but can still be parsed as a date, then the parse succeeds. Clients may insist on strict adherence to the format by calling setLenient(false).

Although this isn’t specific, it may mean it will interpolate dates when the range falls outside of the correct value. Perhaps there is more detailed documentation, but this is all I found without being overly exhaustive about it. So beware if you are expecting parse() to perform strict date format checking for you. I have also found DateValidator() in Commons Validator to be useful in examining date formats.

a Java puzzler

Posted September 14, 2007 by
Categories: Java

I’m a fan of Java Puzzlers and came across this one on my own. Perhaps it has been brought up before though. What happens when you run this program? Hopefully I can explain the answer by tomorrow!

public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat(”yyyy-MM-dd”);
try {
Date d = sdf.parse(”1957-02-29″);
System.out.println(”success: ” + d.toString());
} catch (ParseException e) {
e.printStackTrace();
}
}

summer photos

Posted September 9, 2007 by
Categories: Digital Photography

Now that summer is winding down a bit, I thought I would go back through a few of my photos and link to them here.




Groovy and Google Notebook

Posted September 8, 2007 by
Categories: GData, Google, Groovy, Java

I started learning Groovy in the past few days. So far I am wondering why I waited so long to start learning it. I like the shorthand style and the ability to get tasks that are a pain in Java done quickly. These are obvious things to like certainly since they are objectives of the language.

Anyhow, I needed something to do with the language so I chose to write a simple script to download a list of public notebooks from Google Notebook and then process the first one in the list. Here are some observations on the process.

  • It was not immediately obvious to me how to obtain my Google userid that the documentation mentions. I discovered after a bit of frustration that it is a large numeric value that is passed no the query string and is not the userid that one logs in with. This didn’t jump out at me from the documentation.
  • I used Eclipse to write my script and boy did I miss several things that the plugin lacks: code auto formatting and a debugger. Even though the script I wrote is trivial a debugger would be a nice tool in learning Groovy. Maybe one of the other IDE’s has one for Groovy?
  • Groovy still awkward to me after living the structurd life of a Java programmer for so many years. The corner-cutting takes some getting used to. The missing ;’s can feel like nails on a chalkbaord.

  • import com.google.gdata.client.*;
    import com.google.gdata.data.*;
    def myId = ‘big number from google url’
    def urlUser = “http://www.google.com/notebook/feeds/$myId”
    URL feedUrl = new URL(urlUser);


    GoogleService googleService = new GoogleService(”notebook”, “alex sample”);

    /**
    * request the feed
    */
    Feed myFeed = googleService.getFeed(feedUrl, Feed.class);

    print ‘notebook name: ‘
    println myFeed.title.plainText;

    List l = myFeed.entries;

    println “public notebook’s: “
    for (Entry e in l) {

    print e.title.plainText;

    URL notebookUrl = new URL(e.id)

    Feed notebookFeed = googleService.getFeed(notebookUrl, Feed.class);
    /* process the feed */

    }

    The Windows SDK

    Posted September 7, 2007 by
    Categories: Java

    I was reflecting recently on what it was like during my first few weeks as a professional software developer just out of college. My first job out of college was for a small consulting firm that specialized in writing custom Microsoft Windows programs in C. This was 16 bit Windows 3.1. One way that I went about getting acquainted with Windows programming was to take home the SDK programmers reference and read the API from a to z. This actually proved to be beneficial as horrible as it may actually sound. I believe I got through the API’s in about one weekend of casual reading. Who can forget CreateWindowEx()?

    HWND CreateWindowEx(
    DWORD dwExStyle,
    LPCTSTR lpClassName,
    LPCTSTR lpWindowName,
    DWORD dwStyle,
    int x,
    int y,
    int nWidth,
    int nHeight,
    HWND hWndParent,
    HMENU hMenu,
    HINSTANCE hInstance,
    LPVOID lpParam
    );

    Shortly after this a lot of Windows programmers, myself included, went through a transition period as a C++ compiler and MFC was made available from Microsoft. What a wonderful idea it was and once again the power of abstraction in computer science came to the rescue to hide the gory details. At the time, MFC was a wonderful thing.

    Bringing this to today’s environment, one could not reasonably read through all of the JDK in a weekend I don’t believe. It would be a task more painful than reading through the Windows SDK for me. The breadth of the entire programming environment for Java is formidable if you attempt to survey the entire landscape. We have abstractions built upon abstractions. Entire frameworks get raised up to correct shortcomings in the JDK, or in the best cases provide abstractions that may have had little value when the JDK was first designed.

    I think much of our progression has come from the power of the Internet as a collaboration tool. When I took up Windows programming the only sharing of ideas and issues came from around the office. The notion of using the Internet as a learning or collaboration medium for professional developers, at least for me, didn’t really exist at the corporate level. Collaboration is a wonderful thing.

    As an exercise, it would be quite funny to re-create the typical 16 bit Windows development environment and attempt to write some small application that by today’s standards might be quite trivial. I would venture to guess that using the 16 bit Windows SDK to send and receive an XML request over HTTP would be a challenge. Recreating the environment alone would take time. Anyone still have a copy of Brief for DOS?