Tuesday, December 30, 2008

Studying human behavior

I loved this outline of the book Predictably Irrational, and I also love the idea of a Book Outlines Wiki.

I'm convinced that human society has let technology and science get way ahead of our understanding of human behavior. Far more engineering projects fail because of human foibles than because we don't have sufficient technical skills or resources to solve the problem at hand. Likewise, I bet more money is wasted due to ignorance of our own nature than due to technical inefficiencies in the market itself. So I'm always glad to learn more about my own biases and psychological inefficiencies.

Thursday, December 18, 2008

Birds probably killed by non-stick pan

Wow. I've never been too keen on non-stick pans. For good reason, apparently.

Wednesday, December 10, 2008

BYU excises photo exhibit of gay/straight portraits

BYU has always had to deal with a lot of dissonance as it tries to be taken seriously as a university and simultaneously a PR showcase for church values. Here's a rather bigoted take on a recent photo exhibit that BYU took down which featured unlabeled portraits of gay people and their straight friends, and a more apologist take from the Deseret News.

Tuesday, December 09, 2008

Picking quarterbacks and teachers

Interesting article on the difficulty of predicting who will make a good teacher.

Monday, December 08, 2008

Salary by profession, bachelor's degree only

Survey results for how much people make mid-career, broken down by college major. Fascinating! Chemical engineering tops the list, and the engineering degrees in general seem to dominate the top spots.

Monday, December 01, 2008

Friday, November 21, 2008

See the world with Google Street View!

I always wondered what Australia looks like!
And now I know.

Tuesday, November 18, 2008

Speculation on what a modern depression would look like

I hesitate to link to this article due to evil popups from boston.com (to DirectBuy of all things [shudder]), and also because I don't think there's a lot of value in worrying about how awful things could get, but I thought this speculation was interesting.

Sunday, November 16, 2008

More thoughts on the article about genius. It's so mind-blowing to think that gaining world-class skills in something is not only attainable for people, but even predictable. 4,000 hours works out to about 2 years of 40-hour weeks, and 10,000 hours works out to 5 years.

Of course, that assumes you can tolerate it for that long. I like to say that there are four important, independent considerations in picking a career:

  1. how much you like it,
  2. how quickly you can learn it,
  3. how long you can do it without getting sick of it, and
  4. whether you can make a living at it.

I found that I really liked musical conducting, and I could learn it quickly, but in the long run, couldn't do it for more than about an hour a month without getting burned out. And even though I don't like computers as much as some other things, I can do it all week long (although I still have to watch out for burnout).

Thursday, November 13, 2008

Quantum of Solace review (no spoilers)

So, I have movie hookups, and got to see the new James Bond flick tonight. Somebody was taking feedback after the movie, and I forgot to mention my strongest reaction to the movie:

I really hate seeing torture and extraordinary rendition in modern films: I think filmmakers forget how much life imitates art. And more fundamentally, they're subtly changing how we see it without admitting it:

"I hate to disappoint you," said Joel Surnow, an executive producer, "but we don't work that way. We construct our stories based on what's happening to the characters in a particular episode, and how they respond to the demands of their own personal challenges."

At worst, having action heroes endorse it is a deliberate attempt to manipulate our perceptions, and at best they just don't appreciate how much influence they have. Either way, I hope they'll think hard about the influence they have and whether they're improving the world with it.

Actually, no, I wish they'd stay out of it entirely. Action movies, particularly Bond flicks, are about heroic yet unrealistic adventures. Stuff blows up! People "die", but not really. Lately filmmakers realized that the choreography of it is what we like the most, and so we get films with lots of rockin' fight scenes and virtually no depiction of realistic suffering. I personally love that.

So I don't think action movies are a good medium to express the subtle, life-shattering horrors that actual cruelty inflicts. As a society, we need to make hard decisions about actual cruelty, and avoid the temptation to use movies and TV as a mental model for it.

Okay, enough of that rant. The movie is actually pretty good.

I like the new, grittier bond. I hate the shaky-cam at the beginning, but fortunately they ditch that quickly. They struck a good balance between keeping a complex grand scheme moving without losing those who can't keep track of the details.

There's also an over-the-top bad guy who's anviliciously evil (more than one, actually). I guess that's standard for Bond, but I found these obnoxious and tiresome.

So, worth the time to watch, decent action flick. Not earth shatteringly amazing, but one of the better Bond movies.

Wednesday, November 05, 2008

Freeing the airwaves one wave at a time

The FCC vote passed! Hooray for Free The Airwaves.

Sunday, October 26, 2008

Friday, October 24, 2008

Free the TV spectrum

Google has recently been promoting a very worthy cause: Free the Airwaves. With the move to digital TV this February, there will be really valuable spectrum available, and it's important that ordinary people get to use it, not just big companies.

If you've ever used a laptop with wireless internet access, you've used free spectrum. The spectrum coming up for grabs is much more useful than the spectrum used for wifi.

Please consider signing the petition and calling your congressperson to support this measure. The FCC will be voting on it November 4th, and the NAB is fighting hard to keep it from happening.

This is a cause that will make a really significant difference in your own life: it'll affect the kinds of gadgets you use in a few years, how easily they connect to each other, and whether you have to pay for the "privilege".

Saturday, October 18, 2008

Tarring up lots of duplicate files

Lately I've been building tar archives with lots of directories that have almost exactly the same contents (and it'd be impractical to reduce them to forests of symlinks). I was disappointed at how poorly the tarfiles compress, considering how many copies of the exact same data are there. Both gzip and bzip2 do poorly. (And zip is even worse, since it only compresses one file at a time.)

So I figured I'd give the compression algorithms a little help, by feeding in the identical files in groups. This works fine since tar doesn't care about the file order being different (even if the files are in different subdirectories).

1. I ran find -not -type d on the root directory of what I wanted to tar up, in order to get a list of files. -not -type d is important, since if you tell tar to tar up foo and foo/bar, it'll recurse into foo/ and pick up bar, then pack up foo/bar agin, and you'll end up with two copies of foo/bar in your tarball. Weird, eh? (Beware of symlinks and other non-file types when you do things like -not -type d, of course).

2. I wrote a little perl script to sort the list of files by their basenames (the "baz.txt" in "/foo/bar/baz.txt"), and put the list in /tmp/files.

3. I ran tar -jcvf foo.tar.bz2 -T /tmp/files

So, all the files with the same basename got tarred up together regardless of what directory they were in, and that was enough to give bzip2 the hint that they were thus very compressible.

How well did it work? Pretty well, at least for my present dataset:

In all I had 6100 files totalling 177MB (so an average of 30k/file), with each file duplicated about 100 times (so, 60 or so unique files). Doing an ordinary tar -jcvf produced a 94MB .tar.bz2 file, so about 2:1 compression. gzip fared almost as well, at 96MB.

After sorting the file list, gzip got down to 83MB, but bzip2 did much better: 17MB! So, it went from 2:1 compression to 10:1, just by sorting the file list.

For comparison, I also built a tarball with essentially one copy of each of the 60 or so unique files, and came up with about a megabyte. So, we should have been able to do almost 200:1, but 10:1 is still a big improvement over 2:1.

Of course, this trick only works if the identical files have the same filenames. But here's another trick: instead of sorting the files by base filename, sort by md5sum:

find ./tar-me-up/ -type f -exec md5sum \{\} \; | sort | cut -f3 -d' ' >/tmp/files

It's slower, since it has to read and hash all the files, but now all the identical files will be together regardless of filename.

Now, what'd be really great for me is if tar could run those checksums internally, and simply point to the contents of an earlier file when it encounters a duplicate. That would be pretty simple, but would break tar's streaming nature, and get complicated when it comes to modifying existing tarballs. Really it's the compression algorithm's problem to notice redundancy like that; maybe later I'll play around with bzip2 and see if it can be persuaded to do a better job of noticing patterns.

Friday, October 17, 2008

Gigabit ethernet port won't connect at 1000mbit

A while back I spent a few hours trying to figure out why my workstation was only connecting to the LAN at 100Mbit/sec. mii-diag unhelpfully reports 100baseTx-FD even when mii-tool tells me I'm at 1000baseT-HD, which is probably a bug in mii-diag, but in this case I was definitely connecting at 100mbit.

Anyway, today it happened again. Turns out it was the cable: gigabit ethernet uses all 8 wires in the cable, whereas 100baseT uses only 4. So I bet the cable I was using had a flaky wire in one of the wires used only for gigabit.

Thursday, October 16, 2008

Sunday, October 12, 2008

TV Tropes Wiki

I just discovered the TV Tropes Wiki, a very amusing encyclopedia of literary conventions.

Bechdel-compliant literature (also, the origins of Istanbul)

Tonight I heard a really fun quickstep version of Istanbul (not Constantinople). So I came home and looked it up on Wikipedia, and found out that it's been done by quite a lot of people, as it turns out: The Four Tops did it first, then Frankie Vaughan, Caterina Valente, Santo & Johnny (#141), Bette Midler, an avant-garde representation by The Residents, and more recently, Lee Press-on and the Nails.

Amusingly, I don't think any of those editions is the one I heard tonight.

But that's not why I brought you all here today. A while back I heard about The Bechdel Test, and recently it came up again in several conversations. While the actual list of Bechdel-compliant movies isn't particularly enlightening, it's a really interesting thought experiment to see how many books and movies you can list that follow Bechtel's Rule, and to notice (and wonder why) when things don't. Oh, here's the original article I read that introduced me to Bechdel, in which an ascending screenwriter learns that Bechdel's Rule must not be followed, and having considered the options, decides to leave behind screenwriting.

Saturday, October 11, 2008

Soros on the financial crisis

I thought this was a fascinating perspective on the economic situation:

George Soros and Bill Moyers

I love that they included the transcript. I started watching the video, but found that the transcript suited me better.

Sunday, October 05, 2008

On partisanship in congress

Interesting NY Times article on an influential member of congress who's decided not to run for reelection due to frustration with partisan politics in washington:
Tom Davis gives up. It reminds me of Larry Lessig who recently gave up copyfighting to fight political corruption. I'm glad we have people like that taking a stand.

Saturday, October 04, 2008

Loss of control fuels rituals, superstition

Here's a rather vague description of recent research into control and belief. The big elephant in the room with this article is that religion must have simply arisen in chaotic times, a sentiment I'm rather indifferent to. But it's an interesting thing to watch for in myself. It also supports the Eastern notion of cultivating acceptance of what happens to us, without trying to fit it all into a framework of meaning.

Drunk histories

I really find this series of 4 videos hilarious. Basically,
somebody gets drunk and then talks about a famous historical event. (Uses strong language).

Wednesday, October 01, 2008

If all movies had cell phones

A few swear words, but overall just funny as heck:

If all movies had cell phones.

Warning, includes spoilers for The Notebook and Fight Club.

Tuesday, September 30, 2008

Peter Norvig's election FAQ

Peter Norvig wrote up an interesting analysis of the presidential candidates, attempting to be unbiased. He endorses Obama, so watch out for a bias in that direction, but it seemed pretty fair and enlightening to me.

Monday, September 29, 2008

Where did the oracle/high priest concept come from?

Many ancient cultures (and quite a few modern ones) have the notion of a high priest who represents the people. He goes through cleansing rituals and rituals where he/she takes on the identity of the people. Then he enters a place where ordinary people can't go, a sort of portal between two worlds. There he/she meets with an oracle, who in some of the oldest cultures is represented by someone of the opposite sex. They join together figuratively in the modern interpretation, literally in the older one, and thus are the two worlds reconciled. Sometimes a child is produced, a demi-god.

This evening I got to wondering where such an idea might have come from, especially considering how firmly it took hold across all of humanity. Here's what I came up with: think of very primitive, tribal, nomadic man. Some tribes would be much more powerful and wealthy than others, and being strangers with them could be very dangerous. They distrust and fear one another. The weaker tribe wants to join, or at least, get on better terms with the stronger one. They meet near each other, but keep their distance. A representative is sent from each tribe after being cleaned up and festooned with symbols of their tribe's wealth (the Hebrew high priest wore a breastplate with a jewel for each tribe of Israel). They meet in privacy in a central no-man's land, and if they take to one another, potentially produce a child which both of them have an interest in protecting. If the meeting goes well, the tribes are on good terms and everybody's happy.

I have no evidence for that wild hypothesis, but it seems plausible. Perhaps someone can point out a reference to something with a more historical basis.

Thursday, September 25, 2008

Shuffle lines of a file

Where would I be without tab completion? Not only has it destroyed my typing ability, but today it helped me find a command I've wanted for a long time: shuf, which randomly shuffles input lines.

$ shuf /usr/share/dict/words |head -1

Tuesday, September 23, 2008

Why the 21st century is making you miserable

Another winner from cracked.com:

Why the 21st century is making you miserable

A lot of their stuff is just goofy fun in a very vulgar way; it's too bad that really insightful stuff like this is also vulgar enough to turn off more conservative readers.

Brainwashing in the election

The always entertaining (and vulgar) cracked.com has an article up about the manipulation techniques being used on both sides of the election:

6 brainwashing techniques they're using on you right now

(Warning: Sports Illustrated-level racy pictures and strong language)

Monday, September 22, 2008

Wandering Star covers

I heard a really cool cover to Portishead's "Wandering Star" the other day on KSJS, and today it occurred to me to try to track it down.

Kid Beyond does a pretty cool a cappella version.

I also liked Level's version.

Then I ran across this pretty amazing song after the manner of Portishead, with a pretty cool video to go with it: Nature Boy, by Peach Stealing Monkeys. They have some other cool songs too.

I never did find the cover I was looking for, but the Peach Stealing Monkeys stuff more than made up for it.

Update: Peach Stealing Monkeys emailed me back and pointed me at another version of Kid Beyond's cover of Wandering Star. I think that's the one I heard, although I didn't notice at the time that it's all a cappella. Thanks PSM!

California Prop 2 on cruelty to animals

Interesting viewpoint on raising animals for food, and a ballot measure I hadn't heard of:

A Farm Boy Reflects

Friday, September 19, 2008

How digital cash works.

Most people don't realize what amazing kinds of systems cryptographers have come up with over the years. Here's a good example of a way to create a mathematically-based digital cash system with a lot of desirable properties: you can't counterfeit coins without getting caught, we don't have to rely on a central database being up all the time, and best of all, as long as you don't try to cheat, your privacy is mathematically assured!

Secure, anonymous digital cash is real and has been implemented in the real world. In fact it's one of the things that got me into cryptography years ago. It's mathe-magical!

As others have pointed out, online, trusted third party (TTP) systems are an easy way to solve lots of security problems. Tamper-resistant devices are another "easy out". But in this case, there's a purely mathematical solution.

We have two goals: anonymous cash, and cash that prevents double-spending without an on-line authority.

Anonymity: an anonymous coin is one which you can withdraw from the bank, but which the bank can't link to you when you spend it. Sounds impossible, doesn't it? Blind signatures to the rescue. They allow the bank to sign the banknote using its private key without seeing the contents of what it's signing.

If you're scared of math, skip this part and trust me that it's possible to sign a message without seeing what it is. Otherwise, here's the math for how blind signatures work in RSA:

In ordinary RSA, e is the public exponent, d is the private exponent, and m^(ed) = m (modulo n, the signer's modulus) for all suitable messages m. A signature on m can be computed as m^d (mod n).

If I want you to sign m without knowing what it is, I pick a random r and compute r^e. I send you m*r^e and you sign it, returning (m*r^e)^d = m^d*r^(ed) = m^d*r. I divide out r and am left with m^d, the signature for m. You don't know r, so you have no idea what m is.

Okay, done with math for now.

Now, if the bank only uses d to sign, say, $1 coins, then it doesn't care what I chose for m, so it doesn't mind signing it blindly. m just becomes the serial number for the bill, and I pick it randomly each time. Now, I'm perfectly free to repeat a value of m, but the only person that hurts is me, since I'm just left with two copies of the signed bill.

When I want to spend the bill, I present m and m^d (the bill and the bank's signature for the bill) to the merchant, who verifies that it was indeed signed by the bank. He sends it to the bank while Alice waits, and they record the serial number to prevent double spending, but they have no way to link m with the blinded value m*r^e they signed earlier.

So there's anonymity. Now, to show off, we'll remove the need for the online double-spending check.

m now gets fancier. It's now a structured message having an encrypted message saying "Alice, account number: #123456789" and some other special fields. The 256-bit key k for encrypting the message is split into 2 128-bit keys k1 and k2. The special fields h1 and h2 are computed as hash(k1) and hash(k2). That is, they don't reveal what k1 and k2 are (because you can't work backward from a cryptographic hash calculation), but they let you know when you've got k1 or k2, since you can compute hash(k1) yourself and compare.

Alice creates, say, 1024 different versions of m that we'll call m0..m1023. Each has a unique k. She blinds each m with its own blinding factor b and sends them all to the bank. Each is called a "share".

Now we do what's called "cut and choose". The bank picks half of the shares at random and tells Alice to provide the blinding factors and keys for each of those. She does, and the bank verifies that each one matches the blinded values she sent earlier and that each of the keys decrypts properly, revealing Alice's name and account number.

Satisfied that she's not cheating (by putting a bogus name/account in the shares), the bank smooshes the blinded, unrevealed shares together and signs them. Alice gets back the smooshed value and the bank's signature on it, and is able to unblind each of the individual smooshed parts, leaving a completely unblinded smooshed up message and a valid signature for it.

Here's the math: assuming the bank didn't ask to see m0, m3, m4, ..., it'd give back:

((m0*b0^e) * (m3*b3^e) * (m4*b4^e)...)^d (mod n)

= m0^d * b0^ed * m3^d * b3^ed ...

As before, each b^ed = b, and she divides out the b values, leaving:


That is, the signature on the product of all the m values.

Still with me? Alice now has a signature on a bunch of smooshed-together shares, and the decryption keys for each share which reveal her identity. The bank's signature is valid, but the bank has never seen the unblinded value and thus won't recognize it as coming from Alice when it sees it later.

Alice goes to spend her $1 coin. She gives the signature to Bob the merchant, along with the shares m0,m3,m4... that make up the signed coin. Bob checks the signature on the smooshed up message and unsmooshes it into the separate shares. So far so good. Now, for each m, Bob picks at random and demands to see either k1 or k2 -- that is, half the key decrypting the message which would identify her. She complies, knowing that he has only half the key for any given message, so her identity is still safe. He computes the hash(k1) or hash(k2) and makes sure it matches what's in each m to make sure she isn't lying about the k values. Satisfied, he accepts the coin, and later, at his leisure, sends the day's spent coins to the bank. Alice securely deletes all the k values and goes on her way.

Now, what happens if she tries to spend the same coin twice? She gives the same signature
and m values to the other merchant, and he now demands to see one half-key or the other for each of the m values. With overwhelming probability, he asks to see the *other* half key for one of the m values the first merchant requested. Call that share m'. One merchant has one half of the key, and the other merchant has the other half. Later, when they each send their version of the spent coin to the bank, the bank will see that they're the same coin, and use the two key halves of m' to decrypt the message incriminating Alice.

Neat, huh? I simplified a lot, so if you want to get all the details, look up "Untraceable Electronic Cash" by Chaum, Fiat and Naor. Chaum actually put a fancier version of his system into practice, and I remember around 1995 downloading a Digicash "wallet" and $100 in play money to spend online in a trial run. He also had real vending machines and bus passes (iirc) in the
Netherlands, but ultimately Digicash went broke for the same reason I moved away from security: very few people actually care enough about security and privacy to pay even a little for it (and big companies like Visa have everything to lose if we have to shift to new ways of doing things).

Thursday, September 18, 2008

The Moral Mind

Interesting TED talk on social psychology. I think he's right on to point out 5 traits that predict political behavior, and I think we can learn a lot if we can identify when conflict boils down to difference of opinion on those traits:

The Moral Mind

At the end he appealed to people to be less polarized, but unfortunately, I think he did it in a way that will only appeal to liberals, by pointing out eastern thinking on the topic.

Hopefully conservatives won't get distracted by that part; there are plenty of Christian and traditional American values that say the same thing. The Good Samaritan, the Sermon on the Mount, the founding fathers all encouraged people to try to accept and understand the virtues that outsiders can bring.

Saturday, September 13, 2008

Great West Coast Swing song: Lemon Lime

This is a cool song in general, but also fun to dance to:

Lemon Lime, by Soul Coughing

Monday, September 08, 2008

Hallelujah! Actual journalism!

Why is it so hard to find good journalism anymore? Here newsday gives a neutral presentation of the positions Obama and McCain have taken. No BS about lapel pins or sordid affairs, just a succinct presentation of what each side has proposed to do:

Part 1: Examining key differences between Obama and McCain
Where do Obama, McCain stand on the issues? Part 2

Thank you Newsday! I even looked Newsday up on Wikipedia to see if they were all Secret Muslims or something. Nope, just respected journalists.

Friday, September 05, 2008

Thursday, September 04, 2008

Northern Tool sucks

I recently ordered some stuff from northerntool.com, and they've been spamming me with ads ever since, even after I asked them to stop. I was already skeptical about the quality of their products, and this seals the deal. When will companies learn not to abuse their customers?

Wednesday, September 03, 2008

Penn Jillette on presidential candidates

I like what Penn says about small government:

Last thing we need now is a great leader

We need to break the habit of asking what government is going to do for us.

Saturday, August 30, 2008

Thirteen Days

Thirteen Days is an excellent movie. That is all.

Wednesday, August 27, 2008

Advice for people joining new startups

This is *great* advice. I wish I had known this back in my startup days:
"So you're gonna code the whole thing..."

Monday, August 25, 2008

HD radio sucks

I just heard an ad for HD Radio, and consequently looked up the Wikipedia article. Bottom line: it looks very much like iBiquity rigged a sweet deal with the FCC to force everybody who uses HD Radio to license their patents.

Better yet, they're all lined up to sell radio stations gear for transmitting encrypted, subscription-based digital channels.

The biggest problem with all of this is that wireless "spectrum" is like the air we breathe: it's a Public Good and we can't make any more of it. Everybody can benefit from sending and receiving radio waves, and it's obscene how little space the government has made available to you and me. We get tiny little slices of less-valuable parts of the spectrum, and the rest gets divvied up to powerful companies who sell us access to it (cell phone companies, satellite TV), use it to advertise at us (radio and television) or use it internally to their own ends (fleet management, etc.).

Fortunately, Google is trying to educate people about the matter generally, and specifically trying to get public access to the spectrum coming up for grabs when analog TV stations shut off early next year: Free the Airwaves!

Thursday, August 21, 2008

Pegging packages in debian and ubuntu

I have a .deb package I built from sources, but I found that after installing, when I ran "apt-get upgrade" or "apt-get dist-upgrade" it wanted to reinstall the stock package. It took some searching, but I found the answer here:


To prevent a package from being upgraded,

$ sudo echo packagename hold | dpkg --set-selections

Friday, August 15, 2008

Foxconn sucks

Foxconn sabotages Linux in their BIOS. Wow, Foxconn sucks. Definitely a brand to avoid in the future.

Netflix FAIL

Wow. So, I logged in to my Netflix account specifically to thank Netflix for publicly owning up to their recent shipping problems.

But they don't provide any actual way to contact the company except over the phone (hold time: 7 minutes). So now I'm pissed and highly inclined to cancel my account. Way to piss off a happy customer.

Also, if you're going to only accept inquiries via telephone, at least state that up front (but that sucks; why should I wait on hold?). Don't make me manually crawl your site looking for a contact form.

If you want to actually make your customers happy, put up an email address. Not a web form, an email address. (Would you want your account reps to have to visit a different website for every response they ever send? Neither do I want to stumble around on your website for 20 minutes to find some crappy form to type in a message.)

Wednesday, August 13, 2008

Praise for find

I think this might be the most helpful warning message I've ever encountered:

$ find -name 'foo/bar'
find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name foo/bar' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ foo/bar'.

How to buy a new car and not get screwed

Great 5 minute video on how to buy a new car without getting screwed.

The language of discourse

I think we need to be wary of the new vocabulary that has been appearing of late. Words like "detainee", "harsh interrogation" and "lockdown".

When did we ever get to vote on whether to have privately owned prisons?

Ill and in Pain, Detainee Dies in U.S. Hands

A plea for compromise

Political discourse today seems to be dominated by polarized arguments and emotional appeals.

I got a message the other day promoting offshore drilling titled "Liberals block effort to help solve the energy crisis." The message closes with: "It is time that our 'leaders' put our families first!"

Wait a second. Preventing offshore drilling is an attack on the family? The sitting 8-year Republican president just now issued an executive order authorizing drilling, but the liberals are to blame for why we didn't do it years ago?

I have no idea what the right solution to the offshore drilling problem is, or even what the most important tradeoffs are. But I'm pretty sure it's not a vast left-wing conspiracy to attack the family.

Before I support an issue, I want to know both sides of the issue. I want to see the 2 pundits on the news show say things like:

pundit 1: "well, I support offshore drilling, but I know it comes at a significant ecological cost and so I can see why you'd oppose it"

pundit 2: "but you're totally right about the horrible human costs of importation from the middle east! So I'd like to see the 30% of the sites that have the lowest environmental impact be opened up, since they also happen to be the biggest ones."

pundit 1: "yeah, I think that's a great compromise. I'd set it higher, but now we're just splitting hairs."

Monday, August 04, 2008

Pineapple Express review

Just saw a sneak preview, and I wasn't very impressed. Too gory, and they were trying too hard. They had some great gags (one of the better of which they gave away in the trailer, unfortunately), but a lot of unnecessary gore as well, and a lot of overdoing the stoned scenes.

Saturday, July 26, 2008

The problem with tasers

While I don't mind much if people disagree with me, it bothers me a lot when a debate doesn't even include important aspects of a topic.

Tasers are a great example of this. Whenever I read an article about someone being apparently tasered inappropriately, the reporters only ever cover two topics: whether the use was excessive for the situation, and whether tasers are a serious health risk.

The question that seriously needs to be considered is whether tasers are cruel, and what their effects are on the shooter and the target psychologically, not just physiologically.

How does it affect someone when they have power and permission to deny someone the ability to control their body? How does it affect someone when, during a tense situation, they are suddenly and simultaneously shot with needles, suddenly in terrible pain, convulsing, and unable to control their emotions?

Lest you think this is merely a bleeding-heart liberal love-fest, consider it from the libertarian perspective: what is a police officer's role? Is it primarily to halt crimes in progress and bring the presumed-innocent suspects before a court for a speedy and fair trial? Or is it to be Obeyed by inflicting unlimited pain?

In other words, when I deal with a policeman, what is the proposition? Is it that if he feels he has probable cause, he can insist that I sit cuffed in the back of his car and be taken before a judge, using force if necessary? Or is it that I had better obey him, or he will hurt and subjugate me to himself?

The difference between coercion and cruelty becomes *more* important, not less, when Taser International, Inc. claims their product doesn't cause lasting harm!

Think about it: when that jerk cuts you off on the freeway, you sometimes get really ticked! And you probably want two things: you want him to stop doing that, and you want him to suffer (pay a fine, wreck his car, get yelled at).

You probably don't imagine yourself breaking his back with a club and leaving him crippled, or throwing acid in his face. That would be cruel... and unusual, as the constitution puts it. In fact, we don't even do those things to the worst criminals. Why? (That's a serious question -- what's your explanation as to why our system is set up that way?)

But what if you could hurt him from a distance... just a little. Press a button and give him a little jolt, let him know you didn't like what he just did. Nothing permanent. Tempting, isn't it?

If an officer (or if you) beat a man until he's crippled for life, it's quite obvious that serious harm has been done. Perhaps it was necessary, and we're damn well going to find that out. It's *obviously* a very serious matter, and there's no question whether it happened.

Bruises and broken bones from a club are likewise excellent indicators that force has been used. It's *obviously* a big deal to hit someone with a stick; you have to exert yourself to do it, and it's very personal. We intuitively know that hitting somebody is only okay if they're actively trying to hurt you.

But how much does 1.33 watts hurt someone when you push a button on the Taser X26? I love that the specification reads "Delivered into load: 1.33 watts". Don't think of the target as a person like you, think of them as a load for the main capacitors.

You should really read about the Stanford Prison Experiment if you haven't already. Science tells us in cold hard numbers that having immediate power over people changes us, especially when the people are considered criminals.

I don't think we understand how to control those changes yet; we sweep it under the rug and don't think about it. We make awkward jokes about getting raped in prison, and can only think to ask whether tasers kill people.

Are there situations as a cop in which a taser might prevent permanent injury to someone? Probably. Are there situations in which it's the least cruel option? Probably.

But I don't think that our society is spiritually mature enough to handle the temptation that goes along with total power over someone and infliction of pain at the push of a button. For the same reason that it's better to let a guilty man go free than to find an innocent man guilty, I think it's better to leave a permanent injury on a violent man than to have cruelty inflicted on a peaceful one.

Now, just to leave on a truly depressing note, look at what Taser International's latest offering to the military: Remote Area Denial. If controlling someone with the push of a button is psychologically dangerous, how do you think it changes when that someone is only a figure on a screen and the button is on a keyboard? Just like playing a video game.

Husky sucks

Another addition to the list of crappy tool brands. The Husky 26-gallon air compressor was broken out of the box: it can't get to 150psi, so it never turns itself off. I think the switch contacts are burned out now, because today it wouldn't turn on at all. After searching around, it's pretty obvious I'm not the only one who has had this problem.

Monday, July 21, 2008

Linux: libgphoto2 image capture from Canon EOS 1Ds Mark III

Here's the missing "hello, world" program for libgphoto2. I called it canon-capture, since I was working with Canon EOS SLR cameras, but it might actually work with anything supported by libgphoto2. Having to set-config capture=1 might be canon-specific, but the rest of the guts are pretty generic.

// compile with gcc -Wall -o canon-capture -lgphoto2 canon-capture.c
// This code released into the public domain 21 July 2008
// This program does the equivalent of:
// gphoto2 --shell
// > set-config capture=1
// > capture-image-and-download
// compile with gcc -Wall -o canon-capture -lgphoto2 canon-capture.c

#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <gphoto2/gphoto2.h>

void errordumper(GPLogLevel level, const char *domain, const char *format,
va_list args, void *data) {

vfprintf(stdout, format, args);
fprintf(stdout, "\n");

void enable_capture(Camera *canon, GPContext *canoncontext) {
int retval;

printf("Get root config.\n");
CameraWidget *rootconfig; // okay, not really
CameraWidget *actualrootconfig;

retval = gp_camera_get_config(canon, &rootconfig, canoncontext);
actualrootconfig = rootconfig;
printf(" Retval: %d\n", retval);

printf("Get main config.\n");
CameraWidget *child;
retval = gp_widget_get_child_by_name(rootconfig, "main", &child);
printf(" Retval: %d\n", retval);

printf("Get settings config.\n");
rootconfig = child;
retval = gp_widget_get_child_by_name(rootconfig, "settings", &child);
printf(" Retval: %d\n", retval);

printf("Get capture config.\n");
rootconfig = child;
retval = gp_widget_get_child_by_name(rootconfig, "capture", &child);
printf(" Retval: %d\n", retval);

CameraWidget *capture = child;

const char *widgetinfo;
gp_widget_get_name(capture, &widgetinfo);
printf("config name: %s\n", widgetinfo );

const char *widgetlabel;
gp_widget_get_label(capture, &widgetlabel);
printf("config label: %s\n", widgetlabel);

int widgetid;
gp_widget_get_id(capture, &widgetid);
printf("config id: %d\n", widgetid);

CameraWidgetType widgettype;
gp_widget_get_type(capture, &widgettype);
printf("config type: %d == %d \n", widgettype, GP_WIDGET_TOGGLE);

printf("Set value.\n");

int one=1;
retval = gp_widget_set_value(capture, &one);
printf(" Retval: %d\n", retval);

printf("Enabling capture.\n");
retval = gp_camera_set_config(canon, actualrootconfig, canoncontext);
printf(" Retval: %d\n", retval);

/* This seems to have no effect on where images go
void set_capturetarget(Camera *canon, GPContext *canoncontext) {
int retval;
printf("Get root config.\n");
CameraWidget *rootconfig; // okay, not really
CameraWidget *actualrootconfig;

retval = gp_camera_get_config(canon, &rootconfig, canoncontext);
actualrootconfig = rootconfig;
printf(" Retval: %d\n", retval);

printf("Get main config.\n");
CameraWidget *child;
retval = gp_widget_get_child_by_name(rootconfig, "main", &child);
printf(" Retval: %d\n", retval);

printf("Get settings config.\n");
rootconfig = child;
retval = gp_widget_get_child_by_name(rootconfig, "settings", &child);
printf(" Retval: %d\n", retval);

printf("Get capturetarget.\n");
rootconfig = child;
retval = gp_widget_get_child_by_name(rootconfig, "capturetarget", &child);
printf(" Retval: %d\n", retval);

CameraWidget *capture = child;

const char *widgetinfo;
gp_widget_get_name(capture, &widgetinfo);
printf("config name: %s\n", widgetinfo );

const char *widgetlabel;
gp_widget_get_label(capture, &widgetlabel);
printf("config label: %s\n", widgetlabel);

int widgetid;
gp_widget_get_id(capture, &widgetid);
printf("config id: %d\n", widgetid);

CameraWidgetType widgettype;
gp_widget_get_type(capture, &widgettype);
printf("config type: %d == %d \n", widgettype, GP_WIDGET_RADIO);

printf("Set value.\n");

// capture to ram should be 0, although I think the filename also plays into
// it
int one=1;
retval = gp_widget_set_value(capture, &one);
printf(" Retval: %d\n", retval);

printf("Enabling capture to CF.\n");
retval = gp_camera_set_config(canon, actualrootconfig, canoncontext);
printf(" Retval: %d\n", retval);

void capture_to_file(Camera *canon, GPContext *canoncontext, char *fn) {
int retval;

CameraFilePath camera_file_path;

// NOP: This gets overridden in the library to /capt0000.jpg
strcpy(camera_file_path.folder, "/");
strcpy(camera_file_path.name, "foo.jpg");

retval = gp_camera_capture(canon, GP_CAPTURE_IMAGE, &camera_file_path, canoncontext);
printf(" Retval: %d\n", retval);

printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name);

CameraFile *canonfile;

retval = gp_file_new(&canonfile);
printf(" Retval: %d\n", retval);
retval = gp_camera_file_get(canon, camera_file_path.folder, camera_file_path.name,
GP_FILE_TYPE_NORMAL, canonfile, canoncontext);
printf(" Retval: %d\n", retval);

const char *filedata;
unsigned long int filesize;

retval = gp_file_get_data_and_size(canonfile, &filedata, &filesize);
printf(" Retval: %d\n", retval);

int fd = open(fn, O_CREAT | O_WRONLY, 0644);
write(fd, filedata, filesize);

retval = gp_camera_file_delete(canon, camera_file_path.folder, camera_file_path.name,
printf(" Retval: %d\n", retval);


main() {
Camera *canon;

gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
GPContext *canoncontext = gp_context_new();

// When I set GP_LOG_DEBUG instead of GP_LOG_ERROR above, I noticed that the
// init function seems to traverse the entire filesystem on the camera. This
// is partly why it takes so long.
printf("Camera init. Takes about 10 seconds.\n");
int retval = gp_camera_init(canon, canoncontext);
printf(" Retval: %d\n", retval);

enable_capture(canon, canoncontext);
//set_capturetarget(canon, canoncontext);

int i;
capture_to_file(canon, canoncontext, "foo.jpg");

gp_camera_exit(canon, canoncontext);

Friday, July 18, 2008

Linux: Using the Canon EOS IDs Mark III with gphoto2

I've got the Canon EOS 1Ds Mark III capturing and downloading images via its built-in USB port (not via the external WFT-E2A ethernet/usb dongle) at just under 1fps (105 seconds for 100frames). The 21MP JPG images are 5.2MB each.

If I turn the JPG quality all the way to its lowest setting, the images are 1.5MB each and I get 100f/75s = 1.3fps.

$ gphoto2/gphoto2 --shell
gphoto2: {gphoto2: {.../gphoto2-2.4.2} /> } /> list-config
gphoto2: {gphoto2: {.../gphoto2-2.4.2} /> } /> set-config capture=1
gphoto2: {gphoto2: {.../gphoto2-2.4.2} /> } /> capture-image-and-download
New file is in location /capt0000.jpg on the camera
Saving file as capt0000.jpg
Deleting file /capt0000.jpg on the camera
Deleting 'capt0000.jpg' from folder '/'...
gphoto2: {gphoto2: {.../gphoto2-2.4.2} /> } />

I can also extract metadata for images on the CF card:

gphoto2: {gphoto2: {.../gphoto2-2.4.2} /store_00010001/DCIM/880CANON> }
/store_00010001/DCIM/880CANON> show-info 0N8H8866.JPG
Information on file '0N8H8866.JPG' (folder '/store_00010001/DCIM/880CANON'):
Name: '0N8H8866.JPG'
Mime type: 'image/jpeg'
Size: 3076382 byte(s)
Width: 5616 pixel(s)
Height: 3744 pixel(s)
Time: Thu Jul 17 09:54:58 2008
Mime type: 'image/jpeg'
Size: 3132 byte(s)
Width: 160 pixel(s)
Height: 120 pixel(s)
Audio data:
None available.

And once I set-config capture=1, I can see more config options:

gphoto2: {gphoto2: {.../gphoto2-2.4.2} /store_00010001/DCIM/880CANON> }
/store_00010001/DCIM/880CANON> list-config
gphoto2: {gphoto2: {.../gphoto2-2.4.2} /store_00010001/DCIM/880CANON> }

The gphoto2 maintainer accepted my patch to libgphoto2, so the Mark III will eventually work by default.

I can also download 160x120 image thumbnails from CF:

gphoto2: {gphoto2: {...le/jholt/gphoto2-2.4.2} /store_00010001/DCIM/880CANON> } /store_00010001/DCIM/880CANON> get-thumbnail 0N8H8846.JPG
Downloading '0N8H8846.JPG' from folder '/store_00010001/DCIM/880CANON'...
Saving file as thumb_0N8H8846.jpg

Thursday, May 22, 2008

Jet and Wilton power tools suck

I've gotta start reading more reviews before I buy power tools. I just paid over $700 for a Wilton 4210 disc/belt sander. It's cheaply made and poorly thought-out, especially for an $800 tool. A lot like the Jet horizontal band saw I paid $900 for. Apparently, Jet, Wilton and Powermatic are all the same company.

I picked it up at Tooland in San Carlos. They have more woodworking and metalworking tools than any of the other places I've seen in the south bay, although a lot of what they have is Jet/Wilton/Powermatic.

Delta seems to have sold out, as has Craftsman. So who do you go to for good benchtop power tools anymore? I love my Sawstop, and the Dewalt/Porter-Cable/Milwaukee stuff I've bought has generally been great, but none of them makes a benchtop sander as far as I can tell.