html 5

I am pretty excited about html 5.

<div> tags will still exist - but now there are cool new tags like <header>, <section>, <nav>, and <footer> (among others).

Basically all those things that we had to specify <div> tags as are included.

Some other neat tags to look forward to:

aside - this is content outside of the main area. It could be a sidenote, a tip, footnote.

dialog - a conversation

required attributes on form tags - with any luck, we won’t have to do so much javascript validation.

What I am most excited about is that the <font> tag will finally stop working. Hooray.

Filed under: HTML | 2 Comments

The difference between ‘==’ and ‘===’

I recently spoke with a senior PHP programmer in charge of hiring programmers. She stated that some potential hires do not know the difference between ‘==’ and ‘===’ - therefore she will not even consider them. Many people miss this small detail while learning PHP but it is important to understand.The double equal will check equality. The triple equal will check equality as well, but will also check to see if the variable data types are identical.

So why would you ever want to use the ===?

Some functions, strpos for example,will return the Boolean FALSE - but also return a non-Boolean value such as 0 or an empty string (”). In this case, you would have to use ‘===’ to check the outcome of the function.

Try running the following code:

$myString=”Valerie”;
$find=”V”;
$strResult=strpos($myString,$find);
if(!($strResult)){
echo “Not Here”;
}
else{
echo “The letter “.$find.” is in the word “.$myString.”.”;
}

So although there is indeed a “V” in the string “Valerie”, the output will display “Not Here”.

Instead, we use the identical === operator:

$myString=”Valerie”;
$find=”V”;
$strResult=strpos($myString,$find);
if($strResult===false){
echo “Not Found”;
}
else{
echo “The letter “.$find.” is in the word “.$myString.”.”;
}

Filed under: PHP | 1 Comment

Guitar Hero Intervention - Part 2

I came home today looking forward to playing Guitar Hero and battling a friend of mine from TKG -(Gibatronic!).

The kids have a four day weekend so I knew no homework help was necessary tonight. Had some Red-Bull earlier …so no worries about getting sleepy too soon.

After making supper for my kids (homemade pizza…yum) - I went into the living room to practice up a bit, went to grab the guitar…..and what the? My guitar was missing. I felt like Jewel without a van or snaggletooth. Celine Dion without Rene, snaggleteeth, Titanic, Las Vegas. A drug addict without……

I did a frantic scan of the living room, kitchen, kids rooms … no guitar. ‘Who would do this to me?’, I wondered. Why would someone take my guitar away?

Is this the intervention I pretended that I wanted earlier?If so, I swear I was just kidding - I don’t have a problem..I swear, I can stop anytime..I can stop anytime I want to.

Alas, I found the guitar. My mother had hid it behind a speaker in the living room…I don’t think she knows how about my Guitar Hero addiction so I don’t think she did it on purpose.

I beat Gibatronic on the first song…I was feeling pretty good. Beat him at his own song, I did. ‘ Even Flow’ by Pearl Jam.

Things went severely downhill from there. By the time Gibatronic was through, I was crying real tears. What is this salty discharge?

So maybe this was enough to kill my Guitar Hero addiction?

I doubt it. I don’t ever just lay down and take defeat…ever. For tonight, yes I will take this punishment.

But: Gibatronic…be forewarned…I will be practicing this weekend.

Filed under: General | 1 Comment

The funniest programming book ever!

I haven’t got that far yet - but so far, I am loving Ruby.

I started reading the Poignant Guide to Ruby. Why aren’t all programming books written like this? Funny comics, talking foxes and black-market child sales..what other programming book is going to have all that?

The author even encourages piracy because he is not in it for the money. Nice.

Check out this excerpt:

“…Like I said, start selling copies of my book, but corrupt the text. These altered copies would contain numerous blatant (and libelous) references to government agencies, such as the U.S. Marshals and the Pentagon. You could make me look like a complete traitor.”

Filed under: Recommended Reading | No Comments

Guitar Hero Intervention

Most addicts do not ask for an intervention. But I am asking…

I admit it. I am addicted to Guitar Hero. I think about it all the time.

When I am at work, I am thinking about how to beat the song that I couldn’t beat last night. Last week, when the kids were out with Grandma, I spent a whole day on it without getting up, blinking, eating…yeah.

This is putting everything I want to do on hold. I need to stop, I know I must stop. But right now at this very moment I am thinking about going home later today and turning it on again.

I signed up for a tournament this weekend.

I need help.

Filed under: General | 1 Comment

Resolutions

Here are my goals for 2008:

1. Learn Ruby on Rails - (if anyone can recommend a good book for newbies let me know).

2. Attend at least one meetup meeting!

3. Update all of my videos for all of my classes (ick).

4. Get off the computer more. This is probably the hardest thing on my list to do.

5. Put up a new fence.

6. Get my car fixed so it will stop blowing antifreeze in my face.

7. Eat less pizza and try healthier foods.

Filed under: General | 2 Comments

Do you use Object Oriented Programming in PHP?

I am teaching an advanced PHP course next semester.

I plan on covering Object Oriented PHP - but my question to you is: how much? I worked at one company where objects were not used at all - but that was a PHP 4 environment - so it was understandable. OOP is far better supported with PHP 5. I worked at another company where just about everything was OOP.

I am curious - how often is PHP being programmed procedurally or with objects? I remember reading an article somewhere from the “father” of PHP, Rasmus Lerdorf. In it, he stated that he “leans more toward procedural programming” - and that PHP was originally designed to be procedural.

Then theres the question of frameworks. Being completely honest here, I never even thought of using frameworks like MVC, Singleton, or Factory. I have just always done what works - but I have changed my thinking on this now. The idea is to make less work down the road for myself or someone else, and I am all for that.

So I am struggling with the extent I should take the frameworks and OOP. Let me know your thoughts..

Filed under: PHP | 4 Comments

Web Hosting - Why such poor service?

I recently parted ways with my web host. Why?

Check this out:

TO: newwebsite.com

Hi,

All of my sites are down.

Thanks,

Valerie

FROM: newwebsite.com

“We know it before you do. We are working on it.”

What kind of customer service is this? I used to work for a web development company. We NEVER treated our customers this poorly - and the company I used to work for is still thriving and successful - even with the occasional server outages.

Am I expecting too much? … maybe something like this:

“Hi Valerie,

We are aware that your sites are down at the moment. We experienced (”insert reason here”).

We are sorry for the inconvenience, but please rest assured that we are working diligently to get your sites up again.

We value you as a customer and appreciate your patience.”

So, I just moved all of my sites over, which is not an easy task. I am trying hostgator now - we will see how they do.

Filed under: General | 3 Comments

Creating Show/Hide Links in JavaScript

We have all seen those handy little show/hide buttons that hide content until a user wants to see it. Here is a walkthrough on how to create those visible/not visible divs.

Example:

The html code for the Show/Hide Code button is:

<input type=”button” value=”Show Code” onclick=”showCode(’showBox’,’showButton’)” class=”submit” id=”showButton”/>

So let’s break this down a bit:

function showCode(codeblockID, buttonID){//Here is our function declaration, we are passing two parameters, the id of the button and the id of the div tag

if (document.getElementById(codeblockID).style.display==’none’){//checking current status of div - if the div is currently hidden, we need to close it

document.getElementById(codeblockID).style.display=”;//setting display back to its default value

document.getElementById(buttonID).value=’Hide Code’;//changing the button text

}
else{ //if it is not hidden, we need to show it

document.getElementById(codeblockID).style.display=’none’;//making the display of the div hidden

document.getElementById(buttonID).value=’Show Code’;//chaging the button value to show code

}

}//end function showCode

So what does the code on the button do? Remember, our div tag must have an id (unique identifier):

<div id=”showBox” style=”width:465px;border:0;display:none;background-color:white;color:black;”>

Notice that the button code has an onclick eventhandler:

<input type=”button” value=”Show Code” onclick=”showCode(’showBox’,’showButton’)” class=”submit” id=”showButton”/>

When that button is clicked, we are calling the function ’showCode’. Inside of the parenthesis, we are passing two parameters - the id of the div tag, and the id of the button that we are going to change the text on.

That’s all for showing/hiding html elements!

Filed under: JavaScript | No Comments

Debugging JavaScript in Firefox

Did you know that you can easily debug JavaScript errors with Firefox?

First, start off by installing the web developer toolbar for Firefox.. You do not really have to download this in order to see the errors - but it is a great utility for developing web applications.

So, lets say you are creating a JavaScript validation for a form and forget to include a quote in an alert statement - like so:
JavaScript Error Example

So now your script will not work!

Depending on your version on Firefox, follow these steps to debug your JavaScript errors:

  1. Click on Tools/Error Console:
    JavaScript Firefox Debugging Example
  2. Now you are presented with a clear description of the error that includes error type and line number. You can also click on the error link to be taken directly to the line of code that has the error in the source:JavaScript Firefox Debugging Example 2

Filed under: JavaScript | 3 Comments