Avast Mateys, Let’s All Talk Like Pirates!

Aye, today be International Talk Like a Pirate Day and methinks a celebratory tankard of grog is in order. Yo ho, yo ho, a Pirate’s Life for me! Arr, ye can just call me Cap’n Joey “I’ve Never Owned a Parrot” Gibson fer today, ye can. So raise yer glasses high and be sure to refer to your wife/girlfriend as your “buxom beauty” or, fer the really adventurous, “serving wench!” Aye, that’s more fun than pillaging a small island settlement, it is. Shiver me timbers and prepare to be boarded!

(Note: Yes, this was a pretty poor attempt. I’ve never really tried to talk like a Pirate before.)

Mixer Remixed

After reading several threads about the text scrmabler and various implementations, I revised my Ruby version and it’s now 21 lines shorter and much more Ruby-like. It makes far less of an attempt to deal with punctuation, but I think that’s OK. This is just a lark, after all.

  1  class Mixer  2      private  3      def randomize(str)  4          return str if str.length < 4  5  6          str =~ /B.*B/  7          first = $`  8          last = $'  9          first + ($&.split(//).sort_by {rand}.join) + last 10      end 11 12      public 13      def mix_file(filename) 14          lines = IO.readlines(filename) 15 16          mix_lines(lines) 17      end 18 19      def mix_string(str) 20          mix_lines(str.split).join(" ") 21      end 22 23      def mix_lines(lines) 24          lines.collect! do |line| 25              words = Array.new 26 27              line.split(/W/).each do |word| 28                  words << randomize(word) 29              end 30 31              words.join(" ") 32          end 33      end 34  end 

I Found the Old Mill Wheel

Tonight while riding at Tribble Mill Park, I found the remnants of the old mill wheel. I had been within about 20 feet of it before and never noticed it, but a fellow last week told me where to look. I looked tonight and sure enough, there it was. I’m going to go back with the camera tomorrow and take some pictures which I’ll post here.

It was a strange thing standing there on the stone wall next to the collapsed steel(?) wheel. I was struck with a sense of profound sadness; which was odd since I didn’t know anything about the history of the mill. I have been getting this feeling a lot lately as I look around at all of the construction work going on in this area. Old houses are being torn down or moved in droves in order to build yet another Walgreens or a new strip mall. Houses that have been there for decades or longer; each with histories and lives, happiness and sorrow. Enormous trees that were there before the houses. I’m all for progress and such, but there’s some point where you just feel like saying “Do we really need another drug store?” I don’t know where that point is, but lately I keep sensing that we’ve passed it.

The sadness I felt was in knowing that this mill wheel was once part of a thriving mill. Yet here it was collapsed and broken in the woods. The wall that once diverted the water from the river lay in pieces. I didn’t know any of its history, but all that was left were ruins. I did a quick Google and found this story about the nearby town of Dacula. In it I found this

In the 1920s, he [Newton Giles Pharr] bought Tribble Mill, a water-powered mill where farmers had their corn ground with a mill rock imported from Germany. Situated near the rapids of the Alcovy River toward Walton County, the mill also offered a cool summer outing — people would travel out from town and wade, swim and picnic near the water.

which confirmed some of my thoughts. I don’t know when the mill was destroyed or how. The wheel is now broken and rusted, but it looks like it was once around 12 – 15 feet in diameter. I can imagine it tirelessly turning the shaft which turned the cogs which ultimately turned the meal-grinding stone, hour after hour. I can just imagine folks in their bathing costumes sitting on the sheets of granite by the river having a lunch of chicken and fresh fruit, with the mill behind them grinding out corn meal. I could almost feel the spirits of those who used to frolic there. It was a very sad moment; I don’t know that I can explain it any better than that.

By Popular Demand, I Give You… Mixer!

“Popular demand,” yeah… right… That’s the ticket. Anyway, I saw this blog entry by Jamie this morning which caused me to write a Ruby program to mix up the letters of words, leaving the first and last letter as they were. I started out with a simple script, then I added better punctuation support, then I converted it to a class, then I wrote unit tests to run it. Anyway, somebody wanted to see it, so here it is. Is it great code? Probably not. Do I care? Not really.

  1  class Mixer  2      private  3      def randomize(str)  4          if str.length < 4  5              return str  6          end  7  8          letters = str.split(//)  9 10          first = letters[0] 11          mid = letters[1..(letters.length - 2)] 12          last = letters[letters.length - 1] 13 14          new_letters = "" 15 16          while mid && mid.length > 0 17              len = mid.length 18              r = rand(len) 19              new_letters << mid.delete_at(r) 20          end 21 22          first + new_letters + last 23      end 24 25      public 26      def mix_file(filename) 27          lines = IO.readlines(filename) 28 29          mix_lines(lines) 30      end 31 32      def mix_string(str) 33          new_str = "" 34 35          mix_lines(str.split).each do |line| 36              new_str << line 37          end 38 39          new_str 40      end 41 42      def mix_lines(lines) 43          lines.collect! do |line| 44              new_line = "" 45 46              line.split(/s+|,|.|!|(|)|"|'/).each do |word| 47                  new_line << randomize(word) << " " 48              end 49 50              new_line 51          end 52 53          lines 54      end 55  end 

And the unit tests, which don’t actually test anything.

  1  require 'test/unit'  2  require 'mix'  3  4  class MixTest < Test::Unit::TestCase  5      def setup()  6          @mixer = Mixer.new  7      end  8  9      def test_word() 10          x = @mixer.mix_string("testing") 11          puts x 12          assert_not_equal("testing", x, "String not randomized") 13      end 14 15      def test_string() 16          x = @mixer.mix_string("this is a humongous test, dangit") 17          puts x 18      end 19 20      def test_file() 21          article = @mixer.mix_file("testfile.txt") 22          #puts article 23      end 24  end 

I’m sure someone will find this useful… Again, “yeah, right.” Ah well, it was a mildly amusing diversion…

I’m Presenting at NFJS: Atlanta

If anyone will be in or around Atlanta, GA, October 24 – 26, you should think about attending the Atlanta Java Software Symposium which is part of the No Fluff, Just Stuff symposium series. I’ll be presenting a session entitled “Scripting on the JVM” in which I will present various scripting languages like Python and Ruby running on top of the Java virtual machine and trying to explain why that’s cool. The session abstract is located on the sessions listing page; I’m about 1/3 of the way down the page.

I attended this symposium last year and had an excellent experience. The ratio of useful information to vendor-specific sales-weasel crap was extremely high, which is a good thing. I wrote about it in the February Java Developer’s Journal if you want to read about it. There is also a review of one of the other symposia in the series in the current issue.

I’m really looking forward to presenting at it this year’s symposium.

Java Regex APIs and Quoting

I’ve just been digging through the J2SE 1.4 regex stuff, and every time I have to do regex work in Java I keep thinking how much easier it is in other languages. Specifically I’m talking about the clunkiness of the various regexen APIs in Java and the requirement to double-backslash regex operators. We need a better way. Ruby and Perl both have native regex support built in to the language, so the backslashes are just fine. Python, which doesn’t have native regex support (it’s in the library), does have “raw” string quoting, which allows you not to double-up the backslashes. So what I have to write like this in Java:

1  Pattern p =
2      Pattern.compile("(\(\d+\))?\s*(\d{3}\s*\-\s*(\d{3})");
3  Matcher m = p.matcher(my_string);
4  if (m.matches())
5  {
6      ...;
7  }

or

1  if (Pattern.matches("(\(\d+\))?\s*(\d{3}\s*\-\s*(\d{3})", my_string))
2  {
3      ...;
4  }

looks like this in Python:

1  if re.match("((d+))?s*(d{3}s*-s*(d{3})", my_string):
2      ...

and could be even more easily written in Ruby thus:

1  if my_string =~ /((d+))?s*(d{3}s*-s*(d{3})/
2      ...
3  end

See the difference? The built-in regex support is really nice and the ease of quoting is a beautiful thing. I doubt that we’ll ever see either of these in Java since they would certainly be considered non-trivial to add.

And Now… Ladies and Gentlemen

I finally got a chance to see And Now… Ladies and Gentlemen Saturday night. I’ve been waiting over a year for this movie to make it to the States and it finally has. It stars Jeremy Irons who is wonderful as master jewel thief Valentin. The scenery is beautiful; it was filmed in France and Morocco, and the story is also quite good. But the main reason I wanted to see it was the debut performance of my favorite French chanteuse, Patricia Kaas. She played a lounge singer (surprise!) who ends up in Morroco and meets Valentin. She sings through a great deal of the film, which was wonderful, but quite a bit of it was in English. While she sounds lovely in any language, I much prefer it when she sings in French. The deal is that they are both suffering from blackouts and Valentin has the added bonus of migraine headaches. They are pulled together by the careless tongue of the Morroccan doctor who mentions to Valentin that the singer at the local hotel has the same problems as he. Valentin heads to the hotel to see her, and witnesses her having one of her blackouts. She walks out of the hotel and ends up in a dark alleyway. Two thugs attempt to mug her, but Valentin is there to save the day. She ends up returning the favor the following day when Valentin is accused of a robbery in the hotel. This is the beginning of their relationship that will continue through the rest of the film as they head for Lalla Chalia’s grave; supposedly Lalla can heal people from “the other side.” I won’t give away what happens…

Anyway, I really enjoyed the film. There are sad moments and funny moments (Jeremy Irons dons several disguises during his various robberies) and then there’s all the lovely singing. I highly recommend this film, if it’s anywhere near you. It probably won’t be, but you can always watch for it on DVD. I had to drive 40 miles in to “the Big City” (Atlanta) at 9:40 PM Sunday night to see it at the Landmark Midtown Cinema. I generally don’t like going into the city, but I occasionally head to the Red Light Cafe to see Glenn Phillips, which is about a block away, so it wasn’t that bad.