July 2010 Archives

Simple symbol overriding for tests

When testing a subroutine, it might interact with another subroutine. A useful trick is "mocking", which is to provide a given answer back from that subroutine, helping you imitate some situation for your subroutine to run into, and for you to test.

There's a very easy way to do this:

no warnings qw/redefine once/;
*My::Object::connect = sub {
ok( 1, 'Reached connect' );
isa_ok( $_[0], 'My::Object' );
is_deeply( $_[1], { something => 'else' }, 'connect method …

Check SSH keys on your VPS

Today, during a routine check of a new server, a co-worker found an authorized_keys file that isn't ours. The keys in the file (two of them) were of the VPS company that provided the server. One of them is of a specific user there and the other is a generic one.

This grants them password-less access to our server. We have no idea if the private keys are shared between people and whether they are even password protected or not. If they aren't password protected and shared between users (which is likely), it means that we have a completely unknown number…

Philosophical notes on Dancer, the Perl 5 web framework

Even though I had to let go of web programming for a while now, Dancer is still my favorite framework. Bad attitudes do not exist in Dancer, we don't trash anyone and we're not just polite and respectful towards each other (and by "each other" I'm definitely including all developers _and_ users), but we're also very attentive to one another.

That is how we're able to continue with the project successfully even when one or two core developers are very busy (which happens at times) - as with me right now or Sukria in the past. We're still able to push in new features, serious fixes or e…


I previously wrote a post called "Get the damned version". This post is tentatively entitled "There Is More Than One Way To Get The Damned Version" and speaks about the plethora of applications and modules to get versions. Brace yourself!

So, apparently I'm not the only one who hates how you cannot distinctively get the version of a specific module. We have various trickeries such as loading the module and printing it, trying to load an unknown - yet hopefully - non-existent advanced version and failing thus showing the version and a few other such odd possibilities... and then there …

Gtk2 + Perl = fun!

Use some modules:
use Gtk2 '-init'; # basic
use Glib qw/ TRUE FALSE /; # makes for easier source reading
use Gnome2::Vte; # generic terminal widget, will come in useful

Then we create a new window:

my $window = Gtk2::Window->new;
$window->signal_connect( destroy => sub { Gtk2->main_quit } );

That set the title, a nicer border line and also, if someone closes this window, it will ask Gt…

About Sawyer X

user-pic Gots to do the bloggingz