Archive for October, 2008

Random Perl: How to check if something is a number

Friday, October 31st, 2008

Perl has no built in function or sub to test if a variable is a number or not. Scalar::Util makes it easy, and is a core module as well.

use Scalar::Util qw(looks_like_number);

my $number = 192;
my $string = '123foobarbazquux123';

if(looks_like_number($number)) {
  print "$number is a number!\n";
}

if(!looks_like_number($string)) {
  print "$string is not a number!\n";
}

Tada!

The National Association of Broadcasters are screwing over America again

Thursday, October 30th, 2008

Slate’s Jacob Weisberg is a douchebag

Tuesday, October 21st, 2008

To quote an article by him (and it has also been printed in Newsweek magazine):

A source of mild entertainment amid the financial carnage has been watching libertarians scurrying to explain how the global financial crisis is the result of too much government intervention rather than too little.

[...]

But to summarize, the libertarian apologetics fall wildly short of providing any convincing explanation for what went wrong.

[...]

To which the rest of us can only respond, Haven’t you people done enough harm already?

[...]

The worst thing you can say about libertarians is that they are intellectually immature, frozen in the worldview many of them absorbed from reading Ayn Rand novels in high school.

[...]

They are bankrupt, and this time, there will be no bailout.

Dear Jacob, please find me any libertarians in power. Ron Paul may be a fine example of what it means to be a Congressman, and the kind of person all Americans should look up to… but the rest of the House completely shits on him. I don’t know of any other Congressmen (either from the Senate or the House) or any Governors or anyone else with power that hold libertarian ideals.

The Senate, the House, the Presidency, the Treasury, and the Fed are all led by people who are, in large, extremely right and authoritarian. These people believe the people should have no rights and that all money should be very tightly controlled.

The bailouts? Ideas that only the authoritarian right could love. Propping up banks that practice unsafe banking practices because they’re afraid of change? More authoritarian right beliefs. Removing the rights of the people via the Patriot Act against the wishes of our founding fathers and the Constitution? Again, the authoritarian right.

The libertarian left believes in letting companies crumble if they cannot remain profitable and efficient. The libertarian left believes in letting people have choice in the matter… if the people actually wished to be bailed out, millions of my fellow citizens would not have written to Congress asking them to vote against the $700 billion bailout bill…. the same $700 billion bailout bill that is only serving to make the recession and Wall Street’s downturn much worse.

For all those out there who wonder where the money went in their 401k and IRAs? The lack of libertarian ideals in Congress stole your money.

You know what else the libertarian left believes in? Holding your government accountable… another thing Congress and the President want to have nothing to do with, and they will do anything in their power to make sure they stay in power. This goes beyond just being the authoritarian right… this makes them corrupt.

In two weeks, we are going to vote for the next President…. vote for someone who isn’t a total douchebag. vote for Ron Paul or Bob Barr or Chuck Baldwin. Just whatever you do, do not vote for John McCain (aka Bush 3.0) or Barack Obama: voting for either of these two will just mean more of the same… more bailouts, more corruption, more taking away the rights of the American people.

Random Perl: Application local modules

Tuesday, October 14th, 2008

Perl apps sometimes need modules that belong to them and aren’t installed into any global path.

Consider the following code:

use File::Spec::Functions qw(catpath splitpath rel2abs catdir);
use lib catpath((splitpath(rel2abs $0))[0, 1], catdir(qw(lib)));

If my program was named application (full path is /home/diablo/application-1.2.3/application), no matter how I ran it (via full path, ./application, ../application-1.2.3/application, /symlink_to_application-1.2.3/application, etc) or what I ran it from (console, fastcgi, mod_perl, etc), this code can find the directory named lib (full path is /home/diablo/application-1.2.3/lib/), and add it to Perl’s internal list of directories to look for modules in (aka @INC).

Thanks Aristotle!

Biden wins against Palin on Republican Poll

Friday, October 3rd, 2008

bidenpwnspalin

On Michael Savage’s website, a well known far right wing Republican whacko radio show host, Biden has beaten Palin 10 to 1. Ouch.