Matthews Cafeteria: A Disappointing Breakfast

In the late 1990s, I worked at a company in Tucker, GA. We would make almost-weekly visits to a local landmark: Matthews Cafeteria. In business since 1955, everyone in the area knew about Matthews. It was a meeting place for locals, and it drew diners from all over the area, because the food was wonderful. And when I say “food,” I mean real, Southern food. Wide, flat green beans, seasoned with ham hocks. Corn seasoned with bacon grease. Fried chicken, battered and fried by hand. Really, really good Southern food. I had not had a chance to get back over there since I left that job in 1999.

About two years ago, Matthews was featured on the Food Network show, “Diners, Drive-ins and Dives,” with Guy Fieri. Guy was shown around by, I presume, one of the owners. The guy showed him how they make their biscuits from scratch, by hand, and how they lovingly make their sausage gravy to slather on top of their biscuits. Upon taking a single bite, Guy loudly declared, “O! That’s money, right there!” I had seen this episode before, but I saw a rerun of it on Sunday, and it flung a cravin’ on me to go. So this morning, I arose at 5:00 AM, was out of the house by 5:25, and was walking into Matthews at 5:50.

This is an old-timey cafe, that I imagine looks pretty much like it did when they opened in 1955. There are no frills, but that’s fine. You don’t need frills for good food. I’ve long felt that the hole-in-the-wall, sparsely decorated joints had the best food. Sadly, that mantra failed me this morning.

You first go through a line, telling the servers what you want and they hand it to you on a plate. I knew I wanted a biscuit with sausage gravy, but I was also thinking about the fried steak. The woman who was helping me didn’t seem to speak much English, since when I pointed at what I assumed was the fried steak and asked, “Is that the fried steak?” she didn’t answer. Instead, she placed two patties on a plate, and then proceeded to dump hash browns on them. I was able to stop her, so she raked the potatoes and onions back into the chafing dish, and looked at me for what was next. I said, “I’d like a biscuit and gravy, please.” She grunted, split a biscuit and ladled some gravy over it. I then got a glass of orange juice, bringing the total to $5-something. I took a seat on a terribly uncomfortable metal chair, and got ready to tuck in.

I should note that there were maybe 5 other customers in the place, two of which were older men (mid 60s to early 70s, maybe) seated together. The first thing I heard one of them say was, “… that skanky bitch…” which is not something you hear coming from an old guy all that often. I heard that same phrase at least three more times over the next ten minutes, along with “motherf**ker,” and an account of how drunk he was at some function. Keep it classy, gents, keep it classy.

On to the food. The biscuit was probably OK, though it was hard to tell. It seemed like, by itself, it would have been light and flaky. The gravy that was on top of it was horrible. It was the thinnest white gravy I’ve ever seen. It was basically water, with a dusting of flour, a dash of pepper and one piece of sausage, one thin, tiny, almost imperceptible piece of sausage, that was hardly worth mentioning. There was no flavor at all to this gravy. The fried steak was the highlight of the meal, but even it tasted like it came from a factory, via a deep freeze.

The orange juice was that particular gloop that hotels give you for free. You know what I mean; it’s from concentrate, tastes like it is still too concentrated, and leaves you wishing you’d actually had orange juice to drink.

Needless to say, I was terribly disappointed. I had gotten it into my head that the Matthews cafeteria food I remembered from 14 years ago was what I was going to get. That the owners still took pride in making quality food, and serving it for a good price. Sadly, that’s not what happened. This leaves me with two possible explanations for how Guy Fieri could possibly rave about the food during his visit. 1. What they served him was tailored just for him, and is not what they serve to the average customer. 2. Guy is contractually obligated to only rave about the food he gets to taste on his show, no matter how odious it might actually be. Or maybe even a third option: the food was still good when the show was filmed, but they’ve fallen off a cliff in quality since then. I don’t know which one is more likely, but it doesn’t really matter. I won’t be going back to figure out which is correct.

Posted in food | Tagged , , , , , | Leave a comment

GV Places 1.3.2 Now Available

Last week a bug report came in that it was impossible to turn off notifications for automatic region switches. That is now fixed, and the update should be appearing in your list of updates.

It’s interesting that I spent 5 minutes replicating the bug, 10 minutes fixing it, another 10 doing all the necessary steps to get the app loaded into the store… and then a week waiting for it to be approved. I appreciate the app store for what it gives us, but it really shouldn’t take a week to get bug fixes out to users.

Posted in iphone | Tagged , , | Leave a comment

On Motivation

I just read this quote on Reddit from Neil deGrasse Tyson when asked about finding motivation. I love what he said.

The problem, often not discovered until late in life, is that when you look for things in life like love, meaning, motivation, it implies they are sitting behind a tree or under a rock. The most successful people in life recognize, that in life they create their own love, they manufacture their own meaning, they generate their own motivation.

For me, I am driven by two main philosophies, know more today about the world than I knew yesterday. And lessen the suffering of others. You’d be surprised how far that gets you.

The second paragraph sums up my philosophy, too.

Posted in life | Tagged , , , | Leave a comment

GV Places 1.3 Available in the App Store

After just a week in the Apple queue, version 1.3 of GV Places is now available. Here’s the list of what’s new:

  • Changed the screen order for adding a place. Now the phone number selection comes first, then the map.
  • Places no longer have to have geography associated with them.
  • A place can be designated the “default” place that will be used when no other places’ geography match the current location
  • When adding geography, the map can be searched, just like in the Maps app.
  • The list of places is now sorted alphabetically, rather than by how well they fit around the current location.
  • Completely rewritten calculations for determining if the current location is within a region, and for determining which of multiple overlapping regions is the better choice.
  • Removed most modal operations.
  • Much faster to start.

Posted in iphone | Tagged , , , , , , | Leave a comment

The Most Painful Thing I Ever Ate

Back before Christmas, I discovered a restaurant called Genghis Grill. It’s Mongolian BBQ, and it’s quite tasty. I eat there about once a week, because it is about a 10 minute walk from my office. Anyway, I was there today, and made the same bowl I always make. It had some thin-sliced beef, a metric ton of carrots and broccoli, some chickpeas, black beans and soybeans. As usual, I put a few dried red chile peppers on it. I never eat those peppers; I just like to have them mixed in during cooking to add some flavor.

While I was waiting for my food to cook, a few co-workers who were also there invited me to their table. Once the food arrived, I was talking and eating, and not really paying attention to what made its way onto my fork. You can see where this is going. At one point, I chewed up something that was kind of hard to chew up; sort of leathery. I thought to myself, “Man, they really burned that carrot.” It wasn’t a carrot.

About ten seconds later, it felt as if I were sucking on a blow torch. The entire left side of my mouth felt as if it were melting. My nose started running. My eyes started watering. I’m sure I was turning red in the face. One of my table mates asked, “Eat something hot? Need some more water?” I replied, “Yes. And the only thing that will help this is milk. Or vodka.” As I was chugging my water, knowing that it only provided momentary relief, I was poking around the bowl with my fork, looking for the other two peppers. They were not there. Apparently, all three peppers had gotten stuck together, and I’d chewed them all up at once.

It took a good fifteen minutes before my mouth started to calm down.

Posted in food | Tagged , , , | Leave a comment

No, Santorum, You’ve Got It Backwards

Today, the 9th Circuit Court of Appeals overturned California’s Proposition 8, which banned same-sex marriage. Frothy Republican presidential candidate Rick Santorum took to Twitter to share his wisdom on the subject, saying

7M Californians had their rights stripped away today by activist 9th Circuit judges. As president I will work to protect marriage.
@RickSantorum
Rick Santorum

Only a religious zealot homophobe like Santorum could frame the restoration of rights to millions of people as taking rights away from someone else. Heterosexuals’ rights to marry have not changed one iota by this decision.

Posted in politics | Tagged , , , , | Leave a comment

Three Songs From Anvil’s Show in Athens, GA on 02/03/2012

I went to see the awesome metal band Anvil last night at the Melting Point in Athens, GA. They played a great show, and here are three highlights. The first video is the first two songs of the night, March of the Crabs and 666. The second video is the Spanish Inquisition-themed song, Thumb Hang, which nobody expects. Check the videos out, and if Anvil comes to your town, definitely check them out.

Posted in music | Tagged , , , | Leave a comment

Fast Apple Customer Support

Today I bought the 24 song, 2.3 hour-long Van Halen record Live: Right Here, Right Now from the iTunes store. But there was a snag: “Why Can’t This Be Love?” failed with an error -100000. I tried restarting it a couple of different ways, but each time it would download it, then restart, three or four times, until it would finally choke with error -100000. I even downloaded the album on a Windows machine and 23 songs downloaded fine, but that one track failed with the same error. This pretty much proved to me that it was a problem on Apple’s end. I then went to my account in the iTunes store and reported an error with the track.

I received an auto-response pretty quickly with some things to try, but nothing useful. An hour or so later, I got an email from a human at Apple that basically told me to try what I had already tried and to let them know if I was still having problems, as well as providing some other info like ISP, Internet connection type, etc. I emailed them back with the details they asked for, and told them what all I had tried, including trying to download to another machine. I wondered how hard it was going to be to convince them that the problem was on their end.

A couple of hours later, I received another email, this time from a different human. I immediately assumed I would have to re-explain everything. Much to my surprise, this is what the email said:

I understand that you are unable to download the song “Why Can’t This Be Love” as your [sic] getting error -1000000. I know how eager you are to have this resolved at the earliest. I will be glad to assist you today.

Joey, please accept my sincere apologies for the frustration this download has caused. I took the liberty of removing the file causing the issue from your download queue. To give Apple time to investigate the issue and make any corrections that may be necessary, please wait at least two weeks before repurchasing this title.

I have issued a replacement song credit to your account. You can use the credit to buy a song of your choice from the iTunes Store.

So, while it kind of stinks that it could be two or more weeks before I can get the track replaced, it’s nice that they refunded me the money for the track so quickly. That’s nice, fast, customer service.

Posted in general | Tagged , , , , , | 2 Comments

New WordPress Sociable Plugin Has Unintuitive Setup

I got a notification this morning that the Sociable plugin for WordPress had a new version available, and did I want to install it. I try to keep my plugins updated, so I upgraded. Sociable now has two modes: Skyscraper and Classic. Classic is what you’re used to, with a row of icons under a post. Skyscraper is a tall and thin tower that lives in the left-hand margin of your site, scrolling along with the page. Skyscraper is the new default, but going back to Classic is what is unintuitive.

In your admin page, if you hover over the new menu “Select Sociable Plugin” you will see three options: Select Sociable Plugin, Sociable Options, and Skyscraper Options. Selecting the first one brings you to a page explaining the difference between the two modes, with ginormous buttons at the bottom to choose which version you want. Clicking the button for either mode takes you to the options for that mode, but doesn’t actually change which mode is selected.

At the bottom of each mode’s options page is a checkbox labeled, “Activate…” and the mode name. I assumed that checking the one for Classic mode was all I needed to do, but clearing my cache and viewing the page showed that not to be the case. You must also uncheck the “Activate…” checkbox on the Skyscraper options page to enable Classic mode. If you don’t uncheck it, then you will still get the Skyscraper showing up on your posts. If you decide to switch back from Classic to Skyscraper, you have to uncheck Classic, then go to the Skyscraper options page and check that one.

Since this is a binary choice, they need to have ONE place to enable one and disable the other, or at least explain to you that you have to take the extra step.

Posted in tech | Tagged , , , | 4 Comments

Write Your Congressmen: Please Do Not Support SOPA/PIPA

Depending on what sites you visit, you may or may not know that several sites have shutdown today, or have modified their logos, to protest SOPA/PIPA. These are bills before the House of Representatives and Senate, respectively, that would have a crippling effect on web sites that support user-uploaded content. Sites like Reddit, Youtube and Tumblr are just a few.

If you are concerned about Internet freedom, write your Congressmen. I just wrote both my Senators, Saxby Chambliss and Johnny Isakson, and my “representative” in the House, Rob Woodall. Here’s what I said (with SOPA and PIPA exchanged depending on the recipient):

I do not have a form letter or an eloquent defense of why you shouldn’t support PIPA. But from what I have read about PIPA (and SOPA, in the house), it is bad news for web sites that support user-uploaded content. In an effort to stop “piracy” of content, it places an undue burden on site owners that will cripple and/or shut down many sites. I am not saying piracy is not a problem or that it doesn’t exist. It does. But this bill is not the way to solve it.

Please do not support it.

I don’t really think that sites like Reddit, “going dark” for a day or Google slapping a black box over its logo will have much effect. Millions of people writing their Congressmen should have an effect, though without millions of dollars for lobbying, it remains to be seen how much of an effect it will have.

01/18/2012 1:13 PM Update: I just received this response from Senator Isakson’s office.

Dear Mr. Gibson:

Thank you for contacting me regarding intellectual property theft.  I appreciate hearing from you and I appreciate the opportunity to respond.

S.968, the Preventing Real Online Threats to Economic Creativity and Theft of Intellectual Property (PROTECT IP) Act of 2011, was introduced by Senator Leahy (D-VT) on May 12, 2011, and was referred to the Senate Judiciary Committee.  On May 26, 2011, it was reported out of Committee and is currently pending in the Senate.   The bill targets websites, particularly those registered outside of the United States, which are “dedicated to infringing activities.”  These rogue websites typically offer unauthorized downloading or streaming of copyrighted content or the sale of counterfeit goods including music, movies, and pharmaceutical drugs.

Websites targeted by this bill are foreign owned and outside the reach of U.S. laws despite the fact U.S. intellectual property is being infringed upon and U.S. consumers are the targets.  Rogue websites cost American workers jobs and cost businesses millions of dollars in lost revenue.  As online technology and commerce advances, we must see to it that injured parties have the ability to stop infringers from profiting from counterfeit products.  For example, a victim of infringement will have the authority to file a civil action against the owner or registrant of a rogue site.  If an order is granted by the court, third parties will be required to stop processing payments from the infringing sites, therefore, preventing infringers from collecting payments.  I will work to ensure that our laws our modernized to protect intellectual property, and will keep your thoughts on this bill in mind should it come before the Senate for a vote.

Thank you again for contacting me.  Please visit my webpage at http://isakson.senate.gov/for more information on the issues important to you and to sign up for my e-newsletter.

Sincerely,
Johnny Isakson
United States Senator

01/20/2012 4:40 PM Update: Today I received an email from Saxby Chambliss’ office. Here it is. Notice the bold text, which I added for emphasis:

Dear Mr. Gibson:

Thank you for contacting me regarding S. 968, the “Preventing Real Online Threats to Economic Creativity and Theft of Intellectual Property Act of 2011 (PROTECT IP),” and H.R. 3261, the ”Stop Online Piracy Act (SOPA).”  It is good to hear from you.

S. 968 was introduced on May 12, 2011, and referred to the Senate Judiciary Committee.  On May 26, it was reported out of committee and placed on the general legislative calendar.  If enacted, S. 968 would amend federal copyright law to authorize the Attorney General to file civil action against violators of copyright infringement law.

H.R. 3261 was introduced on October 26, 2011, and referred to the House Committee on the Judiciary.  On December 16, it was considered before the full committee; however, the bill was not voted out for consideration by the full House.  If enacted, H.R. 3261 would authorize the Attorney General to seek a court order against a U.S.-directed foreign Internet site committing or facilitating online piracy.

On January 23, 2012, a procedural vote on S. 968 was scheduled in the Senate; however, Majority Leader Reid announced that this vote will be postponed in order to allow for modifications to the bill to be made.  Furthermore, House Judiciary Chairman Lamar Smith announced that further consideration of H.R. 3261 would be postponed indefinitely.

It was always clear that SOPA and PROTECT IP needed to be perfected, and that legitimate concerns needed to be addressed before these bills could move forward.  Given this and my constituents concerns, it was always my intention to oppose moving forward until concerns had been addressed.  With the majority leader’s decision to postpone the cloture vote on the PROTECT IP Act originally scheduled for January 24, I withdrew my co-sponsorship to await the resolution of the outstanding issues.

I believe that online theft is a serious issue, and that Congress needs to make certain that our laws adequately protect the interests of rights holders.  When $58 billion in economic output is lost to the U.S. economy annually due to copyright theft of movies, music, packaged software and video games, and about one-quarter of all internet traffic is copyright infringing, there is a real problem that needs to be addressed.  I have complete faith that we will be able to work out a compromise in the future that addresses this, while still promoting free and open access to the internet. Should a bill addressing this topic come before the full Senate for consideration, I will keep your thoughts in mind.

If you would like to receive timely email alerts regarding the latest congressional actions and my weekly e-newsletter, please sign up via my web site at: www.chambliss.senate.gov .  Please let me know whenever I may be of assistance.

The bold part is interesting because he claims that he knew both bills were flawed and that he “always intended” to oppose “moving forward” until they were fixed. Given that he was a co-sponsor of PIPA, I don’t really think he’s being honest here. It seems a bit odd to be a co-sponsor of something you think is flawed.

Still, he’s withdrawn himself as a co-sponsor now, which is a good thing.

Posted in politics | Tagged , , , , , , , , , | 1 Comment

Once More, This Time With Clojure

If you happened to read my post from the other day entitled My New “Top Artists Last 7 Days” Widget, you know that I went through three iterations of getting it going. The final solution, written in Ruby worked well. Until bands like Motörhead, Mötley Crüe and Einstürzende Neubauten showed up in the list. At that point, the HTML parsing library I was using would barf, and processing would stop, leaving the list showing on the blog in an incomplete state. It wasn’t the library’s fault; apparently Ruby still has problems dealing with non-ASCII characters. I did everything I thought I needed to do to tell Ruby that it would be dealing with UTF-8 encoding, but it just kept right on barfing.

I was left with only two choices: stop listening to any band with an umlaut in the name (and God help me if any of my Scandinavian bands popped up, with the Ø or å characters), or rewrite the stupid program, again, in a language that I knew could easily deal with UTF-8.

Since I’ve been working in Clojure a lot lately, it seemed lika the logical choice. I spent about an hour working on it last night, and I ended up with a working program and a bit more Clojure experience. Here’s the program for your edification, with a description to follow:

(ns lastfmfetch.core
  (:gen-class))

(require '1)
(import '(java.io PrintStream)
        '(org.htmlcleaner HtmlCleaner))

(defn get-artist-and-playcount [cell]
  (let [title (.getAttributeByName cell "title")
        [match artist playcount] (re-matches #"^(.+), played ([\w\d]+)\s*\S*$" title)
        playcountStr (if (= playcount "once") "1" playcount)]
    [artist playcountStr]))

(defn get-url [cell]
  (let [links (.getElementsByName cell "a" true)
        a (first links)
        href (.getAttributeByName a "href")]
    (str "http://last.fm" href)))

(defn fetch-data [filename]
  (let [response (client/get "http://www.last.fm/user/joeyGibson/charts?rangetype=week&subtype=artists")
        cleaner (HtmlCleaner.)]
    (if (= (:status response) 200)
      (with-open [out (PrintStream. filename "UTF-8")]
        (.println out "<html><head><meta charset=\"UTF-8\"/></head><body><ol>")
        (doto (.getProperties cleaner)
          (.setOmitComments true)
          (.setPruneTags "script,style"))
        (when-let [node (.clean cleaner (:body response))]
          (let [subjectCells (take 5 (.getElementsByAttValue node "class" "subjectCell" true true))]
            (doseq [cell subjectCells]
              (let [[artist playcount] (get-artist-and-playcount cell)
                    url (get-url cell)]
                (.println out (str "<li><a href='" url "'>" artist "</a>, Plays: " playcount "</li>"))))))
        (.println out "</ol></body></html>")))))

;; Main
(defn -main [& args]
  (if (< (count args) 1)
    (println "Usage: lastfmfetch <output_file>")
    (fetch-data (first args))))

I ended up using a library called clj-http to handle the fetching of the URL. It’s a Clojure wrapper for the Apache HTTP Commons library, and was really easy to use. I’m using Leningen, by the way, so including clj-http was just a matter of including a line in the project.clj file. I also used a Java library called HTMLCleaner, that fixes broken HTML and makes it available as a DOM. Since it is also in Maven Central, it was easy to include by adding another line to the project file.

(defproject lastfmfetch "1.0.0-SNAPSHOT"
  :description "Fetch chart data from Last.fm"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [net.sourceforge.htmlcleaner/htmlcleaner "2.2"]
                 [ clj-http "0.2.6"]]
  :main lastfmfetch.core)

The -main function begins on line 38, but all it really does is check that there is a single command-line argument, and exits with a usage message if there is not. It then calls the fetch-data function, which begins on line 20.

On line 21, we declare two locals; one that will contain the results of fetching the web page, and one that is the HTML cleaner. If the fetch of the URL was successful, the status code will be the standard HTTP 200. If we got that, we then open a PrintStream on the filename given, specifying that it should be encoded with UTF-8. (I’ve been working with Java for a very long time, and I always assumed that since Java strings are Unicode, files created with Java would default to UTF-8. That is not the case. That’s why there’s a second argument when creating the PrintStream, and why I’m not using a PrintWriter.) We then print the first part of the output HTML file, set a couple of options to HTML Cleaner that cause it to strip comments, style and script sections from the HTML, and then start doing the real work.

On line 29, we declare a local called node that will contain the output of HTML Cleaner if it successfully parsed and cleaned the HTML. That’s what when-let does; it assigns the local as long as the function returns something truthy and then executes its body. If that function doesn’t return something truthy, the rest of the code is skipped. We then take the first five elements from the HTML that have an attribute called “class” with a value of “subjectCell”. These are table cells. We then loop over them, extracting the artist and playcount value, and the URL. We do these things in two separate functions.

The function called get-artist-and-playcount, starting on line 8, takes the table cell as input. It then gets the attribute called “title” and uses a regular expression to pull out the artist and playcount values. If the playcount is the word “once,” it converts it to a 1, so all the values are numeric. It then returns the two values as a vector.

The function called get-url, starting on line 14, also takes the table cell as input. It then gets all the “a” elements from the cell (there’s only one), and then gets the “href” attribute’s value, which is the URL.

Back at line 34, we take the three values we extracted with the two support functions and concatenates them together into HTML that will be a single line in an ordered list. We then output all the necessary closing tags to make the HTML well-formed, and we’re done.

While the Clojure code is a bit more dense than the Ruby code, it’s actually four lines shorter. And it handles Unicode characters, which makes me happy.

Posted in java | Tagged , , , , | Leave a comment

We Have To Get the Money Out of Politics

It costs a lot to get elected to high political office. A lot. So much, in fact, that a candidate has to either be independently wealthy, or they have to sell their souls votes to those who would finance their campaigns. This is one of the many things that is wrong with our political system. There is no possible way that someone like me could run for anything higher than local office; I don’t have the money, and even if some donors wanted to fund me, I would’t want to be beholden to them on their pet issues. So what do we do about it?

For one, we overturn the horrible Citizens United case. Senator Sanders is introducing a Constitutional amendment, called the Saving American Democracy amendment, to do just that, stating in no uncertain terms that to be considered a “person,” a pulse is required. It would forbid corporations from being classed as “people” and from donating to any politician. It will never pass or be ratified, but at least he’s trying. You should watch this video of him explaining it on the floor of the Senate.

The second is public financing of elections. I used to think this was a horrible idea, but upon more level-headed reflection, it’s the only way to go. Michael Moore has a post today about this very thing. The worst example of the amount of money in elections was Meg Whitman, running for Congress in 2010, who spent $119 million of her own money. You can’t compete with that, unless you also have access to that sort of money. If elections were publicly funded, and everyone who runs for office has the same financial limitations placed upon them, the need for obscene amounts of cash to campaign goes away. Now, I don’t know how the determination would be made of who counts as a viable candidate, since we can’t very well fund everyone who says they want to run for office. That would have to be worked out later. But, just like Senator Sanders’ amendment, this will never happen.

Third, we have to stop the “revolving door” between the Congress and the lobby. In that same Michael Moore post, he mentions Senator Michael Bennett, a Democrat from Colorado, who has introduced something he calls a Plan for Washington Reform that would, among other things, place a lifetime ban on former Congressmen from becoming lobbyists. You have to read this! I just developed a man-crush on Senator Bennet as I was reading it. The things he proposes would fix so many problems in Washington. That means, of course, it has no chance of passing.

Oh, one more thing. Have you ever wondered what sort of financial distribution there is among our elected “representatives”? In other words, how many millionaires are there vs. how many average joes. Here’s a handy chart to answer that question.

Anyway, this wasn’t the most eloquent explanation, but that’s what I think needs to happen. Go read Michael Moore’s blog post, then watch Senator Sanders’ video, then read Senator Bennet’s proposal.

Posted in politics | Tagged , , , , , | Leave a comment

Fizzing and Buzzing With Clojure

I’ve known about the FizzBuzz problem for a few years. I’ve written solutions for it in a few languages, but never posted them. I’ve been working with Clojure lately, and after reading articles about how many job applicants can’t solve a simple problem like this here, here and here, I decided to do a Clojure version. (It baffles me that someone who claims to be a developer can’t come up with a solution for this, no matter how good or bad it might be.)

I ended up doing it three different ways. The first is a simple first-cut solution. The second is somewhat better, I think, and the third is a refinement of the second. In all three cases, they use a nested function to do the evaluation, and return a lazy, infinite sequence. Here’s the first

(defn fizzbuzz []
  (map (fn [i] (cond
                 (and (= (rem i 3) 0)
                      (= (rem i 5) 0)) "FizzBuzz!"
                 (= (rem i 3) 0) "Fizz!"
                 (= (rem i 5) 0) "Buzz!"
                 :else i))
       (iterate inc 1)))

(doseq [i (take 100 (fizzbuzz))]
  (println i))

This solution does work, but I have a problem with the fact that the division tests are done twice. I think doing those tests twice increases the chances of making a mistake. The second version does the tests one time, assigning the results to locals. It then checks them for nil, and concatenates them together, relying on the fact that a nil will not print.

(defn fb []
  (let [fb1 (fn [n]
              (let [fizz (if (= (rem n 3) 0) "Fizz")
                    buzz (if (= (rem n 5) 0) "Buzz")]
                (if (or fizz buzz)
                  (str fizz buzz "!")
                  n)))]
    (map fb1 (iterate inc 1))))

(doseq [i (take 100 (fb))]
  (println i))

In this version, instead of passing an anonymous function to map, I assigned it to a local in a let expression. You can see that I only do the math once, assigning locals with either the appropriate word, or nil. I then check that one or the other of the locals are non-nil, cat them together and return it. If both are nil, the number itself is returned.

The third version is almost identical to the second. The only difference is that the second one used a let expression, and the third one uses a letfn expression. It’s effectively the same thing, but the third one is ever-so-slightly shorter, and I think every-so-slightly easier to read.

(defn fb2 []
  (letfn [(fb3 [n]
               (let [fizz (if (= (rem n 3) 0) "Fizz")
                     buzz (if (= (rem n 5) 0) "Buzz")]
                 (if (or fizz buzz)
                   (str fizz buzz "!")
                   n)))]
         (map fb3 (iterate inc 1))))

(doseq [i (take 100 (fb2))]
  (println i))

I don’t claim that these are particularly good solutions, though I do claim they work correctly. Any Clojure experts care to point out problems and/or offer suggestions?

Posted in tech | Tagged , , | 3 Comments

My New “Top Artists Last 7 Days” Widget

Note Redux: I changed my approach, yet again. Scroll farther down to see the latest.

Note: I changed my approach on this, so scroll down to see how I’m doing it now.

I’ve been wanting a widget or an auto-post on the blog for a while that would show my most-listened-to bands over the previous week. Tumblr users have had something like this for a while, and there were efforts to do this for WordPress before, but they either don’t seem to work with the latest versions of WP, or they only pulled top tracks (not artists), or they pulled album covers, instead of text. All of that is to say that I couldn’t find anything pre-made to use.

So, I had to roll my own. I did so in about 10 minutes using the PHP Code Widget and the script on this page. The only drawback to this is you have to get a developer account with last.fm, but it’s free, so no big deal there. I installed the PHP Code Widget , then pasted the script into a new widget. The only changes I had to make were to replace the appropriate bits in the script with my info, and to escape a couple of double-quotes. Now if you look down the right side of the blog, below the Twitter and Facebook links, you’ll see a rolling record of my top-artists. In case you were wondering what I’ve been listening to. :-)

The only thing I’m not sure about is how this will work with the two levels of caching I use (WP Super Cache and Cloudflare). I suppose we’ll see in the next few days, eh?

11/23/2011 Update: I decided that I didn’t like the way I was doing this, for a couple of reasons. First, each time someone viewed the page, it would be making a call to Last.fm for my stats. This is too often. Also, the values returned using the developer API were at odds with what you can get just going through the web. So what I did was write a Ruby script to pull the feed once a day, parse it and output HTML to a file. I then used the PHP Code Widget to include it. Far simpler, in my opinion.

Here’s the Ruby code:

#!/usr/bin/ruby

require 'rexml/document'
require 'open-uri'

include REXML

open("http://ws.audioscrobbler.com/2.0/user/joeyGibson/weeklyartistchart.xml") do |http|
	response = http.read
	doc = REXML::Document.new response

	index = 0

	File.open(ARGV[0], "w") do |out|
		out.write("<html><head>\n")
		out.write("<meta charset=\"UTF-8\"/>\n")
		out.write("<body><ol>\n")

		doc.elements.each("weeklyartistchart/artist") do |artist|
			break if index == 5

			out.write "<li><a href=\"#{artist.elements['url'].text}\">#{artist.elements['name'].text}</a>, Plays: #{artist.elements['playcount'].text}</li>\n"

			index += 1
		end

		out.puts("</ol></body></html>\n")
	end
end

and here’s the PHP that loads it:

<?php include("/tmp/artists.html"); ?>

That’s it.

11/26/2011 Update: Well, I’ve changed it again. I discovered that the RSS feed I was pulling is not updated with any sort of frequency. It certainly doesn’t represent the “last seven days” as it claims to. At any rate, it differs greatly from what Last.fm shows on the web. So I decided to grab the HTML and pull out the interesting bits. I wrote another Ruby script, this time using Hpricot to parse the HTML, which took about 10 minutes. So now, what you see on the right should be the current values for the “last seven days.” Here’s the latest script:

#!/usr/local/bin/ruby

require 'rubygems'
require 'hpricot'
require 'open-uri'

open("http://www.last.fm/user/your-username-here/charts?rangetype=week&subtype=artists") do |http|
  doc = Hpricot.parse(http.read)

  count = 0

  File.open(ARGV[0], "w") do |out|
    out.write("<html><head>\n")
    out.write("<meta charset=\"UTF-8\"/>\n")
    out.write("<body><ol>\n")

    doc.search("td[@class=subjectCell]").each do |subjectCell|
      break if count == 5

      artistString = subjectCell.get_attribute("title")

      artistString =~ /^(.+), played (\d+) times$/
      artist = $1
      playCount = $2

      subjectCell.search("a").each do |a|
        url = a.get_attribute("href")
        url = "http://last.fm#{url}"

        str = "#{artist}, #{url}, #{playCount}"

        out.write "<li><a href=\"#{url}\">#{artist}</a>, Plays: #{playCount}</li>\n"
      end

      count += 1
    end

    out.puts("</ol></body></html>\n")
  end
end

I’m hopeful this is the last change.

Posted in general | Tagged , , | Leave a comment

Lego VW Microbus

Thomas and I spent six hours this past weekend building this. It was my big splurge from our last trip to Disney World, back in October. What is it? It’s a classic, 1962 Volkswagen microbus. It was expensive, and had far too many pieces (1,332), but it was a blast putting it together. Now it’s sitting on my desk, where I can gaze at it and/or remove the roof and pretend it’s real… :-)

You can read more about the real microbus here.

Posted in life | Tagged , | Comments Off

A Sad Day: Steve Jobs Is Gone

It’s a sad day in the world. A visionary man has left us. Thanks, Steve, for all the great products that I use every day.

I wish I could take credit for the sad Mac image, but I found it here.

Posted in mac | Tagged , | Comments Off

JUnitLaunchFixer 1.0.4 Released

I’ve just released a new version of my Eclipse plugin called JUnitLaunchFixer. If you’ve never heard of it, it lets you set the default heap size for new debug launchers in Eclipse. You can read more about it in the original announcement. This new version fixes a bug that caused it not to accept new parameters in one case, and it also adds the ability to set a default for the maximum permgen size, which is something I’d been wanting to add for a while.

If you already have it installed, go to Help>Check for Updates in Eclipse, and you’ll see it. If you don’t have it installed, the update site is here:

http://junitlaunchfixer.googlecode.com/svn/trunk/JUnitLaunchFixer-update-site/

 

Posted in eclipse, java | Tagged , , | Comments Off

You’re Thinking Of…

 

Posted in politics | Tagged , , , | Comments Off

DirecTV’s Absurd Tech Support Script

I’ve been a mostly-happy DirecTV customer since 2001. In those 11 years, I’ve only had to call tech support three times, and the first two times were flawlessly executed. Those two times were a few years ago, and I was on the phone with them for less than 5 minutes before getting my problem solved.

That was then.

Yesterday, my wife turned on the TV in our bedroom, and got nothing but snow. It had worked the night before, and still had lights on it, so I first tried turning it off and on again. Nothing changed. I then pressed the red reset button. All the lights on the box went out and… nothing.

Then I pulled the power cord out of the back, waited about 20 seconds, and then plugged it back in. I could hear the fan inside the box come on, but still no lights on the box. I tried the buttons and the power button(s) on the remote, but still nothing. I let it sit for a couple of hours to see if it would magically come back on, but it never did. I resigned myself to a call to tech support.

It took me a couple of minutes to get through the phone tree and get a human. I explained the problem, including all of the troubleshooting I’d already done. In my opinion, I had done everything to prove that the unit had died. DirecTV didn’t share that opinion.

The first thing she had me do was turn on the TV and tell her what I saw: snow. Then she had me press the reset button: nothing. Then she said to pull the power cable out of the back of the unit and from the outlet. I told her that I had pulled the cord from the back of the unit, but that I could not unplug it from the outlet, because I would need to move a large armoir to do so. She then said that we could not continue the troubleshooting if I would not unplug it. This is when I started to get annoyed. I tried to reason this out with her, by saying, “Um, OK. Wouldn’t you agree that the fact that the fans are on inside the unit shows that power is getting to the unit?” She agreed. Then I said, “Which means that the outlet is good. There’s no reason to pull the plug from the outlet.” She then re-read me the script.

Now I’m getting pissed. I went through my thought experiment with her again, and again she agreed that it proved that power was getting to the unit. But she wouldn’t budge. I asked for her supervisor. The supervisor came on, and apart from saying, “I understand…” multiple times, she was no better than her subordinate.

At this point, I pretty much lost it. She said that if I “refused” to unplug the unit, then the only thing that could be done was for them to dispatch a technician to investigate. I then said to her, “Do you realize that if I had just lied to the first technician, we wouldn’t be having this conversation? This is absurd. I have proven that power is getting in to the unit. I would agree with you if the fan didn’t come on, but it does. That means the outlet is good.” She then re-read her script.

At this point, I blew a gasket. I told her how utterly absurd this was, but that since I apparently had no freaking choice, I would go move the damn furniture, unplug the cord, and call them back. After moving the furniture, and moving the plug, guess what happend. Nothing! That’s right, it worked exactly like it did the first time.

So I called them back, got a third person to talk to, and had her read the notes on the case. The supervisor had helpfully indicated that I had “refused” to complete the troubleshooting… grrrr…. I then told this person that I had moved the plug, and it still did the same thing: fans, but no lights or picture. She then had me check that the power cable was fully seated in the back of the unit, which it was, and then she wanted me to try plugging the other end into a different outlet, and plug something else into this one. Having learned my lesson, and having already done what she was now asking, I fiddled around with the cables, making some noise without actually doing anything, and then said, “Nope, same thing.”

She then authorized a free replacement unit, which I should have by Wednesday.

I understand that companies need tech support scripts. But when someone calls and clearly explains the problem, and has worked through all the scenarios, you have to allow your people to make judgments and go off-script to keep your customers happy. While on the phone with the first two people, I seriously considered telling them to cancel the service, and that I would get my TV elsewhere.

Posted in tv | Tagged , , , , | 2 Comments

Two Features To Make Lion’s Launchpad Perfect

One of the features in Lion that I didn’t think I would like has become one of my favorites: Launchpad. This is essentially Springboard from iOS, but for the Mac. It’s a nice iOS-like view of your /Applications folder, that you can get to by pinching on your trackpad using your thumb and three fingers. Once it opens, you see all your installed applications, with multiple pages, just like in iOS. Swiping left and right with two fingers switches between pages. Single-clicking an app runs it. Holding down Option makes the icons “go wiggly,” so you can move them around, just like in iOS.

The main problem is that you have to move apps around just like on iOS: one at a time. It makes sense on a touchscreen to only let you move one thing at a time, but on a traditional computer, it’s a limitation. My first suggested feature, then, is Apple should add the ability to select groups of icons and move them between pages as a group. It might also be nice to have a “consolidate” option that would just squeeze the apps onto as few pages as possible.

Which brings me to the second feature I’d like to see: pre-defined sort options. I like to have icons show up in alphabetical order, so having a menu option to “Sort Ascending” or something like that would be nice. I can also see something like sorting by most-recently used, so the apps you have recently used show up first. Or maybe a most-used sort, so those apps you use the most are at the top of the first page. Of course, they need an “as arranged” option so they show up how you arrange them.

These should be easy additions, and Apple should have already thought of them. I hope they will be in an update soon.

Posted in mac | Tagged , , , | 4 Comments