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


Stepper motor
Originally uploaded by bluesterror

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


Sandwich bread
Originally uploaded by bluesterror

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!

I want my hexadecimal dollar

I’m taking the GRE this week as part of a foolish endeavor to possibly get more learning. Wow, have I forgotten lots of high school math. In preparation for the subject test, which I still haven’t signed up for, I picked up a copy of volumes 1 & 2 of TAOCP. I think these will be much better books once the MMIX versions are out in a few years. For now, they are hilariously antiquated as far as any of the MIX stuff goes. 6-bit (binary or decimal!) bytes, no stack, self-modifying code, punch cards, a weird assembly language that encodes the target registers in the opcode. It makes x86 look like a good ISA. Of course as Knuth says, the concepts themselves are timeless. And it does have me wanting to find a reason for using coroutines, so that’s something.