Never ever write a Java gui application with the requirement that you check fields before letting the user tab off of them. What a nightmare! Your only two tools, without rewriting large parts of Swing yourself, are FocusListener and InputVerifier. FocusListener is great for the case when you have two such fields. Set up bad data in each field, then watch the focus traversal war as a focusLost() method reclaims the focus for one component, causing focusLost() in the other component to fire. Fun. Then you have InputVerifier, ostensibly designed for this very purpose. Ignoring the fact that buttons still fire without the verifier getting called, now you have the awesomeness of not knowing what the target component would be. Want to build a view with multiple fields that get validated as one? Good luck with that.
Recommend fail
Amazon:
We recommend: Pony 8510BP Cabinet Claw (2-Pack) by Pony http://www.amazon.com/dp/B0000224BN/ref=pe_ar_x1 List Price: $73.77 Price: $54.39 You Save: $19.38 (26%) Recommended because you purchased or rated: * Align-Rite DG-101 Drill Guide with 3/16-Inch Holes for 12-Inch Drawers and Doors
New business idea: a collaborative filtering engine that lets you, the user, customize the idiocy away. Actually, eTantrum’s music recommendation app (Linux version only) had sliders to control the weights of various things. Still an awesome idea.
Update: yeah, amazon lets you customize it too. I still want sliders though!
resize wtf
I get amused whenever I see another open-coded version of this in our codebase, a method for determining the resolution of a scaled-down image while maintaining aspect ratio:
while (x > targetx || y > targety) {
x *= 0.99;
y *= 0.99;
}
It’s pretty easy to discern that it will take a lot of iterations to accomplish this task. In fact I put it around 250 * log (x/x')
where x’ is the target width. That’s maybe as many as 2000 FP multiplies depending on the difference in sizes between source and target image.
I guess computing the smallest scale factor and using it once was just too hard…
SF recap
I spent last weekend in San Francisco for a convention. Nope, not WWDC, or JavaOne. Angeline was giving a presentation at the American Diabetes Association conference, and I stole along. Here’s the breakdown:
day 1:
Landed in SF about noon localtime after many hours of flight. Took BART to the hotel, checked in and headed to the conference for registration. Then off to the Mission district for lunch at Tacqueria Can-cun, where the burritos are excellent. Too full and tired for dinner, we went to bed early.
day 2:
Walked around the city a lot, saw a 15-person “parade” in Chinatown. Homeless guy said of me, “I can tell, that guy is law enforcement.” Met DA for lunch at Mo’s grill, then chilled in the park. Homeless guy tried to sell us his “book” — aka stapled sheets of paper — of poetry. Saw several random people on the street not wearing clothes, and ballet dancers. Got a nasty sunburn.
Went to Sultan’s for Indian food – not bad, but the place was empty. Cheaper place next door, Naan & Curry, had all the business.
day 3:
Hopped on BART this morning, then took Caltrain to Mountain View. There, in the drab, continuous office park that is Silicon Valley, just a few blocks south of the Googleplex, is the Computer History Museum. Wandered through it taking pictures of computers from my childhood, and saw a demonstration of a Babbage difference engine.
Went to R&G Lounge in Chinatown for dinner with Ange, her sister, and a third doctor. Food was great but the staff was a little bit racist. (They are only serving the red bean soup to persons of East Asian descent now? And, “Fried noodles are crunchy. I recommend the soft noodles for you [, white guy].” WTF.)
day 4:
Met up with more doctors for lunch in the mall near the conference center. Quite good for food court.
Ange had her presentation at 5pm. I sneaked in with her sister’s badge, which I had to flash at Security. Thankfully, they didn’t ask why I had a girl’s name. Angeline gave an excellent talk though all way over my head.
Had dinner at Ame, very expensive but possibly the best food we’ve ever had. Sashimi, potato soup, black cod, braised pork cheeks, chocolate cake and rhubarb-strawberry pie were consumed.
day 5:
Sitting here on the plane back. Not writing complete sentences.
Some photos of computers are on my flickr stream.
Going to California
We’re in San Francisco this weekend through Tuesday. If anyone else is, or has suggestions of locations to visit, drop me a line.
Stepper motor
For a future project, I pulled a stepper motor from an old 3.5″ disk drive and hooked it up to my Arduino. Turns out it’s quite easy to control these things: just periodically write bit patterns 1010, 0110, 0101, and 1001 to the 4 control wires and you’ve got a spinning motor.
I also baked six loaves of bread this weekend thanks to a cooking class on Saturday. I’m drowning in potential croutons.
brevity
I’ve been a slacker, so here’s the 10 second update:
Iron man was good. You knew that two weeks ago.
Ange and I had our immigration interview for her green card. We’re on tenterhooks right now hoping that we get an affirmative answer quickly. (Fun fact: a tenter was used to stretch cloth in the 14th century and the tenterhooks were, I guess, hooks on it. Isn’t history fun!)
We also watched LOTR all week. Still awesome.
Nerd-cool stuff I’m playing with lately:
- UML – user mode linux, I hope to get this up and running so I can script git-bisect
- coLinux – like UML for windows, which I want to use for a distcc compile farm setup at home. Alternately, someone on lazyweb can port distcc for me?
- oprofile – profile your whole box, great for ‘why is X using 90% cpu’ and ‘did ath5k_rx_tasklet ever get called?’
- ccache – Java needs this
Meh
I’m playing with date conversions today, and again I’m struck by how much the Java Calendar should be held up as an example of the over-engineered API. Has anyone ever used anything besides the Gregorian calendar? They were so proud of it when it hit 1.1.
I should have two patches hitting kernel 2.6.26, one entirely cosmetic and one that fixes a real bug on Atheros wireless cards. Akpm did pick up the OMFS patchset so hopefully that will go in .27 timeframe, though the jury is still out on whether it hits mainline.
In other news, take that, Skype!
XMLization
The libpam-mount configuration file has changed to a new XML format.
Aaaaaaghhh, no!!!!
Make your own bread
I tried making sandwich bread this weekend since we forgot to buy it from the grocery store. With a stand mixer, this was not hard at all, and it rocks our socks. Oh, the BLTs I am going to make with this!