Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
Just playing around. It's not overly useful, but it's nice to see it work (and it's fragile). Replace 'some_user_name' below to ignore the user of your choice. No, it doesn't have a lot of features, but it was fun to write
// ==UserScript==
// @name ignore.use.perl
// @namespace http://publius-ovidius.livejournal.com/
// @description Hide Annoying Users
// @include http://use.perl.org/*
// ==/UserScript==
(function() {
var user = 'some_user_name';
var href = '//use.perl.org/~'+user+'/';
// I want zero-width positive look ahead assertions in XPath. That
// would eliminate the awful parentNode.parentNode.parentNode;
// Does this feature exist and I just don't know it?
var divs = document.evaluate(
"//div[@class='full']/div/div[@class='details']/a[@href='"+href+"']",
document,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null
);
for ( var i=0; i < divs.snapshotLength; i++ ) {
var node = divs.snapshotItem(i).parentNode.parentNode.parentNode;
node.innerHTML = '<p><strong>Ignoring '+user+' via GreaseMonkey</strong></p>';
}
})();
I want to do more work on Test::Kit, but right now, Schwern's started a very interesting discussion on the Google Test::More project which could eliminate many of the hard parts of this module. I'll keep you posted.
Does anyone use App::Prove::State, module which ships with the new Test::Harness? Outside of the Test::Harness distribution, the only code which I know of which uses it is a quick "which tests are slow?" hack I put together.
I ask this because I'm making some internal changes to this module. I am giving it a proper API to let people extend it in the future. I need to add new features for it, but said features can't live in the core (due to non-core dependencies) and as a result, I need to nail down the interface, but if anyone else is using it, I'd like to not cause them too much pain.
Because of some weird mental block, I'm always forgetting the syntax of the prototype command. Thus, I now use this bash alias:
alias prototype="perl -le 'print prototype qq<CORE::@{[+shift]}>'"
And from the command line:
$ prototype bless
$;$
Hmm, bless has a prototype, eh? I should try to override it. I might just be able to create object instantiation graphs with this.
It's just a minor change that both Andy and I have wanted for a long time, but I do wonder if it will impact others. Instead of seeing this (use.perl inserts extra spaces, so this might not line up right):
t/proverun......................ok
t/regression....................ok
t/result s.......................ok
t/scheduler.....................ok
t/source........ ................ok
t/spool.........................ok
t/state................. ........ok
t/streams.......................ok
You'll see this:
t/proverun
.................... ok
t/regression.................. ok
t/results..................... ok
t/scheduler................... ok
t/source...................... ok
t/spool....................... ok
t/state....................... ok
t/streams..................... ok
Both of us found this much cleaner. However, this might have unexpected consequences. It also highlights the issue of Test::Harness's long-standing practice of stripping the
(Note: what follows is why I am tired of Apple. It may not apply to you, so don't grumble at me for it
I think for my next laptop, I may just go back to Linux. Apple is really disappointing me.
Before I worked for Kineticode, I had a Sony Vaio running (I think) Debian with the delightfully minimalistic Fluxbox window manager. It wasn't perfect, as I had Linux experts give up trying to get my wireless working and Alsa was just a pain and configuring X was
Well, you get the picture. Then David Wheeler, my boss at Kineticode, handed me an iBook. Prior to that my only exposure to Macs had been a girlfriend's Mac which ran System 7. I was dubious about the iBook, but I quickly came to love it. It had the ease of use of Windows but all of the power of Linux (well, all of the power that I needed, that is). It wasn't perfect, but I was pretty happy with it. Sure, lots of things needed X, but hey, I quickly installed that and most of my complaints were gone -- I'm easy to please. Of course, when Fluxbox was segfaulting, I went to the source, fixed the problem and recompiled and I can't do that with Macs, but hey, it's a small price, right?
When I went to buy a new laptop, I upgraded to a MacBook, bought extra RAM and the extended warranty. The first problem I noticed was no WiFi connectivity. This, apparently, was a common problem for MacBooks. It was several months of software updates from Apple before they sorted this mess out and this annoyed the heck out of me because the one thing you don't screw up is people's connectivity.
Of course, this is not the first time Apple's neglected this. Anyone remember the Titanium PowerBook G4 whose metal case looked sexy as hell and killed Wifi connectivity? Don't screw this up, Apple, just don't.
Recently I wanted to install Gimp, which means I need X, which means I need my install disks, which means I need to figure out how to eject the CD currently in my MacBook. Not only is "non-ejecting" CDs a common problem for the new MacBooks, but Apple removed the manual eject hole that older laptops had. This problem would be much less severe if they hadn't done something so stupid. I still need to get to the Apple store and get this fixed, but I'm afraid they'll take my laptop for days on end. I'm an addict, damn it!
So I have iTunes, too. I decided it would be nice to get the album cover art. Turns out I need an Apple Store account. Grumble. OK.
Then it turns out that I need to enter payment information to receive my free cover art!!! What the hell? Apple? Why are you forcing me to fork over financial information if I want this free cover art?
And ignoring the DRM issues (oh, and there are plenty of them), let's talk about connectivity again. You see, I recently went out and bought an "i". You probably know it by another name, but my brother Greg insists upon calling it an "i" because the damned thing has no phone. Well, that's not entirely true. It has great reception, so long as I turn off 3G, but 3G IS THE REASON I BOUGHT THE PHONE!!! I waited months to buy this thing only to find out that I can't use the feature I waited for! Apple, we're talking connectivity here. The one thing you don't screw up is people's connectivity. You can have all sorts of glitches elsewhere, but DO NOT CUT OFF PEOPLE'S FEEDS! I can forgive a hell of a lot, but don't do this to me.
This, and a number of other reasons, is why I think I want to bite the Linux bullet again. Ubuntu is a dream, it's easy to install, its wireless works, and I don't have idiotic DRM issues. Of course, getting Compiz back also makes me drool.
Apple, it was fun while it lasted, but if you can't communicate, this relationship has to end.
(And while we're at it, how many times do I have to try to post this without a "connected failed" error?)
Using XML::LibXML, I'm trying to determine if two nodes are different. I have the following humiliating code, but it works.
sub _node_differs {
my ($self,$left,$right) = @_;
# toStringC14N ensures "canonization" and allows '<title/>' to match
# '<title></title>'
my ($left_string, $right_string) = map {
defined($_) ? ( eval { $_->toStringC14N } || $_->toString ) : ''
} ( $left, $right );
if ($left_string ne $right_string) {
return [ $left, $right ];
}
return;
}
What's a "proper" way of doing that? I know I'm missing something obvious.
I've received some nice feedback about Test::Kit. A number of people at YAPC::EU also told me it sounded interesting, so I made the mistake of promising I'd have an alpha out by conference end. I made that deadline, but now there's a lot of work to do. I have three main things resolve:
In particular, while it's possible to create something just like Test::Most, it's not particularly easy, so the first thing I need to do is eat my own dog food.
Regarding YAPC::EU, I was astonished when the Lisbon, Portugal delegation opened their talk with my promotional video for a Lisbon YAPC. Sitting in a lecture hall with a few hundred people and watching your video on a large screen can be a wee bit intimidating. Fortunately, it went over well and people laughed in the right places (whew). I'll have to do more. That would be fun. Anybody want a video for a conference?
In other news, the Copenhagen conference was fantastic and, once again, I'm terribly impressed with what the organizers put together. They're a tough act to follow.
Doing more work with Test::Kit and now you can do this:
package My::Tests;
use Test::Kit
'Test::More' => {
exclude => 'is_deeply', # force use of eq_or_diff
},
'Test::Differences' => {
rename => {
eq_or_diff => 'is_deeply',
},
},
'Test::Exception',
'+explain',
'+on_fail';
sub BUILD {
# completely optional
# only needed if you want to extend with your own behavior
my ( $class, @args ) = @_;
# your own custom extensions, and return @args or a new
# import list
return @your_new_import_list;
}
And in your code:
use My::Tests 'no_plan';
on_fail {
my $test = shift;
if ( $test->name =~/critical/i ) {
my $message = sprintf "Test %s failed at %s line %d package %s" =>
$test->name,
$test->file,
$test->line,
$test->package;
email_admin($message);
}
};
is_deeply $foo, $bar, 'Uses eq_or_diff internally';
explain $baz; # if it's a reference, uses Data::Dumper
throws_ok { some_func() }
qr/some message/, 'some_func() is hateful';
So now you can set your own callbacks for test failures and do anything you really need. You can mix and match your own test modules. You can automatically dump references with explain. You can easily extend it. You can choose which test functions you do or do not want or rename them. Conflicting test functions fail at compile time. Yada, yada, yada.
At the hotel, our 'net connection goes up and down constantly. Rather than keep switching over to a terminal to ping something, I wanted to be alerted whenever the 'net was back. Searching for tools for OS X to do this for me was problematic because, well, the 'net kept going down. Now I get Growl alerts.
#!/usr/bin/perl
use strict;
use warnings;
use Mac::Growl ':all';
use Net::Ping;
use Getopt::Long;
# set up options
my ( $sleep, $sticky ) = ( 60, 1 );
GetOptions(
"sleep=i" => \$sleep, # number of seconds
"sticky!" => \$sticky, # sticky growl notifications?
);
# set up MacGrowl
RegisterNotifications( $0, [qw/ping/], [qw/ping/], );
my ($image) = grep { -e } (
'/Applications/Utilities/Installer.app/Contents/Resources/Caut.tiff',
'/Applica tions/Utilities/Installer.app/Contents/Plugins/TargetSelect.bundle/Contents/Reso urces/Caut.tiff'
);
# set up ping
my $host = shift || 'www.google.com';
my $p = Net::Ping->new( "tcp", 3 );
$p->{port_num} = ( getservbyname( "http", "tcp" ) || 80 );
# do that first ping
my $HOST_LAST_STATUS = !!( $p->ping($host) );
show_status( $host, $HOST_LAST_STATUS, $sticky, $image );
while (1) {
my $host_status = !!( $p->ping($host) );
if ( !$host_status ) {
$host_status = retry( $p, $host );
}
if ( $host_status ne $HOST_LAST_STATUS ) {
show_status( $host, $host_status, $sticky, $image );
}
$HOST_LAST_STATUS = $host_status;
sleep $sleep;
}
sub retry {
# because it might just be a flaky, intermittant connection
my ( $p, $host ) = @_;
for ( 1.. 3 ) {
if ( $p->ping($host) ) {
return 1;
}
}
return '';
}
END { $p->close() }
sub show_status {
my ( $host, $status, $sticky, $image ) = @_;
$status = $status ? 'up' : 'down';
PostNotification(
$0,
'ping',
"$host status",
"$host is $status",
$sticky,
-1,
$image
);
}