Setting up CAS development on OS X

Adam Franco June 19th, 2009

Central Authentication Service (CAS) is a single-sign-on system for web applications written in Java that we have begun to deploy here at Middlebury College. Web applications communicate with it by forwarding users to the central login page and then checking the responces via a web-service protocol.

A few months ago Ian and I got CAS installed on campus and began updating applications to work with it rather than maintaining their own internal connections to the Active Directory server. Throughout this process we ran into a few challenges (such as returning attributes with the authentication-success response) and a bug in CAS, but we worked through these and got CAS up and running successfully.

We are now at a point where we need to do some customizations to our CAS installation to deal with changes to the group structure in the Active Directory. As well, the bug I reported was apparently fixed in a new CAS version, an improvement I need to test before we update our production installation. Both of these require a bit more poking at CAS than we can do safely in our production environment, so I am now embarking on the process of setting up a Java/Tomcat development environment on my PC. I’m documenting this process here both for my own benefit (when I have to set this up again on my laptop) and in case it helps anyone else.

Read on for my step-by-step instructions for setting up a CAS development environment on OS X.
Continue Reading »

Fiddlehead Pizza

Adam Franco May 2nd, 2009

For the few weeks in spring that they are available, fiddleheads are a real treat. I find their flavor kind of like asparagus, but a bit nuttier.

This pizza is a whole-wheat crust topped with pesto (some of the last of the 3 gallons I made in 2007), fiddleheads, portobello mushrooms, red bell pepper, and mozzarella.

Newest addition to the stable

Adam Franco April 21st, 2009

Tran Send DX

Tran Send DX photo from the Giant website

I’ve been regularly bicycle commuting since 2002 — though only since 2007 has my commute increased to 3 miles each way up from less than one. I commute pretty exclusively on my Cannondale road bike, as the full-suspension mountain bike with downhill tires is way too slow and the unicycle is even slower.
My road bike, a Cannondale R3000si (CAD5)
The road bike is wonderfully fast and a blast to cruise through traffic with. What is less fun is carrying my laptop bag and a duffel-bag for my gi (heavy cotton Aikido training clothes). A backpack is a little better at handling the weight than the two smaller bags, but hotter due to more contact with my back.

After a few wet rides last week and increasing frustration with the weight of the laptop and sweat-soaked gi I decided it was time to get a dedicated commuter bike with fenders (for the wet) and a rack with panniers (to get the crap off my back). I test-rode a Trek at the Middlebury Bike Center and a Kona and the Giant “Tran Send DX” at the Middlebury Alpine Shop.

While the Trek and Kona felt like perfectly good bikes and were reasonably priced, the Giant felt wonderfully peppy and nimble for a pretty beefy bike. I really like how its geometry manages to maintain an efficient peddling position while still being quite upright. The other bikes didn’t feel quite so efficient. What fully sealed the deal was that the Tran Send came with a custom rack and fenders that felt really solid and fit well on the bike, all for the lowest total cost.

Giant Tran Send DX

After riding the new bike home I mounted a set of head and tail lights for the bi-weekly rides home in the dark. The tail light will be much more visible on this bike than my road bike as I was able to bolt it to the back of the rack where it won’t get covered up by my coat or bags like the under-seat mounting position does. I also picked up some rain pants and ordered a set of panniers to complete my foul and fair weather setup and plan to ride rain or shine through at least November.

Fairpoint DSL problems

Adam Franco April 15th, 2009

A few days ago we noticed that our internet connection seemed to be grinding to a halt. We’ve been on the same DSL plan for years without problems until Fairpoint bought out our service area from Verizon. I despise Verizon and just about all monopolistic telecoms and cable companies, but Fairpoint is just a mess.

Fairpoint’s online account services (just now available after many months of paper billing) do not work with FireFox or Safari, just Opera. While Opera is a fine browser, it seems like an odd sole-choice.

Anyway, the slowdowns seemed really sporadic with sites very slow to start loading, but then loading content quickly. My hunch was DNS problems, which I verified by setting my router to point at the OpenDNS.com name servers at 208.67.222.222 and 208.67.220.220 rather then the default Fairpoint DNS servers. Instant speed up of all web access. So if any one with Fairpoint DSL has noticed a slowdown recently, try changing your DNS server settings in your router or computer and see if that helps.

New Shop Furniture

Adam Franco March 15th, 2009

This weekend I build an outfeed table for the table saw and a stand for the new planer. The outfeed table was inspired by a design in Jim Tolpin’s Table Saw Magic. It folds down to make room or for moving the saw.

First Ride of the Season

Adam Franco March 11th, 2009

03-11-09_1801

After getting several inches of snow on Monday, the weather has now warmed up and I was able to get out for my first bike ride of the season. It was a pretty blustery evening with west winds gusting up to 35mph, but was quite warm at about 50°F. I ended up going out for an hour and covering about 15 miles.


View Larger Map

After having the wind at my back for the first 20 minutes to East Middlebury I got it into my head that I wanted to ride up Route 125 to Ripton. Halfway up the first pitch my legs disabused me of that notion and I decided to ride down to the Shard Villa instead. I enjoyed the rest of my hills, but that first pitch was more than I was prepared for.

03-11-09_1759

All in all it was great to be back in the saddle and I am looking forward to a lot of riding this summer. Last year I only covered 527 miles, we’ll see what this year brings.

Ruby and Rails Thoughts

Adam Franco February 3rd, 2009

I’ve decided to learn a few new programming languages and web frameworks over the next year or so to broaden my experience and just to have fun. I figured that I’d start with Ruby and its Rails framework. Python (and its Django framework) are also at the top of my list, but I seem to run into Ruby programs more often and the Rails fanatics are loudest, so I’m starting there.

After about 5 evenings of documentation and tutorial reading intermixed with a bit of programming I’m about 1/3 of the way through my first real Rails application and am beginning to have a few thoughts on Ruby, Rails, and the process of learning new languages and frameworks:

Languages are Easy…
This might have something to do with how my brain works, but I find learning new programming languages quite easy and extremely interesting. Some of the things I find really neat about the Ruby language:

  • Full-on object-oriented — I really like the consistency
  • Blocks and Iterators — I fell in love with blocks in SmallTalk, they are a great concept and so much easier to use than named callback functions
  • Method names can end in equals such as name=(newName), parentheses are optional, and spaces seem to be allowed in method names that include ‘=’, so attribute-setting methods can look syntactically identical to variable assignment operators. Example: adam.name=('Adam') is equivalent to adam.name = ('Adam') and is equivalent to adam.name = 'Adam'. Sweet syntactical sugar.
  • All instance variables are private. Always. The snazzy setter/getter syntax can spoof the idea of public attributes while still retaining actual methods to do the work. (I never got the point of public attributes other than as a way to avoid other languages’ painful getter/setter syntactical requirements.)
  • Classes are never closed — can always add a method
  • Single-inheritance prevents ambiguity in the class-hierarchy, but there is this concept of ‘Mix-ins’ where the un-closed nature of classes (I think) allows for a class to obtain method implementations from another class without inheriting from it. It sounds interesting, but I haven’t played with it yet

The Ruby language may have some blemishes (and apparently a slow interpreter), but it seems like a pretty nice language in general and pretty devoid of major syntactical or conceptual warts.

…Frameworks are hard
While I feel like I can [mostly] get my head around Ruby in a few days, Rails is another matter. Rails follows a few architectural concepts very strictly: convention over configuration, DRY, MVC, etc. One of the problems (at least with the tutorials and documentation on the Rails website) is that few of the convention have descriptions on how they should be applied and the documentation is scattered and can be hard to follow. A lot of magic happens behind the scenes when things are named a certain way and it can be hard to sort out what’s up when something goes wrong.

One problem I ran into that took me forever to debug was that by naming one of my classes Connection and using it in a has_many relationship I collided with something internal to ActiveRecord which caused an indecipherable error when trying to save my object. Connection is not one of the reserved words listed for Rails.

It may just be that I need to find a good book for Rails, but the official online documentation seems to be rather sparse, disorganized, and/or scattered. I don’t mean to complain too much and I believe that Rails will become much easier to use after I have a bit more time in the saddle, but it is a complex system that is not easy to learn a bit at a time.

I don’t want to dwell on on comparisons, but I must note that I have been very spoiled by PHP’s excellent official documentation at PHP.net and for the Zend Framework. PHP has more warts than, well, something with a lot of warts, (it has many, many warts), and doesn’t begin to compare to Ruby in syntactical elegance, but good documentation is also a valuable thing.

With all this said, I now have only 5 evenings in Ruby on Rails and I plan to give it at least twice that more. I hope by the end of this first project I’ll be comfortable enough with it to use it on other small to medium-sized applications with relative speed and ease.

Adam’s Tortilla Soup

Adam Franco January 18th, 2009

(photo by Sarah Franco)

(photo by Sarah Franco)

Ever since I first tasted it on a trip to Oaxaca, Mexico in 1999, I have maintained a special place in my heart for tortilla soup. Since then I’ve had good and no-so-good tortilla soup at restaurants and enjoyed a decent version in the Middlebury College dining halls. Over this past Christmas holiday my mother made a tortilla soup from a New York Times recipe convincing me to give this soup a try myself.

I went into my soup planning to generally follow the New York Times recipe, with the addition of chicken and corn, but ended up deviating quite a bit with good results. As well, Sarah and I usually just use corn tortilla chips rather than frying or baking flour-tortillas. This saves a bit of work and makes for very easy left-over eating.

This recipe should serve 4 as a main course and leftovers are great frozen.


Ingredients

  • A few tablespoons of olive oil
  • 1 medium onion - chopped
  • 1 chicken leg or breast, cut into small (less than 1-inch) pieces
  • 6-8 cloves of garlic, minced
  • 1 teaspoon of chili powder
  • About a quart of frozen tomatoes or a 28oz can of tomatoes
  • 2 quarts of chicken stock
  • 3/4 cup frozen corn
  • Salt to taste
  • 1/2 cup chopped cilantro
  • 2 tablespoons of lime juice
  • 1 large bag of tortilla chips

Instructions
In a large pot…

  1. Sauté the onion and chicken in olive oil until the onion starts to get translucent and the chicken isn’t raw.
  2. Add the garlic and chili powder and cook for another few minutes, but not so much as to brown or scorch the garlic.
  3. Add the tomatoes and cook for about 10 minutes until the tomatoes reduce a bit.
  4. Add the stock and frozen corn. Bring to a boil and then reduce to a simmer for 30-45 minutes.
  5. Use an immersion blender, pulse the blender a few times to grind up the larger chunks of chicken, tomatoes, and onion, but not so much as to puree all of the corn. A variety textures from purée to small chunks is what I aim for.
  6. Add the chopped cilantro, salt to taste, and stir.

Serving

  1. Put soup in bowls, top with broken tortilla chips.
  2. Optionally, add crumbled queso fresco or other cheese.

Git Tip of the Day: Stage Hunks

Adam Franco January 13th, 2009

One of the great things about the Git version-control system is the ability to incrementally commit your changes on a private branch to keep a step-by-step record of your thought and writing process on a fix or a feature, and then merge the completed work onto your main [or public] branch after your feature or fix is all done and tested. By keeping an incremental log of your changes — rather than just committing one giant set of code with changes to 30 files — it becomes much easier to know why a certain line was changed in the future when bugs are discovered with it.

One thing that often happens to me though, is that I work for about a half hour to an hour trying to get a new piece of code working and in the process make several sets of changes to one file that are only loosely related.

Let’s say that I am fixing a bug in my ‘MediaLibrary’ class and while doing so notice some some spelling mistakes in some comments that I fix. Now my one file has two changes my bug fix, and the spelling fix. Rather than committing both changes together with one comment describing both changes, I can highlight one of the changes in git-gui and select the “Stage Hunk for Commit” option.

Screen-shot of Staging a Hunk of code

With that one hunk staged I can now commit with a message applicable to that change. Other changes can then be staged and committed with their own messages resulting in a very understandable history of changes.

“Stage Hunk for Commit” can also be used to commit important changes while not including debugging lines inserted in your code.

Twitter Export Script

Adam Franco October 13th, 2008

I have been using Twitter as a log of my daily doings and wished to export my time-line for reformatting into a calender format. Unfortunately TweetDumpr just retrieves the list of Tweets using a single fetch request which is limited by the Twitter API to a maximum of 200 Tweets. (Update: apparently TweetDumpr can get more than 200 Tweets. It just didn’t say so in its description.)

I wanted to export all 600+ of my tweets, so I wrote the following little php script to accomplish this. I have not yet tested it with many concurrent users or added a form to select which user to update. Until I do so, I won’t be providing it as an end-user service. You are free to put it on your own machine and use it though.

TwitterExport.php

<?php
/**
 * This script will allow the export of complete user time-lines from the twitter
 * service. It joins together all pages of status updates into one large XML block
 * that can then be reformatted/processed with other tools.
 *
 * @since 10/13/08
 *
 * @copyright Copyright © 2008, Adam Franco
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
 */

$user = 'afranco_work';	// Replace this with your user name.

header('Content-type: text/plain');

$allDoc = new DOMDocument;
$root = $allDoc->appendChild($allDoc->createElement('statuses'));
$root->setAttribute('type', 'array');

$page = 1;
do {
	$numStatus = 0;

	$pageDoc = new DOMDocument;
	$res = @$pageDoc->load('http://twitter.com/statuses/user_timeline/'.$user.'.xml?page='.$page);
	if (!$res) {
		print "\n\n**** Error loading page $page ****";
		exit;
	}
	foreach ($pageDoc->getElementsByTagName('status') as $status) {
		$root->appendChild($allDoc->createTextNode("\n"));
		$root->appendChild($allDoc->importNode($status, true));
		$numStatus++;
	}

	print "\nLoaded page $page with $numStatus status updates.";
	flush();

	$page ++;
	sleep(1);

} while ($numStatus);

print "\nDone loading timeline.";
print "\n\n\n";

$root->appendChild($allDoc->createTextNode("\n"));
print $allDoc->saveXml();



Usage (assuming PHP is installed)

  1. Save the code above on your machine as twitter_export.php
  2. Edit the code to change the $user variable to be your own Twitter username
  3. From the command line run php twitter_export.php
  4. Copy/paste the XML output into a file for safe keeping and further processing

Next »