Business Card
Weather

World Population Plugin for MT

Here's a little bit of MovableType business, well worth its High Intensity Time Wasting status! I was browsing the MovableType Help Forums, and came across this thread. Sam wanted, as it turned out, to have a counter on his site that would retrieve the current world population, and then be able to use it in something like this:

The current world population is
So, if I think I'm "one-in-a-million" I should just
bear in mind that there are about more people just like me!

Hey, let's hope none of them lives nearby!

So, being a bit of a narcissist myself, I thought I would benefit from being regularly reminded of my actual ordinariness, and thus I threw together some World Population code to enable the above demo. The first thing is a MovableType world census plugin which enables a <$MTworldPop$> tag that scrapes a government website for the current world population. Then there is some javascript for updating the population and doing some simple calcualtions.

Read more if you want to take a look at the code and play with this wonderfully frivolous distraction. Maybe you can even put it to some serious use besides the war on narcissism!

Posted by Oscar on 04/18 at 04:36 PM

The trackback URL for this entry is:

Maggie
19 Apr, 2003
07:34 PM

You are such a wiz with coding Oscar .  Hope you’re all geared up for the egg hunt tomorrow

Oscar
20 Apr, 2003
04:22 PM
member avatar

Sign of a mis-spent youth Maggie!

And yes, daughter had a fun egg hunt!

Beatriz
23 Apr, 2003
12:22 PM

Dear God! Someone should have told me about this before I started making statistics of world population in Excel… ha ha! Cool plugin. I just don’t have the patience (or the resources, I’m afraid) to make them work.

Cool! Spongebob!

Beatriz
23 Apr, 2003
12:26 PM

Uh oh! Sorry for the double comment. But I’m sure being a blog-guru you can fix it.

Oscar
23 Apr, 2003
05:47 PM
member avatar

Thanks Beatriz! Yes, I used my computer brains to push the delete button on the duplicate comment Phew!

You know, all you have to do is throw the plugin into the plugins directory, and then you have a new tag at your disposal. But, I know, ya gotta be in the mood for that sort of thing.

I was thinking of adding some tags to the plugin, like populations for different countries, or who knows. But I figure, I’ll only do that if someone wants it!

But, hey, I am glad that youy LIKE it in any case!

Neil
19 Mar, 2004
11:53 PM

Where does the second “Chunk of Javascript code” go?  Do both the first two codes go in your head of “index.html”?  Also, does the last part have to be in a post, or can it go in the sidebar on the site?  Thanks
-Neil Vitale

Oscar
20 Mar, 2004
12:57 PM
member avatar

It can go anywhere you want. You can put it in an individual post if you are going to use it only once, or in your index template or elsewhere if you plan to use it repeatedly, i.e., if you want those functions available to you regularly without having to recode them all the time. Hope that helps ...

Neil
24 Mar, 2004
02:32 PM

Thanks alot.  I have it working now on my site.  http://neil.cbulock.com It’s in the sidebar right under the cost of the Iraq war smile

John Wyles
06 Jul, 2004
07:03 PM

The script fetches a quote from a page that is double in size (~8k rather than ~4k) and seems to be less “live” than this page from Census.gov: http://www.census.gov/cgi-bin/ipc/popclockw .  Might I suggest only the following MINOR modifications?:

sub scrape_pop {
my $out = ‘Could not retrieve population.’;
my $population = ‘http://www.census.gov/cgi-bin/ipc/popclockw’;
my $req = HTTP::Request->new(GET => $population);
my $ua = LWP::UserAgent->new;
$ua->agent(’cenCheck/1.0’);
my $res = $ua->request($req);
my $c = $res->content;

if ($c =~ /<h1>(.*?)<\/h1>/i)
{
$out = $1;
}

return $out;
}

Oscar
06 Jul, 2004
08:09 PM
member avatar

Right you are John (on both size and “liveness")!

I’ll change the code and re-post the plugin when I get a few minutes wunna these days soon.

Thanks!

Susan
28 Nov, 2004
10:56 AM

I must be doing something wrong with this...I thought this would be an interesting piece of info for my email blog domain and I cannot seem to get it to work.

Instead of getting numbers I get letters...3 of them which state “NaN”. What the heck did I do wrong?

Oscar
10 Dec, 2004
06:39 PM
member avatar

If anyone is using this plugin, the site has changed just a little, so it hasn’t been working lately. I just now updated it, so download the new one and give it a try!

Susan
12 Dec, 2004
01:09 PM

Thanks!

Susan
12 Dec, 2004
01:14 PM

okay, is the new plug-in at the same location? I am still getting the NaN thing.

Susan
12 Dec, 2004
01:26 PM

I got rid of the NaN thing, but nothing shows up for numbers now.
I am sorry if I am being a pain.

Oscar
12 Dec, 2004
03:59 PM
member avatar

Hmmm ... If you’ll email me your template code, I’ll try it here and be sure it’s working.

But, before that, you might download the plugin again, or make sure it’s the latest one, then delete the current one on your server, then upload the new one. Then CHMOD the plugin to at least 755 (assuming your comfortable with such) - permissions are important here or plugins won’t work.

If the plugin is failing to get the data, it should return “could not retrieve population” but if it is not working at all, you get a blank.

In the latter case, the plugin has either become corrupted on upload somehow, or permissions are wrong.

Let me know howit goes, and feel free to ask for more help. The thing should be working

    One in a Million
    If you are One in a Million, there are 6285 people in the world that are exactly like you....

    Tracked on: : One in a Million (64.235.234.140) at 2003 04 21 17:01:54

    WorldPop
    Uses the census data from Census.gov. oscar@ofhills.com-->

    Tracked on: : MT Plugin Directory (66.246.57.2) at 2003 04 24 16:04:37

    World Population plug-in
    Still playing around with plug-ins and track back. I just installed the World Population Gadget which screen scrapes the world population. It is a cute waste of time....

    Tracked on: : Confessions of a Tech Junkie (207.142.135.101) at 2003 09 26 00:29:08

The trackback URL for this entry is:

Name:

Email:

Location:

URL:

Some Other Smileys

smiley sad blush wink smug wacky tongue2 tongue shifty undecided shocked wreck cry angry
veryangry2 evil cool anxious surprised smart veryhappy irked mischievous worried dead confused angel ashamed
biggrin bigmouth guilty cutie ill drunk wave lovestruck devil scoobydoo spongebob


Live Comment Preview

Remember my personal information

Notify me of follow-up comments?

Submit the word you see below:


<< Back to main