So yesterday evening, hubby tells me that a house down the street was broken into last week during the day. I was just playing with Cale in the living room when I heard some thumps from the other end of the house. Whoops! Time to investigate! Since I was on the side of the house with all the doors, I wasn't too alarmed since it would be hard to get in my house right now without me noticing. But, ah, it was still time to investigate heavy mystery thumps. It turns out that Cale had turned on Roomba who is quite creative at getting stuck in unusual places. Roomba can escape the normal obstacles, but in this case had rather noisily climbed inside the sturdy metal circular base of the nursing rocking chair ... a regular Roomba prison!
Wednesday, September 16, 2009
Opt-out of Time-Warner/RoadRunner's DNS Hijacking
I am opposed to ISP DNS Hijacking for many reasons (DNS needs to be trustworthy, DNS needs to follow the RFC standard and return "Not Found" as specified especially since my browser would then tack on ".com" for me, I already pay TWRR more money for less bandwidth than most other developed nations so I resent this standards-breaking monetization), but luckily today I found the opt-out page. Thankfully it's easier and less intrusive than Comcast's opt-out.
A bright spot on a rainy day!
I was about to use the hosts file, like this tip. The bazooka approach would be to download this impressive ad-blocking hosts file and add http://ww23.rr.com/ to it.
Tuesday, September 15, 2009
Debugging Expect programs
So far, the best way to debug Expect programs seems to be to append " -d" the #! line. The output is confusingly verbose, but if I work through it one glob at a time, I can usually figure out what's going on.
Right now, it's that it's matching too early. So I think sleep 5 may be the needed breather.
PBworks migration
It was a good ride while it lasted (I was an early adopter), but it was time to move off the PBworks (formerly pbwiki) boat. My site was hard to read on my iPod touch, and the new 2.0 migration took away my ability to edit from my touch. I do most of my "personal" web browsing from my touch while Cale is nursing, but I don't do it often enough to want to pay for that feature. (I'm not fond of the 2.0 look either. I prefer simple. I think I'll be happy, possibly happier, with jottit, simpler than a wiki, and wikidot, so customizable and lovely page tags with a flying tag cloud, instead.) I decided that a lot of what I had in pbwiki didn't need to be online, so I decided to move it to Journler. I wish it were Alepin, but I want tags and Spotlight.
First I downloaded all of my files from my site (fill in your workspace name). I noticed that the zip file preserved the file modification times! Bonus!
I didn't like how Journler imported HTML (as an attachment to an otherwise-empty entry), though, so I decided to convert to RTF instead. I was sure it had to be easy on OS X, so after discarding non-simple Google results, I found textutil! Score!
I opened Terminal, and changed to the directory of my HTML files.
textutil -convert rtf *.html
mkdir rtfdir
mv *.rtf rtfdir
That was a nice start, but I lost the timestamps! I was sure I could keep those, and I know touch modifies timestamps ...
cd rtfdir
for filebase in $(ls *.rtf | sed 's/\.rtf$//g'); do touch -r ../$filebase.html $filebase.rtf ; done
Now to import into Journler ... no problem: my data are in the entry (not attached to it), and the timestamps are preserved as creation date! Not a bad piece of command-line tomfoolery to get exactly what I wanted without touching each file by hand. I like textutil!
Don't get me wrong: I think PBworks is a great service, and I don't think anything bad about it. But I know what features I want, and it was time for me to move on for my needs.
Tuesday, September 8, 2009
Anthony Bourdain Told Me So
I went to a nice Italian restaurant for lunch today. I told myself I had to order something other than my usual (rut) this time, and I reminded myself that I've always enjoyed the weekly specials. So when I saw the tuna panino on the weekly specials menu, I ordered it. To be honest, what drew me in was the toppings: arugula and roasted red peppers, one with a kick and the other with the mellow. I love those!
Anthony Bourdain says never to order fish on Monday. Since yesterday was the Labor Day holiday, today is a virtual Monday. And I ordered fish. And I've been going to the bathroom roughly once every other hour ever since lunch. I can hear the I told you so, and if I had remembered the virtual Monday-ness, I wouldn't've done it.
Come to think of it, it's been years since I've been happy with my food order when I've told myself to order something different before I saw the menu. Maybe the lesson is not to fight the rut: if the menu tempts me away from The Usual, I should branch out, but otherwise ... might be safer to play it safe. And I always order taco salad at Mexican restaurants because I want the largest pile of lettuce. (I love salad, mostly for the greens.) Last time I made myself branch out at a Mexican restaurant, I really missed the tall stack of fresh vegetables to lighten the meal.
Friday, September 4, 2009
Little Mysteries
Some days have little mysteries.
I was happy to learn the bash trick ${0##*/} to skip using basename (don't need to add dependencies), and once I learned more about bash substring removal, it made perfect sense. $0 (or ${0}) is the script name, as called, often with leading directory information. You need curly braces for substring removal, so start with ${0}. Use # for stingy prefix matching (the smallest match from the start of the variable), and ## for greedy prefix matching (the largest match). So ##*/ is the largest match of any character than ends with a slash. Since / is the directory separator, that greedy match removes all leading directories from the script name ... same as basename, but should be faster.
OK, so I feel like I've learned something! A small trick, but it weans me from excessive sed and awk too.
Yesterday's neat trick was shoving all of my command-line arguments into an array. Why an array? I kept losing the quotes around a string with spaces (user comment) with unexpected script results. This is why I test my scripts! So I don't have to worry about shift eating the script input, I'm in the habit of storing that input in a variable for safe-keeping; I'm now tinkering with an array for that purpose. (Yes, the implicit shift of getopts can be overridden with OPTIND=1, but $ARGS is immune to other tactics like set too.)
# save the args
ARGS="$@"
# or put the args into an array, space-preserving
typeset -a ARGARRAY=("$@")
The ARGARRAY is great: although I lose the quotes from the command line, the user comment is a single element in the array so it's safe as long as I quote that variable when I use it. But back on the bash string replacement track: using the command-line input argument array, I quickly noticed that the flags starting with a dash (hyphen) disturb some string matching routines. So since I know about greedy string matching now, I thought this should work:
typeset -a UNDASHEDARGARRAY("${@##-}")
It doesn't work. It still doesn't work when I escape the hyphen UDAA=("${@##\-}"); either way, the result is just the same as the stingy removal of UDAA=("${@#\-}"): just the first dash goes away. Phooey.
The only approach I've found that works is to use the substring removal twice in a row.
typeset -a UDAA=("${@##\-}")
UDAA=("${UDAA[@]##\-}") (also works with single octothorpes instead of pairs)
What also works is the overkill of removing all hyphens, leading or trailing or internal, with either
typeset -a ONE=("${@//-}") TWO=("${@//-/}")
However, internal hyphens don't mess up string matching, and might be significant. One or two leading dashes indicate a flag, an option to the command; any other dashes might be useful.
So my little bash mystery today is why these two arrays are the same with --long-flags:
typeset -a FIRST=("${@#-}") SECOND=("${@##-}")
I don't like these mysteries, but I know when it's time to get back to work. I have a work-around, so I'll use it.
UPDATE 14:09: looked at the strip_leading_zero2 () example function in the Advanced Bash-Scripting Guide to strip possible leading zero(s), and came up with a dash-prefix-stripper that works in one operation:
shopt -s extglob
typeset -a UNDASHEDARGARRAY=("${@##+(-)}")
I'll ponder that one, and check extglob before set then unset it after.
Thursday, September 3, 2009
September = Fall
I didn't know the weather was watching the calendar, but just as soon as the calendar flipped over to September, the weather turned into Fall. Usually summer has a long tail, Indian Summer, maybe a fall snap and then summer comes back for a few weeks ... but this looks like Fall is sticking around.
I love fall weather (early fall weather while it's still reasonably warm), but it's always so poignant since I know that cold winter weather is just around the corner. However, winter isn't as much of a drag in our house with a pretty view (I didn't know home location could make that much difference!) and with two kids enjoying it so much!