Professional PHP and MySQL Training

I’m happy to announce that I have started offering a professional PHP and MySQL training course. Actually, I’m offering two professional PHP training courses; one for beginners and one that covers more advanced topics.

The PHP Beginner course will be a two day course starting July 19th, while the PHP Advanced course will be a three day course starting July 21st. If you are interested in attending either of the courses please contact me.

Fahrenheit 9/11 Review

I saw the movie Fahrenheit 9/11 on opening night. Why? Because that’s what tree hugging hippies do on a Friday night in Ann Arbor, MI. How was it? Well, that’s hard to say. First of all, the content is not ground breaking for anyone who has actually been paying attention and connecting the dots for themselves over the last few years.

There are two things that more does a great job of; breaking down the facts into small digestible pieces and showing the real consequences of our actions in Iraq. He makes a few arguments about Bush & Co. and the war in Iraq and mulches them into small bite size chunks. His arguments are as follows.

  1. The Bin Laden family and other high level Saudis were allowed to leave the country right after 9/11 without being questioned. Moore’s argument is a valid one here; if you committed a crime the police would surely want to question your entire family as soon as possible.
  2. Moore asserts that the close connections between the Bush family and the Saudi royal family is the reason they were allowed to leave. This is a plausible argument, but is certainly leaning towards conspiracy theory.
  3. The reasons given to us for war, which, at the time the President made his case, were weapons of mass destruction, were lies. The fact that Iraq had no WMD is well known and currently there is much debate on links between Iraq and al Qaeda.
  4. Bush is evil and stupid. I think you can only be one or the other, but I could be wrong. Moore does use a lot of gratuitous Bush snickering clips, etc., which don’t add to his argument and really are only there for laughs

Nothing really ground breaking here for those of you who actually watch the news and read once in a while, but what makes this movie so powerful is the fact that it breaks down the lies behind us going to war and the consequences of us going into Iraq (if you don’t like seeing the results of our military actions then this movie is not for you).

Now all of the GOP’s out there are condemning this movie, but what makes me so angry is that, in their blind allegiance to the party, they ignore the following facts.

  1. Bush said the main reason for invading Iraq was that is posed an immediate threat and possessed WMD’s (he even had sattelite photos!). We now know they did not, in fact, pose a threat or possess WMD’s. Some make the assertion that the WMD’s were smuggled out to another country leading up to the war. If that was, in fact, the case then Bush HAS NOT MADE US SAFER; he’s merely shifted where the WMD’s are located.
  2. Once it was clear there were no WMD’s the GOP started to shift the reasons for war. First it was the much contested Iraq-al Qaeda link and then it was “we’ve liberated them!” and now they espouse the virtues of having a Democratic state in the Middle East. First off, your party’s leaders are trying to justify a war while ignoring the fact they either lied about the WMD’s or screwed up the efforts to secure those WMD’s. Second, the terrorist links are vague at best. Finally, did anyone ever think to liberate Iranians or N. Koreans? Do they even want Deomcracy?

NOTE: The following list of scenes I liked a lot contains spoilers.

  1. I find it disgusting at how the patrons of the conference for war contractors talk about how much they are helping the country, etc. These vultures profit from the horrors of wars. There is a great clip about a soldier who makes $3k/mo. and is assigned to guard the oil fields where guys driving 2.5 miles and back make three times that a month.
  2. The look on the Senator’s face when Moore asks him if he’d like to sign up his son to the armed forces to figh in Iraq is simply classic.
  3. I didn’t like looking at the scenes of dead bodies and blown up babies, but I’m glad that millions of people out there are going to finally see what we’ve put the Iraqis through.

So, in short, the movie doesn’t bring any major new information to the forefront, but does break down the misdeads of the Iraq war and Bush & Co. quite well.

"Civilian Contractors" Cross a Fine Line

The latest “it” within intelligence and military circles seems to be the use of civilian contractors for interrogating prisoners. I don’t like this at all and neither should you.

These men are usually trained by the CIA/military or former CIA/military agents. Despite what the term “contractor” might imply these are simply fulltime 1099 employees of the CIA/military. When’s the last time you hired a contractor to interrogate someone (the police surely don’t do this). This is an extremely gray area. I would assume, like any other contractor, the CIA has contracts with these individuals stating that the CIA is not culpable for what these contractors do while working for them. The light bulb goes off.

The same happens in real life. If I do a job for a company (say Ford) which directly results in you getting overcharged on your next Ford car statement I’m the one who pays, not Ford. The CIA and military are, in a word, “privatizing” the grayest part of what these government agencies do: extract information from uncooperative people.

This means, simply, that if a civilian contractor kills someone the civilian contractor is responsible and not the CIA or military. It’s genius! This means the CIA can simply say “I’ll pay you $X do get Y information” and leave the “details” up to the contractors. When things get out of hands the CIA denies any wrong doing.

You want to know what is so crazy about all of this? Civilian contractors where exempt from prosecution for crimes committed abroad until Congress passed a bill in 2000 that allows the MP’s to ship you back to face felony charges at home. That’s right! The CIA could hire a civilian contractor, who could intern do whatever they wanted to abroad without fear of prosecution back home. Luckily, things have changed. But, the problem still remains that the true culprits are getting away scott free: the CIA and military personnel who circumvent international treaties and US law by using scape goats they’ve personally trained and paid for thanks to a loop hole in the current law.

We should ban civilian contractors from working with and for the CIA and military. If our government can’t work within established laws and treaties we have bigger problems than terrorists.

And don’t give me that crap about “terrorists don’t work inside the laws or treaties so why should we?” You know why? Because we’re better than them and we hold ourselves to higher standards.

White House says

Recent media reports have been saying that there is a lot of double speak coming out of the White House concerning the Iraq/al Qaeda link. These are the facts as we currently know them.

  1. Whitehouse says there is no direct link between Iraq and al Qaeda concerning 9/11 specificallyYou’re right, if you’re talking specifically about the September 11th attacks, we never made that claim.
  2. 9/11 panel sees no link between Iraq, al-Qaidathe commission investigating the Sept. 11 attacks reported Wednesday that Osama bin Laden met with a top Iraqi official in 1994 but found “no credible evidence” of a link between Iraq and al-Qaida in attacks against the United States.
  3. Cheney blasts media on al Qaeda-Iraq linkVice President Dick Cheney said Thursday the evidence is “overwhelming” that al Qaeda had a relationship with Saddam Hussein’s regime in Iraq, and he said media reports suggesting that the 9/11 commission has reached a contradictory conclusion were “irresponsible.”

As much as I hate to say this the reality is that the White House is right. They, as far as I can find, never said Saddam and al Qaeda worked together to pull off 9/11. What they are saying is that along the way Iraq and al Qaeda did have contacts with each other. The commission even says this.

… the commission also found that bin Laden did “explore possible cooperation with Iraq.”

But man, the White House really, really sucks at making their case. I’ve laid out an intelligent argument showing that the media (and bloggers) are basically jumping the gun to make fun of the White House on this one. Here is what Bush said (this is classic Bush here).

“The reason I keep insisting that there was a relationship between Iraq and Saddam and al Qaeda [is] because there was a relationship between Iraq and al Qaeda,” the president said.

Oh, OK that clears things up. Thanks for all of the interesting information supporting your claim. This is the kind of retarded logic the White House uses all the time. It’s the “just trust us” mentality. That’s not good enough for me. I’m happy to give you the benefit of the doubt, which is what I’m doing now, but you gotta give me something to work with! So, you’re wondering how everyone got confused? Before reading the following quote please re-read what the 9/11 commission said about the Iraq/al Qaeda link.

In his CNBC interview, Cheney went a bit further. Asked if Iraq was involved in 9/11, he said, “We don’t know.”

Oh, OK that clears things up. Sometimes I think this administration uses this sort of inter-contradiction with known facts, previous statements and other cabinet members just to confuse everyone and leave everyone scratching their heads.

UPDATE: It looks like Andrew Sullivan agrees with me [via Instapundit]. And you thought I only read leftist blogs!

UPDATE: Oh, so maybe they did vaguely say Iraq had a part in 9/11 [via Stephen VanDyke]. Bush wrote a letter to Congress in March of 2003 saying the following.

[A]cting pursuant to the Constitution and [the Authorization for Use of Military Force Against Iraq Resolution of 2002] is consistent with the United States and other countries continuing to take the necessary actions against international terrorists and terrorist organizations, including those nations, organizations, or persons who planned, authorized, committed, or aided the terrorist attacks that occurred on September 11, 2001.

Of course this can be taken either way. The White House could be saying that even communication with al Qaeda was aiding the terrorist attacks. It’s not the smoking gun that I’d like to see though.

Recent Side Projects

Over the last month or so I’ve been working with Cameron Barrett of camworld.com fame to create a few interesting new blog related websites.

  1. Today’s Papers – Today’s Papers is a website devoted to aggregating news discussions. It works by pulling from over a hundred RSS news feeds, aggregating them by category and allowing users to both trackback and post comments to each news entry. It’s a great way for people to find out meta information and centralize discussions on the latest news.
  2. FH911.com – FH911.com is an online community for Michael Moore’s much anticipated and much debated new movie, Fahrenheit 9/11. We don’t take sides, but merely allow for a forum to discuss Moore’s new movie, the controversy, his books, etc.

Feel free to check out the new sites and send me ideas, complaints, comments through the contact form on this site.

Checking Server Status – Easily

I’m currently working on a simple backup script and I wanted to make sure my backup server was up before I sent stuff from my laptop over to the backup server (which is housed here locally on a nice software RAID setup). It’s nothing ground breaking, but I couldn’t find a simple utility to simply ping a server, timeout gracefully and return a valid exit code. So, being the geek I am I made one.

<?php

  $timeout = 5;
  if (!isset($argv[1])) {
      die("Usage: php -q server_status ipaddress:port [timeout]n");
  } else {
      list($server,$port) = explode(':',$argv[1]);
      if (isset($argv[2]) && is_numeric($argv[2])) {
          $timeout = $argv[2];
      }
  }

  $fp = @fsockopen($server,$port,$errno,$errstr,$timeout);
  if (!$fp) {
      exit(1);
  } else {
      fclose($fp);
      exit(0);
  }

?>

Privatizing Social Security

Ask any Republican if we should privatize Social Security and you’ll get a resounding “YES!”. Meanwhile, ask any Democrat and you’ll get a resounding “NO!”. As usual, the reality is somewhere in between. Many reports have indicated that the current Social Security system will no longer be solvent in about 40 years (solvent means “profitable” – in other words we would be paying out more in Social Security than we took in). You can blame this on all the horney WWII vets.

It was after viewing this AARP “tutorial” on Social Security that I had what some might call a stroke of genius. I simply call it a stroke of common sense. Here are the pro’s and con’s of Privatizing Social Security as I see them currently.

Pros

  1. Depending on how you invest your Social Security you could realize strong gains by investing in the stock market.
  2. This would be a major victory for the stock market, in general, as a substantial sum of money would be infused into the market in a relatively short period of time. This, however, is a short term victory.
Cons

  1. Privatizing Social Security means you have absolutely NO guarantee that your money will be safe. Your money, once put into the stock market, will no longer be insured by the government.
  2. There is an enormous risk of corporate abuse. Companies could throw all the fees they wanted at transactions, etc. (ie. exactly what they do with your current IRA’s, etc.)

As you can see there are a couple of pro’s and con’s to each. I don’t think privatizing will fix the problem of us paying less in that we pay out. Here is how I think Social Security should be set up now.

  1. Make Social Security optional. If I want to be in total control of my retirement then let me be.
  2. Have two avenues for Social Security: a.) Government Bonds (pros: simple, insured; cons: very little/slow growth) b.) Privatized Account (pros: potential for high growth, flexibility in investment choices; cons: corporate fees, not insured, could lose your ass)
  3. Make sure all Social Security benefits paid for by employers cannot be invested in private accounts. This way if you do lose your ass in the stock market you still have something.

I think this structure could appeal to all sides (including Libertarians: see #1). The problem is that no one is willing to budge on this – each side wants all or nothing. Sad.

Bad Week For Bush

And it’s only Monday! And I doubted those who said Bush and his cronies were over-achievers. At any rate here are some great stories coming out this week.

  1. The State Department to Correct Terror ReportThe State Department said on Thursday its report that the number of international “terrorist” attacks fell last year was wrong and in fact had risen sharply.
  2. Cheney helped Haliburton land no-bid contractPentagon officials have acknowledged that Vice President Dick Cheney’s chief of staff and other Bush administration political appointees were involved in a controversial decision to pay Halliburton Inc. to plan for the postwar recovery of Iraq’s oil sector … The decision, overruling the recommendations of an Army lawyer, eventually resulted in the award of a $7 billion no-bid contract to Halliburton …
  3. Bush Rejects calls from Ronald Reagan’s family to relax stem-cell research restrictionsThe White House rejected calls Monday from Ronald Reagan’s family and others to relax President Bush’s restrictions on stem-cell research in pursuit of potential cures for illnesses.
  4. Bush pays tribute to Clinton In a rare election-year political truce, US President George W. Bush warmly paid tribute to Bill Clinton and even plugged his forthcoming memoirs at his formal White House portrait unveiling.

So, as expected, it appears that Cheney DID use his influence as VP to get Haliburton the fishy no-bid contract. Some will say that Haliburton had received no-bid contracts under the Clinton administration, to which I say this: Clinton nor Gore were never closely connected at any time with Haliburton. I’m not mad that a company out there got a no-bid contract from the government, which happens often, what I’m mad about is that it appears the VP of the United States used his office and influence to secure a no-bid contract for a company in which he was formerly CEO.

My favorite is that on top of all the bad press this administration has been getting lately Bush had to pay tribute to Clinton (the GOP’s version of the anti-christ) during the unveiling of the former President’s White House portraits. Ouch.

A Quick Bitmask HOWTO for Programmers

Warning: Highly Geeky material follows.

I’m currently working on a large database for a customer. I’m actually redoing a crappy version of the database into a normalized screaming machine. I ran into a problem recently in that some of the values are stored as bitmasks. I knew what a bitmask was, but generally regarded them as voodoo magic left to crazy C hackers. Until now. I contacted my voodoo crazy C hacker mentor, Jeremy Brand, and asked him how they worked.

Here’s a quick tutorial:

instead of counting 0, 1, 2, 3, 4, 5… you could with powers of 2
instead 2^0, 2^1, 2^2, 2^3, 2^4, 2^5… (1, 2, 4, 8, 16, 32…).

When you lable something with one of these powers of two you can
add them to other powers of 2 and then later on divide out what
you started with again.

For example:

apple = 4
orange = 2
banana = 1
———–
sum = 7

The sum of your identifiers is 7 (lets call this $sum).

So, later on you can check 7 to see what is in your basket:

does $sum mod 4 equal 0? (then there is no apple in the cart)
does $sum mod 2 equal 0? (then there is no orange in the cart)
does $sum mod 1 email 0? (then there is no banana in the cart)

Using bitmasks isn’t neccesarily easier to use, but it is fast.
It’s fast because computers already thing in bits. This example
is using 3 bit memory. Typically you’ll have 16 options (like I
have 3 here) because of the size of an integer. If you’re lucky
you’ll be using C or even mysql that can access all 32 bits of an
integer then you’ll have 32 options.

The reason why computers use base-2 to to begin with are because
with storage hardware there is really only two states: on and off.
The more single units that you can store ons and offs the more
storage the device can have.

FYI, you can use google for your calculator:
eg. http://www.google.com/search?q=7+mod+4.

Finally, that makes sense. I’m still completely lost on the actual math that goes into making this work (which irks me), but I did manage to get a proof-of-concept program working, which may help other bitmask deficient programmers out there:

<?php

  // Copyright 2004 Joe Stump <joe@joestump.net>
  // Public Domain
  // Usage: php -q bitmask.php 1 4 32
  //        (any numeric argument will be evaluated - change to whatever)
  echo "Valid bitmask values (up to 16): n";
  for ($i = 1 ; $i < 16 ; ++$i) {
      echo "2 ^ $i = ".pow(2,$i)."n";
  }
  echo "nn";

  $bitmask = 0;
  $values = array();
  for ($i = 1 ; $i < count($argv) ; ++$i) {
      if (is_numeric($argv[$i])) {
          $bitmask += $argv[$i];
          $values[] = $argv[$i];
      }
  }

  echo "Bitmask Contains: ".implode(', ',$values)."n";
  echo "Bitmask Total: ".$bitmask."n";

  echo "nResults:n";
  $arr = array(1,2,4,8,16,32);
  for ($i = 0 ; $i < count($arr) ; ++$i) {
      echo $arr[$i].': '.((($bitmask & $arr[$i]) == 0) ? 'FALSE' : 'TRUE')."n";
  }

?>

The trick is the &. If the result is 0 (zero) then the single bitmask value is not present in the sum of the bitmask. I’m sure this has something with the fact that you cannot add any separate list of single bitmask values and get the same sum twice (ie. 1 + 2 + 4 = 7, 2 + 4 + 8 = 14). Again, I just know “it works[tm]”. I hope this helps someone else out there.

I’m mainly caching this here so the next time my retarded mind can’t wrap itself around bitmasks I can check back to my own site. If you have questions concerning this don’t email me because I still think little green men make this mathematic “trick” work. Damn, I wish I had gotten a Computer Science degree instead of a Computer Info. Sys. degree.