hmmm....

WebService::MobileMe Uploaded to the CPAN

Just a quick post to announce a new perl module I uploaded to the CPAN the other day. It’s still to be considered alpha quality as it is lacking error checking and other such necessary stuffs but is working for me.

Usage looks like:

1
2
3
4
5
6
7
8
9
10
11
use WebService::MobileMe;

my $mme = WebService::MobileMe->new(
    username => 'yaakov', password => 'HUGELOVE' );
my $location = $mme->locate;
print < <"EOT";
    As of $location->{date}, $location->{time}, Yaakov was at
    $location->{latitude}, $location->{longitude} (plus or minus
    $location->{accuracy} meters).
EOT
$mme->sendMessage( message => 'Hi Yaakov!', alarm => 1 );

The online documentation is available via search.cpan.org.

YAPC|10

I will be at YAPC|10 in Pittsburgh the end of June. Here’s a schedule of the talks I plan to attend. There are a few holes not because the talks at those time suck but because they rock so hard I can’t decide which I want to attend.

Old Google Calendar embed removed.

Playing a Tone Through an Arduino Connected Piezo

I’m working on a top secret project, all I’ll say is it involves the Arduino, Twitter, and the refrigerator, and needed to play a tone through a piezo connected to the Arduino. I looked around and the closest I could find was a tutorial that included code to play a melody.

This wasn’t quite what I wanted and the playTone function expects the notes and timing to be in global variables which makes the baby jesus cry. The premise was simple though. Take the period and divide by two then bring the output high then low for this amount of time, repeat to make up the desired duration.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int pinSpeaker = 10;

void setup () {
    pinMode(pinSpeaker, OUTPUT);
}

void loop () {
    playTone(750, 500);
    delay(750);
}

// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

This simple sketch plays a 500Hz tone for 750 mSec, pauses 750 mSec and repeats. To use it in your sketch simply define pinSpeaker and set it for output, copy playTone to your sketch and call it with the duration in milliseconds and the frequency in hertz.

I Am So Totally a Nerd

Somebody came into the IRC support channel for work and their nick was ‘turtle’. I made a logo joke and a co-worker corrected my short LOGO triangle. This prompted me to waste 20 minutes in a LOGO interpreter.

1
2
3
4
5
6
7
RT 30
REPEAT 3 [REPEAT 3 [FD 100 RT 120] RT 120]
PENUP
FD 100
PENDOWN
RT 90
REPEAT 360 [FD 1.75 RT 1]

The output:

logo

Pitz Prepares to Rock My Socks

Matt Wilson must be spying on my dialogs in sekrit IRC channels. After setting up Task this evening I mentioned there being several project ticketing systems, like Ditz, that store data in the RCS. I was lamenting the fact that there wasn’t any of these systems written in anything other than ruby that I was aware of.

Reading my RSS feeds before bed, I found “My new ticket tracking system is now vaporware” from Matt Wilson’s blog talking about Pitz, his soon to exist Python implementation of Ditz.

Please take a few moments to read over the feature set and example commands on the Pitz site and let Matt know about any ideas/suggestions you may have.

~/.bashrc Perl Module Version Tip

I often need to quickly check the version of a perl module currently installed. A while back I got tired of running:

$ perl -MPOE::Filter -E 'say $POE::Filter::VERSION'
1.2357

So I added a quick function to .bashrc:

1
2
3
pm-vers () {
    perl -M$1 -e "print \$$1::VERSION, \"\n\""
}

Now I just run:

$ pm-vers POE::Filter
1.2357

Git Diff and White Space

So I’m getting ready to make a commit to wxperl and I run a git diff to check on changes and git yelled at me that I had some trailing white space. Well it didn’t yell but it hi-lighted the white space in red. Way awesome!

git-diff-trailing-white-space

Net::Abuse::Utils v0.10 Released

I just released Net::Abuse::Utils v0.10 to CPAN. If you can’t wait, grab it here.

If you haven’t heard of this module before, see this online example of some of the data that can be returned. Online docs are available as well at search.cpan.org.

From the Changes file:

  • New get_domain function that converts host name to domain name
  • Memoize support though commented out by default, enable by uncommenting the following two lines in `lib/Net/Abuse/Utils.pm`
    1
    2
    
    # use Memoize;
    # memoize('_return_rr');
    
    A future version will likely allow Memoization via an export tag.

The get_domain function is fairly spiffy taking a host name like ‘michael.thegrebs.com’ and turning it into the domain name, ‘thegrebs.com’, but with proper recognition of second level zones like .co.uk.

The Memoization support is weak and I almost removed it but decided to leave it in but commented out for this release. It speeds up batch processing of large quantities of requests fairly well. Processing a days worth of spam used to take an average of 5 minutes and is now down to a minute and a half. This is quite a bit more increase than I expected as I am using bind with heavy local caching.

There were a few more changes mostly related to distribution related stuff, see git for the full gory details.

Not a horribly significant release but it’s been a while since the last one and I wanted to get get_domain out there.

Geeky Weather Station Stuffs

wxperl http://weather.thegrebs.com/

I recently received a nice Honeywell weather station. It turns out they are actually manufactured by a company called Irox which also sells stations under it’s own name but they seem to be more popular in Europe. Being a geek, one of the first things I did was check out Linux or OS X support. Unfortunately only one piece of software supports this weather station under Linux, Weather Display. There Linux software is freeware but not open source and leaves quite a bit to be desired but at least it would talk to the weather station and collect data from it.

With a bit of Googling I found Saratoga Weather which seems to be based on a template from Carter Lakes. Unfortunately the PHP code is a bit of a mess with 43 separate php files all in a top level directory and including each other. With a bit of work I was able to bend it to my will but every little change was a pain to accomplish.

I started slowly re-implementing things in Perl. I found an online WD data-file parser which greatly helped in figuring out what the fields in Weather Displays native log files meant. Fast-forward a couple of weeks and I think things are pretty much done feature wise. I lack NWS warning/watch/advisory notification, the thermometer image with today’s information is still PHP generated, and I don’t yet have a wind graph. These last few details shouldn’t take too much work when I get around to it. I also have a few features the original lacks, graphs, a daily tweet with today’s high/low, and sane code :p.

The information from my weather station is available online at http://weather.thegrebs.com/ and the source is available via git clone from http://git.thegrebs.com/git/wxperl. You may also browse the repo via Git Web at http://git.thegrebs.com/?p=wxperl.