Mar 15 2010

HDMI out Sony BDP-360

HDMI out on my Sony BDP-360 BluRay player worked fine for a month or two, then mysteriously cut out. I’m still troubleshooting, and the unit may need repair, but when I contacted Sony support they sent me this link which has already been very helpful: http://www.kb.sony.com/selfservice/documentLink.do?externalId=C567099

It may be coincidence but twice in a row I held down the stop button for 10+ seconds then replugged the HDMI cable, and it came back. I have it on 720p now and if it doesn’t cut out again I’ll assume some kind of 1080p problem, e.g. I need a better cable or there’s some EM interference or something.

Tangentially, the player has a quirk in audio output. It refuses to send the full audio signal over HDMI to the TV, even though the TV passes a digital signal through to my receiver. I know this works because MythTV send Dolby Digital 5.1 audio through HDMI, which is then passed from the TV to my receiver unharmed. But I can’t get more than stereo downmixed dolby surround from this BD player, except if I hook up the digital audio out directly to the receiver. This is annoying because I have to switch the TV input source and the receiver both.


Mar 9 2010

My favorite bash idiom

Stuart and I came up with a refinement to my favorite bash idiom today. It was:

find ... | while read FOO; do ...; done

as demonstrated in:

find . -name '*.mp3' -type f | while read MP3; do
    ffmpeg -i $MP3 ${MP3%.mp3}.m4a
done

This handles whitespace (except newlines) in filenames. Except that ffmpeg is sharing stdin with while, which can cause some very funky problems. This is safer:

find ... | while read FOO; do echo | (
    ...
); done

and while you’re at it, you might as well take into account the unlikely-but-possible corner case of a filename containing a newline:

find ... -print0 | while read -d $'\0' FOO; do echo | (
    ...
); done

Feb 19 2010

Free File Fillable Forms

If you saunter on over to irs.gov you’ll see that there’s a new option for free electronic filing: Free File Fillable Forms (0xFFFF). Unlike the partnerships with companies like H&R Block which limit free filing by your income, this is free for everyone. And unlike those companies, you have to do all the thinking and math. Well, most of the math.

I did this with my taxes this year, mostly out of curiosity and because the notion of electronic filing user-filled forms is elegant and I think we should have been doing it for at least 10 years by now.

Alas, the implementation of this elegant idea is pretty shoddy. I went to FreeFileFillableForms.com via irs.gov and immediately hit a hurdle. While trying to sign up for an account, the captchas consistently failed. I’m not stupid enough to miss 5 captchas in a row. Just for kicks I did the audio captcha instead. Wow, that’s a thorough captcha—you have to type a whole phrase from a TV snippet from like 1955. I had to try 3 before I even had a good guess on all the words. (I’m betting you only had to get one word right, though.) That worked. Armed with an account I got started.

Or at least I tried to. It redirected me back to the login page. After a few times around the block I decided it was probably some kind of browser incompatibility, so I ditched Chrome and fired up Safari. That worked (it may have solved my captcha problem, too).

The interface is nothing sensible like PDF forms or standard HTML forms. It’s a flash-based GUI. Very slick in some places, but very deficient in actual usability. The most glaring problem is that you can’t type faster than about 20 words per minute or it goes all dyslexic on you. This is a serious problem. I had to triple check every word and number entered to be sure it hadn’t switched the letters around behind my back. Lest you think I’m a paranoid defective keyboardist, I watched it shuffle the letters around, like something out of the new Electric Company. I typed a word while watching the screen, saw it lay down the letters in the order I typed them, then watched in horror as it rearranged the last few letters. My hypothesis is that it’s doing some sort of input verification, but doing it poorly and rife with race conditions.

In spite of all my diligence, I missed the fact that it had rearranged my SSN at the top of the 1040, and so when I submitted it the IRS rejected it and I now have to go back in and fix it, recheck every number, and resubmit.

I said you do the math, which isn’t entirely true. You follow the instructions and the forms automatically do most of the math. But not until you actually press “do the math” (that’s very 1998). But it’s not very consistent about how helpful it is. Some forms automatically fill in your AGI, others require you to enter it manually. Some remember your filing status and enter the right number, others require you to do it manually. Basically, you have to try to enter every number and check box, and the only way you can tell whether you should have tried to enter it is by whether it pops up a little red tooltip telling you it’s going to do that for you, thanks.

All in all, with those major caveats, it worked well. The overall interface wasn’t horrible, the generated PDF when you print your forms is very nice, and I’m sure once I get my return right in spite of its buggy input validation it’ll file without issue. If they had just used regular HTML and Javascript like H&R Block does, it would have been more likely to be less buggy and more compatible with all browsers. I can recommend 0xFFFF, but only to the patient and diligent who really want that refund sooner rather than later. Otherwise go with the paper forms.


Feb 2 2010

Defeating the AC_CHECK_HEADER cache

The AC_CHECK_HEADER macro caches its result, so if you want to call it again with a different CPPFLAGS it will just remember the result of the first execution.

If you want to defeat this cache, as I did, this is the pattern:

header=foo.h
cache_var=AS_TR_SH([ac_cv_header_$header])
...
AC_CHECK_HEADER([$header])
...
CPPFLAGS="-I/opt/local/include"
$as_unset $cache_var
AC_CHECK_HEADER([$header])
...

AS_TR_SH does the escaping (giving ac_cv_header_foo_h in this case), $as_unset is the portable way to unset a shell variable in autotools.

Incidentally, if you don’t restore CPPFLAGS to its original user-set value, I will hunt you down and shave your head.


Oct 15 2009

Defeating the Anti-Autocomplete Demons

There are demons out there. They have sent their evil henchbugs to make my life difficult. The Santa Clara library login page for some unfathomable reason doesn’t trigger Firefox’s autocomplete. No, the HTML form doesn’t specify “autocomplete=off”. As far as I can tell, it’s just that Firefox doesn’t seem to think that my library barcode is worth remembering. Which is a real bummer because it’s impossible to remember and about as sensitive as the callus on my big toe.

So I got jiggy with GreaseMonkey and made my own autofill script:

// ==UserScript==
// @name Santa Clara Library Autocomplete
// @namespace http://hans.fugal.net/
// @include https://sccl.santaclaraca.gov/patroninfo*
// ==/UserScript==
name = document.getElementsByName('name')[0];
code = document.getElementsByName('code')[0];
name.value = 'Fred Flintstone';
code.value = 'Your impossible-to-remember-barcode goes here';


Oct 12 2009

Graph-paper Weight Loss

I think I’ve posted on this before, but I want to post my method for weight loss again, and try to do it in as few words as possible this time. If you want more information about the principles upon which I based this method, read Total Fitness in 30 Minutes a Week by Laurence Morehouse, and The Hacker’s Diet by John Walker.

First, why you should care: I lost 40 pounds eating whatever I wanted and have kept it off even after joining Facebook and eating up to 3 meals a day at the gourmet buffet plus micro kitchens.

Second, why you may not care: you want to lose more than 2 lb / week (good luck with that) or you are a masochist.

Here’s what you need: a piece of graph paper, a pencil, and a bathroom scale (digital is best). Oh, and a little patience and a small amount of willpower (much less than your average diet requires). To set up all you need to do is draw a line in the corner that goes over 5 squares and down 1 square for a weight loss rate of 1 pound per 5 days, you can choose any weight loss or gain rate that you want as long as it’s not more than 2 pounds per week. Obviously, the faster you lose the more willpower you need, but no matter how much willpower you have it won’t work if you go much over 2 pounds per week.

Here’s what you do every day: just after you wake up you use the bathroom and then step on the scale—before eating or drinking anything. Mark your weight on the graph paper. Then, imagine the line that best fits the marks for the past 5 days (least squares fit for you mathy types).

Is that line sloping down more steeply than your reference line? Congratulations: you can eat as much of anything you want today. Don’t gorge yourself, but don’t fret it. Want that ice cream? Go for it. Candy bar? Sure. Triple burger with guacamole? Ok, but think about making it a double man.

Is that line flatter than your reference line (or going up)? Then today you still get to eat (almost) whatever you want! But, we need to restrict quantity. In specific, we need to eat about 500–800 calories less than your normal intake. You can accomplish this easily by eating smaller portions at meals and skipping dessert.

That’s it. Fast forward 1 year and if you have stuck with the plan you will have lost as much as 70 pounds. But we know life (and holidays) happens, so be realistic and figure you’ll fall off the horse a few times. No big deal, this system is designed to keep your morale up and recover gracefully. To be safe, expect 40 pounds per year, then be pleasantly surprised.

There is no correlation between what you eat today and what you weigh tomorrow. Well that’s technically a lie, but there are much bigger effects than what you ate. Your weight will fluctuate as much as 2 lb due to various effects. You have no control over this. The method is not relying on any correlation between today’s diet and tomorrow’s weight. It is relying on the long-term effects of eating smaller portions approximately half the days (maybe even less). If you weigh more today it doesn’t mean you failed yesterday! If you weigh less today it doesn’t mean you succeeded yesterday! You have to take the long-term view and just stick with the program.

Now some short notes. First, exercise is a good idea. No, a great idea. Although it’s not essential to this plan, I think you’ll find it helps you with appetite control and to just feel better all-around. Second, eating healthy doesn’t hurt either, obviously.


Oct 8 2009

AC_TYPE_UINT8_T and friends

If you get errors like this:

$ autoreconf
configure.ac:110: error: possibly undefined macro: AC_TYPE_UINT8_T
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:111: error: possibly undefined macro: AC_TYPE_UINT16_T
configure.ac:112: error: possibly undefined macro: AC_TYPE_UINT32_T
configure.ac:113: error: possibly undefined macro: AC_TYPE_UINT64_T
configure.ac:115: error: possibly undefined macro: AC_TYPE_SSIZE_T
autoreconf: /usr/bin/autoconf failed with exit status: 1

It probably just means you have an old autoconf. These macros were introduced in autoconf 2.60. But it’s probably no big deal if you have a sensible stdint.h.


Oct 8 2009

EINVAL on sendmsg() to a UNIX Doman Socket

I’m seeing an EINVAL result when trying to do a sndmsg() call to a UNIX socket. The man page says that means that the sum of the iov_lens overflows an ssize_t, but an ssize_t is 8 bytes on this machine and there’s only one iov and its length is 671. Last I checked that doesn’t overflow anything but a char. What gives? Same code works fine in Linux and when using UDP or TCP.


Sep 28 2009

SIGABRT and gdb

So you fire up gdb and pepper your code with assert() calls. Then one of your assertions fails and you see this:

Assertion failed: (item_idx < si.slabclass[clsid].perslab), function ITEM, file slabs_items.h, line 78.
Program received signal SIGABRT, Aborted.
0x00007fff83efab16 in kevent ()
(gdb)

Well shucks, you think you're screwed because gdb doesn't seem to have left you in a useful state. So you investigate conditional breakpoints (that are a pain to set and don't seem want to work in inline functions), and generally beat yourself over the head for awhile.

Then you realize that gdb's throwing you out into a different thread, and your pretty backtrace is there for the exploring, you just have to switch to the right thread. Yeah, remember that. Then maybe you can set a breakpoint on the actual assert code (which you can find with the backtrace—it was __assert_rtn() in my case) so you're already in the right thread and just need to go up the backtrace one level to get to debugging goodness.


Sep 11 2009

Rental Deposits

Dear Internets,

I seek your advice regarding rental deposits. We left the property in decent condition and the managers want to not only withhold our deposit but charge us $200 to boot. What are our rights?

When we moved to Las Cruces we got lucky and found a great place managed by a great company, Doña Ana Properties. Somewhere along the line, the property was sold and the new owner switched management to the unscrupulous Mathers Realty. There was much mourning, but thankfully our stay remained uneventful until the end.

When we moved out everyone told us Mathers would weasel out of returning the deposit, so it came as no surprise when we received a bill in the mail explaining all the ways in which they deserved our money more than we did. What was surprising is that they didn’t stop at exhausting the deposit, but racked up an additional $200 in charges. They charged $100 for “repairs” such as “a towel [in the bathroom] needs to be removed,” “the blinds are broken,” (they had been replaced not two weeks earlier and were perfectly fine), “remove the pan from the oven,” (all our pans are accounted for—I’m not sure what they are talking about). Then they charged $95 to clean the carpet that we steam cleaned, and $95 for “janitorial services”—we left it clean.

There are a few things I would be (grudgingly) willing to give them: the blinds in the other bedroom that were broken but from normal wear and tear, a modest amount for painting (they charged $150, the lease said “minimum of $50″), a modest amount for “janitorial services”, etc. In fact, I’d be willing to let them take the whole deposit (we had written it off anyway, based on their reputation). But I really don’t want to send them a check.

Here is the only relevant text of the lease: “As a general rule, you will not be held financially responsible for repairs due to ‘normal wear and tear’ or routing maintenance. YOU WILL BE HELD RESPONSIBLE FOR THE REPAIR OF DAMAGE DUE TO YOUR NEGLECT OR MIS-CONDUCT.” and “The deposit may be applied to recover losses, if any, suffered by reason of the Tenant’s non-compliance with this Rental Agreement including non-payment of rent. [...] Refund of your deposit is contingent upon the condition of the rental unit after vacated. The condition of the unit will be compared to its original condition as stated on the check-in list. (i.e. carpet shampooed, cleanliness, condition of walls, damages, etc.). A minimum of $50.00 will be charged for painting upon move-out.”