Archive for the ‘politics’ Category

Automatically refreshing election results in San Francisco

Tuesday, November 7th, 2006

I’m at a post-campaign party right now, and we’re all huddled around the computer watching the San Francisco election results. At first, the common injunction to whoever was sitting at the computer was to “hit refresh” to see if new results were posted. I quickly tired of hitting refresh, so I cooked up a small CGI script to fetch the results, and embedded them in a page to automatically update.

The CGI is pretty simple. The nice thing about the San Francisco results is that they’re plain text embedded in a pair of <pre> tags, so all the CGI has to do is grab the text between the tags:
#!/usr/bin/perl -w

use CGI;
use LWP::Simple;
use Time::Piece;

# Get results from between


my $sf_results_html = get ‘’;

my @htmlbeforepre = split ( ‘

', $sf_results_html );
my @htmlafterpre = split ( '

‘, $htmlbeforepre[1] );
my $sf_results_txt = $htmlafterpre[0];

# write up page, with date
my $page = new CGI;
print $page->header;
print $page->start_html(‘SF Election results’);

my $t = localtime;
print “Date retrieved by CGI = $t\n”;

print “\n

print $sf_results_txt;
print "\n


print $page->end_html;

Then, to automatically refresh it, I embedded in an server-side include that refreshed every three seconds. (Though, on further reflection, perhaps I should have set the timeout to be longer.)

Auto Refreshing election results

Page generated on

Robo-caller, meet Asterisk. And then go to a special circle of hell.

Monday, November 6th, 2006

Clearly, for people who use automatic robot callers to send you recorded messages deserve to go to hell. If somebody with the right connections is reading, I’d like to propose construction of an extra-special circle of hell for people who use mis-programmed auto-dialers. The Barrington Courier-Review (Illinois) is reporting that some political telemarketing machines will call you right back if you don’t listen to the whole message.

The campaign caught making repeated phone calls has blamed the telemarketing contractor, saying that it was obviously a mis-configured computer. Well, those campaigns can retain their mis-configured computer, because my correctly configured Asterisk machine will handle the calls appropriately. I’ll make my voting decision in peace, by reviewing sources of information I trust. (Hint to campaign managers: this probably is not you.) Please, make as many calls as you want. My computer is happy to listen to you spew your message, and it will deliver it to me if it is appropriate. I have programmed my computer with an algorithm that is working quite well so far, namely, that all telemarketing calls should be discarded.

However, there’s clearly a reason why these calls get made. Somebody has to believe that they work, which means that they’re either effective or cheap. Thudfactor says that a robo-call is only five cents per call, though I’ve also heard figures between one and two cents per call. No wonder they’re so depressingly common. The Center for Information and Research on Civic Learning and Engagement (CIRCLE) says that

[t]he most effective way of getting a new voter is the in-person door knock by a peer; the least effective is an automated phone call. Canvassing costs $11 to $14 per new vote, followed closely by phone banks at $10 to $25 per new vote. Robocalls mobilize so few voters that they cost $275 per new vote. (These costs are figured per vote that would not be cast without the mobilizing effort.)

(The figures cited are a study of the youth vote, which may not necessarily be representative of the whole voting population.)

Defeating telemarketers with Asterisk

Tuesday, October 31st, 2006

One of the reasons I initially started using Asterisk at home is that I was tired of telemarketers. Most telemarketers have been deterred by the national (U.S.) do not call list. However, the do not call list has two important exceptions for political organizations and charities (see question 29 on the FTC’s Q&A).

The exception for politics is a huge hole in California. In addition to all the candidates for public office, we typically are faced with a slew of ballot propositions. In this election cycle, there are thirteen state measures and eleven city measures in San Francisco, to say nothing of the actual people running for office. I think a majority of the money and effort is spent on the referendum side of the ballot, since text inserted into the state constitution, city charter, or California legal code never develops an annoying conscience and turns on its financiers.

Now that it’s the final push in the electoral season here in California, I’m sure the calls are flying furiously. However, I sit in blissful silence at home with a phone that’s not ringing. When you call my house, Asterisk picks up and asks you to enter an extension number or use the dial-by-name directory. If you don’t do either of those tasks, you can’t make the internal extensions ring.

Initially, I had expected that guarding the phone was going to be hard. I thought it would require validating caller ID, checking it for correctness somehow, and possibly even doing a “liveness” proof that generated a random string of digits for the caller and requested that the caller enter them back to you. It turns out that there’s a much simpler and easier way. Most mass-dialing operations use predictive dialers or robot dialers. Neither type of device is capable of understanding and reacting to speech appropriately. All I needed to do was to pick up the phone, read out an extension number (“hello, you’ve reached this phone number, dial extension 123 to talk to person #1“), and wait for a response. Most computer dialers are not able to intelligently process the voice, so Asterisk hangs up on them.

Here’s the essence of the code I use:
mainmenu => {
NoOp(Received Caller ID is => ${CALLERID(all)});

// Caller ID checks and Iotum processing left out for clarity
// Friends and family menu check goes here

// My voice menu — default for most callers

So far, that simple voice menu does the trick. I haven’t needed to modify the code yet so that when it detects a telemarketing computer, it plays the “disconnected number” tones with the Zapateller application.