Part of my hesitation in moving away from FVWM and over to GNOME was having to give up a lot of my custom keyboard commands (my goal in life is to pretty much never use a mouse). GNOME Do helped to bridge much of that gap. After a few days, it became a pretty much essential part of my UI.

Problem is, although Fedora 11 brought a newer version of Do (0.8.1.3), the Do plugins aren’t yet in the Fedora 11 repositories. That doesn’t leave Do crippled, but I was missing some of the added functionality I had grown accustomed to.

I took some time at lunch to build Do and its plugins locally. It took a bit of effort since the installation instructions were geared towards Ubuntu, but I updated the Do wiki with notes specific to building on Fedora. Anyone who is missing the added features of the plugins can check out the build instructions over at the GNOME Do wiki to get the plugins installed for full Do awesomeness.

Vim Recipes

June 4th, 2009

A coworker sent out the following link to the Spacewalk mailing list.

Vim Recipes

Don’t know what Vim is? Google it, I haven’t gotten around to blogging about it and Emacs yet. After you’ve googled it, install it. Yes, they have a Windows version.

Rather than being a straight user guide, it’s more of a guide on how to do useful shit in Vim. I took to Emacs keys much more easily (to the point that I remapped IntelliJ to use the common ones), but I’m really trying to force myself to get better with Vim. The recipes guide reads much better than any of the other tutorials I’ve looked into for Vim and has already shown me a number of useful tips.

For instance, the one thing that has always bothered me about Vim was how many steps it takes to save a file. I’m the kind of person who instinctively saves whatever I’m working on every time I stop to think. I’ve lost too much time by fat fingering something and closing the window without saving. In Emacs, that’s a very quick sequence:

Ctrl-x, Ctrl-s

It may look a little weird, but after using Emacs for 10 minutes, an easy key stroke to mindlessly use. In Vim, it takes a few more steps:

Esc  (to exit insert mode)
:w
i  (or a, to enter insert mode again so I can, ya know, actually type something)

That’s a lot of movement around the keyboard for something I do several times a minute (I stop to think a lot). Page one of that recipes guide already showed a useful way around that:

Use [Ctrl]+o in Insert mode to switch to Normal mode for one command, then return to Insert mode. For example, [Ctrl]+o gqas enters Normal mode, reformats the current sentence, then returns you to Insert mode.

In other words, it eliminates both the need to press escape as well as having to explicitly enter back into insert mode. So my mindless save now looks like:

Ctrl+o
:w

Much nicer. Even if that was all I picked up from the guide, it’d have been well worth it.

I won’t go into more specifics, but I was able to easily find information on repeating commands. I tend to use a lot of dividers in my text files, so being able to quickly generate 60 hyphens as a section header was a sore spot when learning Vim after Emacs. I’m also a big fan of temporary macros to repeat a sequence of changes, which I’m still figuring out how to do in Vim.

Eventually I want to write a bit more of a general introduction blog on Vim and Emacs (where I may explain the religious war between the two) in hopes I can convince my students to learn a real text editor (no, Wordpad doesn’t count and you ask for help while using Notepad, I’m docking your grade). I can’t stress enough that at some point in your career you will find yourself on some form of Linux/Unix/Solaris box where at least being able to navigate and edit text in Vi is pretty much required knowledge.

Java enum

February 9th, 2009

One of the cooler features introduced in JDK 1.5 was the enum keyword.

In short, an enum is a collection of constant values. They provide a simple way of limiting the options you can use for a variable if there are only a standard, or in other words enumerated, set of values it can be.

For instance, imagine if you were modeling a deck of cards. Each card would be one of 4 possible suits: clubs, diamonds, spades, or hearts. One option is to store the suit in a string variable, however this is cumbersome for two reasons:

  • There has to be careful validation in the setter for the suit to ensure only the four possible suits are allowed, taking into account the capitalization of the string.
  • If you needed to do different handling based on the suit, if/elses would have to be used; a switch statement cannot be used on strings.

Instead of using a string to track the suit, an enum is a good candidate. An enum is defined just like a class except using the enum keyword instead of class. Also like a class, an enum is typically defined in its own file of the same name.

1
2
3
public enum Suit {
    HEARTS, CLUBS, SPADES, DIAMONDS
}

A simple enum, which is usually sufficient, just lists the possible values. Since these values are effectively constant, the convention is the same as for final variables (all caps).

Using an enum is the same as any other object:

1
2
3
4
5
6
7
8
9
10
11
public class Card {
    private Suit suit;
 
    public Suit getSuit() {
        return suit;
    }
 
    public void setSuit(Suit s) {
        suit = s;
    }
}

When attempting to set a suit on a card, the compiler will only allow one of the four values defined in the enum, so there is no need to add validation in the setter. The value is accessed by using the enum name and the value name, similar to calling a static method or variable:

1
2
Card card = new Card();
card.setSuit(Suit.DIAMONDS);

If for some reason, we needed to do different handling based on suit (not an overly applicable scenario in this use case, but often a common usage of enums), enums are supported in switch statements:

1
2
3
4
5
6
7
8
switch (myVariable) {
    case Suit.HEARTS:
        // do hearts processing
        break;
    case Suit.CLUBS:
        // do clubs processing
        break;
}

Keep in mind that an enum can also take on other properties of a class. Instance variables and methods can still be defined in the enum. Since the only creation of enum values are done inside of the enum itself, any instance variables must be initialized in the constructor. For example, assume we wanted a display name for each suit. The following changes would support this addition:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public enum Suit {
    HEARTS("Hearts"),
    DIAMONDS("Diamonds"),
    CLUBS("Clubs),
    SPADES("Spades");
 
    private String name;
 
    private Suit(String n) {
        name = n;
    }
 
    public String getName() {
        return name;
    }
}

Given the above changes, the public methods can be called on the enum values as if they were any other object::

1
System.out.println(Suit.HEARTS.getName());

For another example, check out the enum for each column in the grades table in CodeTurtle.

iPod + iTunes + DRM = fail

February 5th, 2009

Courtesy of defectivebydesign.org

iPod Fail

I sit multiple chat rooms for work, spanning two IRC servers: internal Red Hat and Freenode. We use nick name changes to reflect status, for instance “jdob[lunch]” or “jdob[getting-beer]“. The default behavior of the /nick command (used to change your nickname, natch) is just for the server on which you executed it. What happens is I inevitably forget to change the nick on one of the servers, either leaving me at lunch for hours on end or making it look like I’m working at 9pm (which, let’s be honest, doesn’t happen nearly as often as my unchanged nickname would reflect).

I asked in the #spacewalk room if anyone on my team knew how to change the nicknames across servers. No one knew, but a bunch seemed to want the same functionality for the same reasons as I did.

I hopped in the #xchat room on Freenode.

[jdob] hey all... random question... is there a way to set my nick across multiple servers at the same time?
[Khisanth] jdob: /allserv nick newnick would change it on every server

Done. It took me 10 seconds to locate a community of XChat users and draw from their expertise. I didn’t even have to google around for the community; Freenode is a pretty common location for that sort of thing. I have no idea who Khisanth is, but it doesn’t matter if he/she is a developer or just a user, the community was there, accessible, and knowledgeable. That rocks.

CodeTurtle

December 29th, 2008

Grading sucks.

Don’t get me wrong, I love teaching. And I love getting to see how students approach problems. I tend to leave my projects open-ended enough where they can express a bit of their own creativity into the solution. I like having small classes since I can spend a good amount of time offering suggestions on their implementation in addition to their results (my students can vouch for this, I usually provided 2-3 pages worth of comments that were unrelated to a particular grade item).

But coming up with an actual consistent, subjective, quantified number grade is a pain in the ass. I end up with a big checklist of things to look for and I am constantly having to go back and recheck projects to make sure I ran a particular test or to see how I scored a certain shortcoming.

I thought about writing my own test cases in one of the existing test frameworks (such as JUnit) to automate some of the process. The concept is sound, but in the end I was trying to shove the square peg into the circle hole; there would still be a lot of manual intervention to interpret the results and turn it into a grade.

I looked around for a solution. From what I saw, there really isn’t a solid application to facilitate what I wanted. So, I decided to write one.

The idea started out small: Point my application at a bunch of student projects and have it run tests and return me a grade. That would give me a very solid and consistent basis on which to derive the grade, allowing me to spend more time providing manual comments on the code or approach itself. I would just need a pretty flexible API to support the types of tests and introspection I wanted so it could be used to grade multiple projects easily.

Not surprisingly, once I started writing it more and more ideas started to take shape. I realized I could have my application, which I named CodeTurtle (more on that later), generate the report to return to the student as to which tests passed or failed. If I was going to have CodeTurtle generate the report, I needed a way to add my comments in, so comment functionality was written. Since most of my comments were based on a code review, I wanted to be able to view the students’ source files as well and then tie that into the comments subsystem to skip the copy/paste need when commenting on particular code snippets. And so on…

Also not surprisingly, I open sourced it at SourceForge. Ideally, I’d love to get other teachers, both at Villanova and eventually other schools, involved with both usage and development. But I also wanted to give some of my former students an opportunity to get some solid, real-world programming experience before they graduate.

I built the 0.1 version and made it available to download from the SourceForge site for people to start playing around with. Being the first release there’s obviously a ton of more work to do, but I included a sample project to demonstrate the types of student submission validation I’m going after (screenshots available as well). I also included some starting documentation, which will continue to get flushed out as I get the time. I’ve also got the interest of at least one friend of mine, so getting it off my laptop into a public area soon was important.

Feel free to contact me through SourceForge (mailing list or forums) or e-mail me directly if anyone is interested in either learning more about it or wanting to contribute.

Oh, and since I’ve been asked this a dozen times already and don’t have a FAQ up yet, I’ll just toss this out now. The name “CodeTurtle” came from the fact that I really didn’t have a good idea for a name. One night while working on it I looked up from my laptop and asked my 18 month daughter what I should call the project. The newest word at the time was “turtle” which sounded as good as any for a project name. And so, CodeTurtle was born. It’s not the most descriptive name out there, but it’s also not the worst named open source project I’ve ever heard of.

Spacewalk 0.3 Released

November 7th, 2008

The Spacewalk team is proud to announce the release of Spacewalk 0.3.

With this release, Spacewalk 0.1 will no longer be available. If you are still using Spacewalk 0.1, please upgrade to Spacewalk 0.3.

Features & Enhancements

  • New APIs including the following namespaces. See https://fedorahosted.org/spacewalk/wiki/ApiAdditions for a complete list of APIs.
    • activationkey.*
    • kickstart.profile.*
    • kickstart.keys.*
    • system.custominfo.*
  • Inter Satellite server sync to allow you to sync your Spacewalk server with other Spacewalk servers.
  • Enhanced system search
  • Command line proxy installer
  • More perl to java migrations
  • rhn-satellite is no longer in /etc/init.d, use /sbin/rhn-satellite to start/stop the entire satellite
  • Upgrades from 0.2 -> 0.3 available as well: https://fedorahosted.org/spacewalk/wiki/HowToUpgrade

Bugs fixed

Known issues

  • Unfortunately, Spacewalk running on Fedora was once again moved to 0.4. The biggest hitch is rebuilding a number of supporting packages to work with Fedora.

Community

Installation Help