December, 2007

PHP Bubble Sort

December 30, 2007 @ 8:02 pm · Filed under Code

One of an occasional series of posts on PHP algorithms. I found this originally at United Scripters, and bookmarked it for some reason.


function bubbleSort($array=array()/*could have been a pointer*/){
for($j=($startIndex)?$startIndex:1; $j<=$lastIndex; $j++){
if( $array[$j-1] > $array[$j] ){/*SWAP:*/
if($newStartIndex===false){return $array;};
/* keep this comment to reuse freely:
Orwant, Hietaniemi, Macdonald algorithm as Php implemented by: */

| Comments

We Need More Analyst Calls Like This

December 24, 2007 @ 1:43 pm · Filed under Reality

Last June, General Mills raised the price of its cereal, but decreased the size of the box, so that the price per box went down. Apparently, this confused some analysts. Here’s the transcript:

Analyst: So let me see if I understand this. The price of your cereal is going up?

General Mills Spokesperson: That’s correct.

Analyst: But the price per box is actually going down?

General Mills Spokesperson: Correct.

Analyst: So then how is the price going up?

General Mills Spokesperson: Because we’re making the box smaller.

Analyst: Ok, but you just said the price of each box is going to be less.

General Mills Spokesperson: Yes, that’s true.

Analyst: So then you’re actually lowering prices.

General Mills Spokesperson: No, we’re raising prices.

Analyst: How?

General Mills Spokesperson: Look, you’re an analyst, you work with numbers.

Analyst: Right. Ok. I got it.

General Mills Spokesperson: Next question.

Analyst: Uh, actually, I don’t get it. How can you raise the price by lowering the price?

General Mills Spokesperson: Because we’re decreasing the size of the box.

Analyst: Ok, but you’re charging less for each box.

General Mills Spokesperson: Yes. Because we’re decreasing the size.

Analyst: Ah, I get it. So then the price is really the same, you’re just making the box smaller which makes the price look lower.

General Mills Spokesperson: No, no, no! Listen. We’re raising the price of our cereal.

Analyst: But –

General Mills Spokesperson: Shut up! Now listen, we’re raising the price of our cereal.

Analyst: (Silence).

General Mills Spokesperson: Say it.

Analyst: We’re raising the price of our cereal.

General Mills Spokesperson: Good. We’re raising the price of our cereal… while simultaneously making the box smaller. Go on, say it.

Analyst: While simultaneously making the box smaller…

General Mills Spokesperson: But… and this is the important part… but we’re raising the price more than we’re decreasing the size of the box… go on…

Analyst: But we’re raising the price more than we’re decreasing the size of the box.

General Mills Spokesperson: So…

Analyst: So…

General Mills Spokesperson: That…

Analyst: That…

General Mills Spokesperson: Come on…

Analyst: Come –

General Mills Spokesperson: No, I mean, come on and follow the thought. So that…

Analyst: Oh. So that…

General Mills Spokesperson: The…

Analyst: The… price is lower?

General Mills Spokesperson: No! So that the customer

Analyst: So that the customer…

General Mills Spokesperson: Will.

Analyst: Will.

General Mills Spokesperson: Oh good Lord. So that the customer will think the price has gone down when it’s really gone up!

Analyst: Oh.

General Mills Spokesperson: See? Price increase. Smaller box. Larger price increase than smaller box.

Analyst: Right. I still don’t get it.

General Mills Spokesperson: You know what? Just forget it.

Analyst: I’m going to have to downgrade your stock, you know.

General Mills Spokesperson: Good. Good. You do that.

Analyst: I will.

General Mills Spokesperson: I don’t even want you to rate our stock positive.

Analyst: Good, because I won’t.

General Mills Spokesperson: It would be an insult to the company for you to rate it positive.

See more analyst fun here.

| Comments

Let Us Go Up To Jerusalem And Die With Him – The Comedians

December 24, 2007 @ 12:12 pm · Filed under Culture

On my recent trip to Huntsville, I borrowed the Graham Greene book The Comedians from my parents. I had seen it on several visits before, but I had never picked it up, mainly due to it’s rather garish cover promoting the 1967 film version. This time, more from lack of alternatives than anything else, I started reading it and quickly became hooked.

Set in the Haiti of Papa Doc Duvalier, the main character of the story is a hotel owner who gradually becomes involved in Haitian politics despite his almost desperate cynicism. He and his compatriots are the comedians of the title: those who stand aside when commitment is required. The main theme that indifference is worse than a mistaken zealotry is only finally made clear near the end of the book:

The priest was a young man … He preached a very short sermon on some words of Saint Thomas the Apostle: “Let us go up to Jerusalem and die with him.” He said, “The Church is in the world, it is part of the suffering of the workld, and though, Christ condemned the disciple who struck off the ear of the high priest’s servant, our hearts go out in symphathy to all who are moved to violence by the suffering of others. The Church condemns violence, but it condemns indifference more harshly . … In the days of fear, doubt, and confusion, the simplicity and loyalty of one apostle advocated a political solution. He was wrong, but I would rather be wrong with Saint Thomas than right with the cold and craven. Let us go up to Jerusalem and die with him.”

Here’s the Amazon link.

| Comments (2)

Drunken Santas Run Amok!

December 24, 2007 @ 11:31 am · Filed under Reality

Check out this story in The Sun (yeh, I know that it’s not the most credible source, but they have video). According to the story, fifty drunken santas ran amok in a cinema smashing stuff up and swearing at customers! The manager of the cinema is quoted as saying:

“As they ran through the complex they wrecked everything they could, the Christmas tree – they bowled everything over … (they were) just absolute fools.”

That’s the spirit of Christmas for you!

| Comments

Tweeterboard: Not bad, but not great

December 23, 2007 @ 10:34 am · Filed under Technology

So, I added myself to Tweeterboard. It’s an application that tries to measure your influence on Twitter. It’s not a bad service, but it still has a few problems to work out. In particular, it doesn’t seem to update the stats very often, and it misses a lot of links that I post. Still, a good initial effort, and worth checking out.

| Comments

Defense Procurement News

December 22, 2007 @ 8:14 pm · Filed under Technology

I’ve been working on a new site called Defense Procurement News with my brother Dag. Please check it out.

| Comments

Why Ron Paul? Here’s Why!

December 21, 2007 @ 12:15 pm · Filed under Reality

If you want to know why Ron Paul is the best candidate in the race today, just read “Pimp My Ride” by Tucker Carlson. Tucker spent a couple of days on the road with Ron, and liked what he saw.

| Comments

Circuit City Going Down The Tubes

December 21, 2007 @ 9:15 am · Filed under Reality

So, it looks like Circuit City is going down the tubes. All I can say, is that it couldn’t happen to a better company. When I first saw the story earlier this year that Circuit City was firing higher paid employees to replace them with lower paid ones, I immediately stopped going there. It appears I wasn’t alone in making this choice. Now, Circuit City seems set to reap what it has sown. Good.

| Comments

How You Can Tell Twitter Has Arrived

December 19, 2007 @ 9:15 pm · Filed under Technology

You can tell Twitter has arrived when writers like Michael Krigman start arguing that it is a danger to corporate information security. In a post titled Twitter is Dangerous, Michael Krigman states that “Twitter is rapidly becoming a serious threat to corporate information protection.” For example, he suggests a person twittering during a meeting could release valuable information to thousands of people. His solution, IT should “be prepared to strongly enforce information-sharing policies. If confidential information is being shared, even innocently, question the judgment of the sharer.” Having read a lot of tweets, I’m not sure information sharing is the main issue corporations should have with Twitter. I think it’s much much more likely to cause HR issues

| Comments

Sometimes I am Ashamed to be an Apple User

December 19, 2007 @ 3:22 pm · Filed under Technology

Check out the comments on this (non) story entitled ZDNet Forcing IPhone Users to Dumbed Down Mobile Website on Mac Daily News. The conspiracy theories, interlaced with abuse, are just insane. As usual, there’s also massive confusion between Ziff-Davis and ZDNet, but I’m used to that. Sometimes, I just despair.

| Comments