Scope? Nope. Dope!

Today I made a classic blunder in PHP programming. It is one that many make and certainly one I have made before. But the frustrating thing about this issue is it probably would have been caught by a simple unit test or, in lieu of that, something as simple as trying to capture output of my script from the go.

I was working on the command line (something I have been spending a lot more time doing) building a background processing application that will be triggered by the web. The process is expected to take between 45 minutes and an hour each time it is ran and will be ran one time a month at the discretion of an administrator (hence the reason it is not set as a cron job).

One of the very first lines of the CLI script looks like this:

// Define our path for all includes and file writes
define('APPPATH', realpath('.'));

It would seem simple enough, right? Basically that little line of code defines a constant called APPPATH that would essentially describe the path to the location of the file that is setting the constant. At least that is what I thought. And every test I ran led me to believe that I had indeed made the right choice to set the path the way I did.

I ran the script, and even other scripts that derived code from the script, from the command line on my local Ubuntu machine, from the command line on our Fedora dev machine and from the command line on our Ubuntu production server. I have similar snippets that are working on all of our machines, and these snippets work interactively, through cron and through the web.

But today something happened that I did not intend. As I attempted to run my last process test of this long running script through the web I found myself in a place where my script would not run. It was being triggered properly. It was just not actually doing anything.

After an hour of trying to figure out what I was doing wrong I solicited the wisdom and advice of two of my colleagues who are seasoned Unix professionals and after a couple of minutes I was able to begin to see what was wrong. Can you guess what it was?

That’s right… PHP, on the web, was applying its scope to the CLI script that it was calling. The reason it had worked in all cases prior to triggering it by the web was that I was logged in as me and calling the script as a CLI script interactively, through the prompt. That means that the setting of the APPPATH constant was happening as expected and to what I expected.

However, from the web, when PHP runs as an apache module, it calls the CLI script from the scope of the web server. That means that the use of realpath() on the location ‘.’ (current working directory) was assuming the working directory was the web server root, not the location of where the script actually resided.

That’s right folks, I lost track of the scope in which I was working. Like a dope.

The simple solution to this problem was to change where the script looks to set its own directory. Can you think of what I could have used, instead of ‘.’ as the location to pass to realpath() so that it knows, without a doubt, what its own path is?

// Get the real path to the current directory location OF THIS FILE
define('APPPATH', realpath(dirname(__FILE__)));/

I hate it when something this simple causes such deep pain and suffering, needlessly.

The criminality of cash

Just about anyone that knows me knows that I tend to lean toward a conservative/independent political point of view in most of my thinking. I have had a dissatisfaction with our government and government policies for a while, though more recently I have grown increasingly vocal about it because of the glaring opposition I have toward president Obama’s political views.

However there are times that I see things that were implemented under previous administrations that incense me as much as, if not more than, the current administrations decisions. Yesterday I got an email from Campaign for Liberty, an organization that supports Ron Paul and his political philosophies. They are more American Independent oriented politically and I do not necessarily agree with everything they preach, but in the case of the events mentioned in this email I could only be left with disgust toward the Bush administration for the implementation of policies that have affected good old American citizens who have been identified as displaying “terrorist” tendencies.

Campaign for Liberty’s very own Steve Bierfeldt has become an unexpected Internet sensation — and the latest target of over-reaching federal government agents.

You see, Steve was detained by Airport Police and TSA officials shortly after the Campaign for Liberty regional conference in St. Louis.

The officials rudely berated and harassed Steve for 30 minutes in a secluded room at Lambert-St. Louis International Airport. Fortunately, Steve was able to record nearly all of the interrogation with his cell phone.

Steve’s alleged “crime”? Carrying $4,700 in checks and cash from Campaign for Liberty, along with various other materials from our conference.

The local and Federal agents harassed Steve. They were belligerent, cursing and using insulting language. They threatened to turn Steve over to the DEA and the FBI, all the while refusing to inform him of his legal rights or explain how cash and checks threatened airplane or airport security.

Throughout the interrogation, Steve remained polite but resolute and declined to answer the invasive questions without an adequate explanation from these federal and local agents as to why they needed to be answered. Without telling Steve what law he was accused of breaking, they continued their harassment.

Although they grew increasingly frustrated that he remained committed to exercising his rights, intervention from another officer eventually led the police to reluctantly release Steve.

Last Wednesday, Steve appeared on Judge Napolitano’s Freedom Watch to discuss the flagrant violation of his rights and to promote the importance of each of us defending our civil liberties.

Here is the video clip. Listen to the recording that is played during this video and how well Steve handled the interrogation he was put through. The TSA had absolutely no right to treat him the way they did. And the thought that he was detained simply because he had a few thousand dollars in cash and checks on him makes me even angrier. Imagine if you had money on you while trying to board a plane and were treated like a terrorist because of it. What the crap?

I wonder what it is going to take to keep this crap from happening anymore. No American citizen should be treated the way Steve was just because they are carrying cash and checks, especially when there is absolutely no cause for it. There were no reports of theft locally and no reports of criminal activity in which the suspect resembled Steve (at least none mentioned in the report of the story). I am amazed that the TSA and airport police have this level of authority to carry out actions of this nature without being under the scrutiny of some type of oversight agency. This freaks me out.

But more than anything it makes me yearn for change. I hope president Obama has something on his list of things to change that covers this.

No whale hunting in Oklahoma

Ever read one of those little snippets that makes you take a second to really listen to the text of it again in your head, just to make sure your brain and eyes are communicating properly? What if you read a whole list of true facts/laws/ordinances that seemed to make no sense but are nonetheless still true facts/laws/ordinances?

The other day I was sent a link to a listing of strange facts and like a train wreck I could not look away. So rather than fight the urge to stay clear of the nonsense I dove headlong into it.

From that list, here are my top few favorites:

  • You can’t plow a cotton field with an elephant in North Carolina
    But dude, that would be the best way to do it because they animal is sooo big.
  • In Lehigh, Nebraska it’s against the law to sell donut holes
    Probably because of some high schooler’s shenanigans where someone woke up one day and found the middles of their donuts missing.
  • Every citizen of Kentucky is required by law to take a bath at least once a year
    Because once a decade is really not considerate enough.
  • It is against the law to whale hunt in Oklahoma
    Think of the whales that will be saved by this one. Whew!
  • In Breton, Alabama, there is a law on the town’s books against riding down the street in a motorboat
    Again, darn high schoolers. And I had a big time summer trip planned in Breton already. Complete with the motorboat. There goes that one.

In honor of the beginning of April… HAPPY APRIL FOOL’S DAY! 🙂

Sometimes you’re the windshield, sometimes, the bug

The Miami Herald reported earlier this week that a man was shot to death while trying to rob a local Miami Burger King restaurant. The suspected robber entered the restaurant, tried to rob the store at gunpoint and was subsequently shot to death by another patron who was carrying his own weapon.

An afternoon shootout at a busy Burger King restaurant in Miami left a potential robber dead and the customer who shot him seriously wounded.

The bloody event unfolded about 4 p.m. Tuesday at the restaurant at Northeast 54th Street and Biscayne Boulevard. It was a time, employees said, when it is usually crowded with schoolchildren and people getting out of work early.

Did you know there are people that would have you believe that carrying a gun, even owning a gun, should be outlawed? Imagine if the citizen in this story didn’t own his weapon. How badly could this have turned out? Of course, it did turn out badly, but not for the law abiding citizens in the restaurant.

In fact, the day turned out to be a pretty bad day for the suspected robber. After all, he thought he was going to score some cash and walk out of that restaurant. Man, did his day turn out different than he expected or what?

Just goes to show you:

  • You should never rob a fast food joint
  • Criminals are stupider than crap
  • The 2nd amendment is still a good thing

Since when have the courts become parents?

Someone recently sent me a link to a court case in which a judge ordered homeschooled children into public school based on his decision that the children needed more ‘focus’. This, despite the fact the kids in question had tested above their grade levels.

A North Carolina judge has ordered three children to attend public schools this fall because the homeschooling their mother has provided over the last four years needs to be “challenged.”

The children, however, have tested above their grade levels – by as much as two years.

The decision is raising eyebrows among homeschooling families, and one friend of the mother has launched a website to publicize the issue.

The ruling was made by Judge Ned Mangum of Wake County, who was handling a divorce proceeding for Thomas and Venessa Mills.

I couldn’t believe this was a real and true story. This kind of injustice doesn’t happen in America. Does it? I know judges have an appointed authority to interpret the law and enforce it accordingly, but if you read some of Judge Mangum’s own quotes you can’t help but be left with the same questions I am sure all people who read them have.

How can any judge see this case in the manner in which Judge Mangum is seeing it? How can he favor so heavily in favor of a father that has admittedly committed adultery, repeatedly, and has even gone so far as to admit that he took time away form his kids to pursue relations with his mistress? How can this judge feel as negatively as he does toward Mrs. Mills?

I am astonished by this to be honest. If you are a home schooling parent I would encourage you, if you are not already a member, to become a member of the Home School Legal Defense Association. It is an invaluable resource for home schooling families and something that every home school parent should be a part of.

And if you haven’t yet, stop on by The Homeschool Injustice blog set up by Mills family friend Robyn Williams and offer a word of encouragement to Venessa or support for the case that she is so valiantly fighting right now.

Government knows best

There was a time in our country when parents were afforded the position of “knowing what is best” for their children. In fact it wasn’t that long ago that parents were not only expected to tend to their kids but were encouraged to do so. But it seems as though the government has become increasingly interested in the governing of not just the political landscape. Apparently the government wants into your family now.

I had heard about this issue originally from a Home School Legal Defense Association newsletter and I later read about Senator Barbara Boxer seeking to ratify the U.N. Convention on the Rights of the Child. After reading the content and the message behind it I am left with an overwhelming disgust for our government. Not that I liked the government before, but this makes me want to become a politician just so I can speak out against this crap.

How can any politician believe, at all, that the government knows better than a parent when it comes to raising and handling their own kids? I know there are edge cases of neglect, abuse, bad parenting and utter parental stupidity that could easily be recounted that might provide a small sense of justification for this. But I would say that in the bulk of families that could be affected by a decision like this most have parents that are in some way or another involved in the welfare of their children. The government does not need to pass an intrusive legal decision that would in effect put the governments decisions regarding children above the decisions of the parents of those children.

Does this not seem odd to you? I take comfort in knowing that as a parent I am responsible for my children. I take comfort in knowing that since I live in a free country, a country that does no derive its identity nor its principles from the government which covers it, that I can parent my children however I see fit. Like home schooling my kids. Like disciplining them as I see fit. Like providing for them, sheltering them and teaching them the way that I, as their parent, think is the best way.

I hope Senator Boxer takes one on the chin with this attempt. Seriously, the government is meddling in affairs that it just should not be in. Parenting is one of those areas and that really needs to be left up to the experts: us parents.

No good deed shall go unpunished

I friend of mine sent me a link to a story about a man that was ticketed for jay walking after he helped save a woman from being hit by a bus.

A good Samaritan who helped push three people out of the path of a pickup truck before being struck and injured has gotten a strange reward for his good deed: A jaywalking ticket.

Family members said 58-year-old bus driver Jim Moffett and another man were helping two elderly women cross a busy Denver street in a snowstorm when he was hit Friday night.

Moffett suffered bleeding in the brain, broken bones, a dislocated shoulder and a possible ruptured spleen. He was in serious but stable condition Wednesday.

The Colorado State Patrol issued the citation. Trooper Ryan Sullivan said that despite Moffett’s intentions, jaywalking contributed to the accident.

Now as big a fan of the law that I am I have to say that the police in this case dropped the ball pretty hard. Police let people off all the time for things like speeding, illegal turns, red light violations, etc. And jay walking is one of those infractions that few officers actually cite for, opting instead for real infractions. So this leave me a bit baffled as to why an officer would take it upon himself to issue a citation to someone who just saved a life.

I mean, would it have been better to let the woman die and not jay walk? And in that same vein, did the woman who was saved get cited as well? And lastly, as in the case of self defense or defense in need (like saving someone from attack by attacking the attacker), would this not qualify as a circumstance in which a law broken to save a life was certainly worthy of being negated by the fact that a life was spared? Whiskey Tango Foxtrot?

Well, I can assure you that if ever I am faced with the prospect of jay walking for the purpose of saving someone from the certain death wrought by the impending collision with a speeding bus, I am going to do it. Cite me if you must. Just know that I would take that citation to court and probably win.

Failure is the style of the day

In light of the recent “will of the people” to save failing banks and our tanking economy, and in keeping with the tradition of rewarding failure with lots and lots of taxpayer cash, I felt it appropriate to write about two stories that have me wondering when the government funding of stupidity and management failure will eventually trickle down to me.

I read a few days ago that AIG, one of the earliest recipients of government money for the purpose of saving a dying business, is seeking to restructure their obligation to the government while at the same time asking for more money. Apparently the billions that were “lent” to AIG were not enough to keep them financially sound for more than a few months. Now, they need more AND they need to be let off the hook for what they have been given. Dude, where can I get some of that?

In other banking related news, it was reported by that Northern Trust, a bank that received $1.6 Billion in federal bailout money, spent a gob of cash on a sponsorship of the Northern Trust Open golf tournament at the Riviera Country Club in L.A. The story was also picked up by The Chicago Tribune, which reported a response to the original news report by a spokesperson from Northern Trust. Can anyone say back pedalling?

With all of this “rescuing” being offered by the government to these humongous corporations and organizations, I cannot help but be reminded of some of the presidential campaign promises the Obamasiah made when running for our votes. Some of those things revolved around the premise that he would work for the middle class, working family and that big business has benefited enough from past administrations. Forgive me if I sound a little ignorant here, but exactly how does taking more of our money and handing it over to a collection of large, irresponsible financial institutions equate to helping the middle class working family and not benefiting large corporations? Any idiot with a pen and an elected office could have done that. I thought we elected hope, change and a new sense of patriotism?

Oh well, maybe one day, when every American has lost their house and people are killing one another in the streets to bring a piece of bread home for their families, the large banks that are throwing these lavish parties will open their restrooms for us so we can clean up a little bit. It’s the least they can do for us, seeing as we are the ones paying for their banquets, their marketing, their airplanes, their bonuses, their salaries and other niceties that they would have to forego without out money.

Why California Republican politics suck

I was reading an article in my newspaper earlier today and was brought to laughter, then to disgust, when I read the headline GOP reprimands six who backed budget. Whiskey Tango Foxtrot?

You mean to tell me that because a state legislator voted for tax increases in the recent California budget that the California Republican Party is slapping them on the wrist by withholding funds for the campaigning in the future? Although this is said to be largely symbolic, I tend to look at it as largely divisive and utterly ridiculous.

The lawmakers were elected by the people in their districts. They were no doubt contact by many people, some for them, some against, that asked, if not begged, that they somehow pass a budget so California could get back to business. These men and women, regardless of their political affiliation, had an enormous task ahead of them and though it took the better part of an eternity to pass the stinking budget, they finally got one passed.

Yes, it had tax increases. Yes, it had cost cutting. The most important thing though is that it put California back in a place to conduct business again.

I was not exactly a fan of the budget to be honest. I am not happy about tax increases. No one can really be happy about tax increases when we are in a toilet of an economy and waiting for the handle to get jiggled. But I am very happy that spending is being curbed. The budget, as it was passed, had all sorts of problems but it got California moving forward again.

And to think that the state Republican party moved for, and succeeded in getting, a resolution against members of their own party is unbelievable. I knew politicians were filthy animals. I didn’t know they were cannibals.

Oh well, as I wait for the Obamasiah’s economic stimulus/recovery plan to trickle down to me I will be trying to figure out how to keep the state of California out of it. Not sure I will succeed seeing as it appears the government wants to take everything we have to give it large companies and other institutions, including my state, but I gotta try.

Let’s just hope the CRP doesn’t come knocking on my door to scold me for not being pissed off enough at the budget.

From the news of the weird file

According to an email I received recently:

When southern Florida resident Nathan Radlich’s house was burglarized recently, thieves ignored his wide-screen plasma TV, his VCR, and even left his Rolex watch. What they did take, however, was a generic white cardboard box filled with a grayish-white powder. (That’s at least the way the
police report described it.)

A spokesman for the Fort Lauderdale police said, ‘it looked similar to high-grade cocaine and they probably thought they’d hit the big time. Later, Nathan stood in front of the numerous TV cameras and pleaded with the burglars: “Please return the cremated remains of my sister, Gertrude. She
died three years ago.”

The next morning, the bullet-riddled corpse of a local drug dealer known as Hoochie Pevens was found on Nathan’s doorstep. The cardboard box was there too; about half of Gertrude’s ashes remained. Scotch-taped to the box was this note: “Hoochie sold us the bogus blow, so we wasted Hoochie. Sorry
we snorted your sister. No hard feelings. Have a nice day.”

Now I am no fool. I know that since it came through my email it must be true. But the smart guy in me told me that this sounded like the stuff of urban legends, so putting my skepticism to work (sorry intarwebs but I had to) I started doing some research.

The first thing I asked myself was can this really happen? I answered that pretty readily by explaining to myself that yes, criminals are really that stupid. And many could easily mistake cremated human remains for cocaine. Especially since it was hidden so inconspicuously in an urn.

But then I thought to myself what is the likelihood of this happening? And for the answer to that, I had to look the infallible intarwebs square in the eye and humbly ask it if it could look something up for me.

It did it, albeit hesitantly.

And you know what? Other people have also received this same email about Nathan Radlich. So I stopped thinking that I was special. And I started looking a little harder at whether this was really true.

And I found out it wasn’t. The stinking emailwebs lied to me. Not the intarwebs. No, the intarwebs stayed true and loyal and only gave me the truth (as it always does). But no such luck for emailwebs.

But its all good. Later on, when I pour a foedee on da floe foe mah dawg Hoochie, I will do the same for the emailwebs.