“Free” WiFi

I found two links to this BusinessWire story this morning; one at /. and the other at Boing Boing about the island country of Niue rolling out nationwide “free” wireless networking. Why can’t people understand that nothing from the government is ever free? Anything provided by government was paid for from the money seized from the citizens in taxes. And in most countries that have “progressive” tax policies, the majority of that money was taken from the “wealthy.” So everyone now has “free” wifi because some working stiff had to pony up to the tax man.

First Cut At Kata 8

Dave Thomas of the Pragmatic Programmers has started publishing programming problems, calling them Kata. He’s just published Kata 8 this morning and I’ve had a go at a solution. The problem is to take a supplied list of words and go through it finding all the six letter words that are constructed from shorter words in the file. The full problem is to write the program in three different ways: one optimized for human consumption, one optimized for speed, and one that is highly extensible.

Presented below is my first cut at this kata. I think it is fairly readable, at 79 lines, so this probably will count as my “fit for human consumption” version. It’s relatively fast, completing in 11 seconds.

Comments? Critiques?

 #!/usr/local/bin/ruby  start = Time.now  # Arrays for each class of word fourLetters = Array.new threeLetters = Array.new twoLetters = Array.new sixLetters = Array.new  # Loop over the word list, segregating the words #  to their respective array IO.foreach("wordlist.txt") do |line|     line.chomp!.downcase!      case line.length     when 2         twoLetters << line     when 3         threeLetters << line     when 4         fourLetters << line     when 6         sixLetters << line     end end  candidates = Array.new  # Build up all combinations of four letters + two letters #  and store in them as candidates fourLetters.each do |four|     twoLetters.each do |two|         wc = four + two          candidates << wc     end end  # Build up all combinations of three letters + three #  letters and store them as candidates threeLetters.each do |three|     threeLetters.each do |otherThree|         wc = three + otherThree         candidates << wc     end end  # Finally, all combinations of two letters + two letters #  + two letters and store those as candidates twoLetters.each do |firstTwo|     twoLetters.each do |secondTwo|         twoLetters.each do |thirdTwo|             wc = firstTwo + secondTwo + thirdTwo             candidates << wc         end     end end  # Now get rid of dups and sort in place candidates.uniq!.sort! puts "Candidates = #{candidates.length}" #  # And the two arrays together leaving only those words #  that appear in both lists matches = sixLetters & candidates  # Now write the matches to a file File.open("matches.txt", "w") do |file|     matches.each do |word|         file.puts(word)     end end  finish = Time.now  puts "Started at #{start}" puts "Finished at #{finish}" puts "Total time #{finish.to_i - start.to_i}" 

I Need a “Favorite Icon”

Everyone seems to have nifty little icons for their websites that show up in the address bar and on their bookmarks. I need one for my site, but I can’t think of anything. Does anyone have any suggestions? (And no, I won’t even consider a horse’s ass…) An elephant at a computer keyboard, perhaps? Probably too detailed for that small amount of real estate. Email me if you have a suggestion.

No (Apparent) Love Lost In JBoss Group Split

After this morning’s surprise announcement that JBoss Group was essentially forking, there has been a lot of speculation about what this means for JBoss Group specifically and JBoss in general. The new company was started by 8 now-former JBoss Group consultants and was announced with much fanfare this morning. Ben Sabrin of JBoss Group just posted a “rebuttal” of sorts to the jboss-user mailing list. He took a few jabs at the departing consultants and made one statement that’s a bit hard to swallow. The jabs:

“…the most important developers are on board with JBoss Group.”

“WE have the financial resources to patch the departures of three consultants in our US consulting operation.”

and the dinger is

“It is business as usual and JBoss Group is currently growing.”

The statement that all the “important” developers are on board is an attempt to downplay the reputations of those who have left by implying that they were second string, while the second is attempting to indicate that the new company is going to be strapped for cash, probably to scare off potential customers. I have no personal info on either statement or situation, nor do I know if the developers in question are useful or not. From what I can tell, though, in reading the various articles about the split, the consultants who left all seem like integral parts of the team… I can’t blame JBoss Group for being ticked off, but these statements just strike me as a little smarmy.

The dinger is a dinger because how can you be growing if half of your consultants just left?

I think it will be interesting to see how all this plays out over the next several months. Will this lessen or increase the business use of JBoss? I actually think the potential is there to increase it because you have more options for support, but that’s just me.

Jython Is Just Too Useful

A colleague just came to me asking about Java serialization and output options. We’re going to store some partially filled Serializable DTOs in a BLOB in our database so he needed some info. Our talk then turned to options for storage and such. He already knew about using ObjectOutputStream on top of a FileOutputStream, but I also told him how to get a byte array from the object using a ByteArrayOutputStream. To illustrate, I fired up Jython in interactive mode and typed the following:

[c:tmp] jython
*sys-package-mgr*: processing modified jar, 'C:AspectJ1.1libaspectjrt.jar'
Jython 2.1 on java1.3.1_02 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> from java.io import *
>>> from java.util import*
>>> m = ArrayList()
>>> m.add("Foo")
1
>>> m.add("Bar")
1
>>> m
[Foo, Bar]
>>> baos = ByteArrayOutputStream()
>>> oos = ObjectOutputStream(baos)
>>> oos.writeObject(m)
>>> oos.close()
>>> dir(baos.class)
['__init__', 'reset', 'size', 'toByteArray', 'toString', 'write', 'writeTo']
>>> baos.toByteArray()
array([-84, -19, 0, 5, 115, 114, 0, 19, 106, 97,
  118, 97, 46, 117, 116, 105, 108, 46, 65, 114, 114,
  97, 121, 76, 105, 115, 116, 120, -127, -46, 29,
  -103, -57, 97, -99, 3, 0, 1, 73, 0, 4, 115, 105,
  122, 101, 120, 112, 0, 0, 0, 2, 119, 4, 0, 0, 0,
  10, 116, 0, 3, 70, 111, 111, 116, 0, 3, 66, 97,
  114, 120], byte)
>>> bais = ByteArrayInputStream(baos.toByteArray())
>>> ois = ObjectInputStream(bais)
>>> x = ois.readObject()
>>> x
[Foo, Bar]
>>> m
[Foo, Bar]

There are lots of cool things there, but specifically, notice the bits in red. I couldn’t remember the method to call to get the byte array, so by using the Python dir() method on the class of the object, I got a list of available methods. toByteArray() was the ticket and you can see both the array itself and then that I went further and deserialized the byte array using a ByteArrayInputStream. Think about how many lines of Java code I would have had to write to show him the same thing. But even if the syntax were just as verbose as Java, not having an edit-compile-run cycle made the demo far faster and productive than it would have otherwise been.

Tracking Down a Log4J Problem

I had a really interesting time tracking down a Log4J problem. We’ve been using Log4J for over a year now happily and even happier with the Commons Logging package on top of it. But last week (while I was on vacation) something went pear shaped: the logs got created but after some initial log messages got sent to the logs, no further messages would get logged. I checked the config file (the XML variety, not the properties file) and it was correct. I then set about digging through code to see if someone had programatically changed the logger, but found nothing. Finally today I found the culprit: a rogue log4j.properties file in a war file in our ear file (that had been there the whole time) had been changed to set the root logger to a level of WARN. Since all of our log messages are at INFO level, thus they never made it. I’ve tested this and it is indeed the problem.

That was a real pain to diagnose, especially since the offending file had not been checked into our source repository. Had it been checked in, I probably would have spotted the change sooner.

Excellent Verizon Wireless Tech Support

I just got off the phone with tech support at Verizon Wireless and I have to say it was one of the most pleasant tech support experiences I’ve ever had. I have a Kyocera 2235 tri-mode mobile phone. I bought Verizon’s MobileWeb, but in the year that I’ve had it, I’ve hardly used it because it’s just so cumbersome to type URLs on a phone keyboard. Well, with the acquisition of my Dell Axim PocketPC, that’s just changed. I got a cable to connect the Axim to the Phone and use it’s Internet connection. But I couldn’t figure out the settings to make it work. I called Verizon tech support and got a human within 60 seconds. He was extremely friendly, but not the right person to answer the question. He asked me to wait a little longer and assured me it would be no more than one minute before the right person would be on the line. He was right. I got another extremely friendly person who walked me through the settings on my Axim and stayed with me until I actually got connected. Total time on the call: 5 minutes. This was excellent service and I’m very happy.