Sep 2 2010

include vs. include_once vs. require vs. require_once

include (‘sponsor_links.php’);
If the file sponsor_links is present in the current folder, it will be included ( way may want it to appear both – at the top and at the bottom).

include_once (‘statistics.php’);
If the file statistics.php is present, it means we want statistics for the page. Otherwise, we don’t want statistics. Deleting statistics.php will not affect the main program.

require (‘navigation.php’);
We may want to include the navigational links both both at the top and the bottom at the page. If navigation.php is not present, the main program will stop running and an error message will be displayed.

require_once (‘google_adsense_top.php’);
Because a page has only one top, only one instance of google_adsense_top.php will be included. If google_adsense_top.php is not present, the main program will stop running and an error message will be displayed.


May 14 2010

Top 10 SEO checklist

Proper Title Tags
Well-constructed title tags contain the main keyword for the page, followed by a brief description of the page content. It will be less than 65 characters and avoid using stop words such as: a, if, the, then, and, an, to, etc. Your title tag should also be limited to the use of alphanumeric characters, hyphens, and commas.

Proper Description Tags

Good description tags contain information about the page’s content and persuade search engine users to visit your web site. They should be between 25 and 35 words in length.

Proper Keywords Tags

Your keywords meta tag should contain between 5-10 keywords or keyword phrases that are also found in page content.

Proper Heading Tags

Each page of your site should use at least the H1 heading tag for the search engines that examine it when crawling your site.

Page Content

Pages should have between 300 and 700 words of descriptive content that contains the keywords specified for the page.

Proper Navigation

Each page of your site should contain links to every other page so search engine spiders can find every page. This is a critical step for the proper indexing and page rank distribution of your site.

Proper Sitemap

It’s important to use two site maps for your website–an XML version and a static version. The XML version can be created with Search Engine Visibility’s site map tool. The static version should sit on a static HTML page and contain links to every other page.

Controlled Crawling

It’s important that search engine spiders find your robots.txt file that guides spiders to pages and directories you want crawled and denies entry to protected areas of your site.

Duplicate Content/Tags

Because search engines treat web sites as a grouping of pages and not a single entity, each page on your site should be unique so that the tags and content differ between each page. Doing so increases the number of pages that will rank.

Word Density

Pages should contain 300 to 700 words of unique and descriptive content. A page’s meta tag keywords should also be those that occur most frequently on the page.


Aug 7 2009

CSS Image Rollover

The CSS method uses what is known as an image sprite to load all the rollover effects as a single image and we then use CSS to do the transition. To create the image sprite just create a single image containing all of the individual transitions.  Once you have your image sprite you just need the HTML and CSS code:

CSS Code:
a.grnBTN
{
display: block;
width: 200px;
height: 45px;
text-decoration: none;
background: url(“greenBTN.png”);
background-position: 200px;
}

a.grnBTN:hover {
background-position: 0 0;
}

.displace {
position: absolute;
left: -5000px;
}

HTML Code:

<a href="#" class="grnBTN" title="Image Title">
<span class="displace">Alternative Text</span>
</a>

  • The width and height values in a.rollover are the size of the original image.
  • The value of background-position is that of the original image width since we are literally moving from one part of the image sprite to another.
  • The <span> tag was included with a text alternative to the image and displaced it off the side of the visible screen so that screen readers will read it and in the event of no CSS support a text link will be shown instead.

Working Example:

Alternative Text


Aug 5 2009

IE Specific Stylesheets

ie-only-css

Internet Explorer has it’s problems with CSS (OK, it’s pretty much awful) but if you are worth your salt as a CSS coder, you should be able to deal with it. I am of the opinion that you can handle anything IE can throw at you without a ton of hacks and without having alternate stylesheets. But if you (or your client) really wants to get pixel-perfect results cross-browser, you may need to specify alternate stylesheets for different browsers, especially Internet Explorer.

Here is the basic technique for an IE-Only stylesheet:

<!--[if IE]>
<link rel="stylesheet" type="text/css" href="ie-only.css" />
<![endif]-->

The opposite technique, targeting only NON-IE browsers:

<!--[if !IE]>
<link rel="stylesheet" type="text/css" href="not-ie.css" />
<![endif]-->

If you need to get down and dirty with specific versions of IE, here are a few examples.

IE 7 ONLY:

<!--[if IE 7]>
<link href="IE-7-SPECIFIC.css" rel="stylesheet" type="text/css">
<![endif]-->

IE 6 ONLY:

<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="IE-6-SPECIFIC.css" />
<![endif]-->

IE 5 ONLY:

<!--[if IE 5]>
<link rel="stylesheet" type="text/css" href="IE-5-SPECIFIC.css" />
<![endif]-->

IE 5.5 ONLY:

<!--[if IE 5.5000]>
<link rel="stylesheet" type="text/css" href="IE-55-SPECIFIC.css" />
<![endif]-->

VERSION OF IE VERSION 6 OR LOWER: (I find this one pretty handy)

<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="IE-6-OR-LOWER-SPECIFIC.css" />
<![endif]-->

Why would you want to use these conditional stylesheets?

  • It’s more future-proof than hacks. A new browser or a new version of a browser may come along one day that wrecks up interprets your hacks in a strange way and will mess up your styling. That’s no good! For example, there is a really effective min-height hack out there right now, but who is to say that will work forever? The solution here would be to declare a min-height like normal in your real stylesheet, then declare a height (the workaround) in an IE-6-and-Lower stylesheet.
  • It keeps your CSS clean. And valid! If having CS code that passes W3C snuff is important to you, this is the way to go
  • Expandability. If a new browser comes along that you want to also support, you can create a conditional statement and stylesheet for that and you are all set, instead of re-tweaking your existing stuff.

If you think it is overkill for you to have IE-Specific stylesheets, you can use hacks to make things happen. Again, I don’t really recommend this, but this is how it’s done.

IE-7 ONLY:

* html #div {
    height: 300px;
}

NON IE-7 ONLY:

#div {
   _height: 300px;
}

HIDE FROM IE 6 AND LOWER:

#div {
   height/**/: 300px;
}

HIDE FROM IE 6 AND LOWER: (another way)

html > body #div {
      height: 300px;
}

Aug 5 2009

Installing Eclipse with the Palm WebOSdev SDK

Installing Eclipse and the Plug-Ins

This section describes how to install and update Eclipse.

Note: If you are using an earlier version of Eclipse, you must upgrade to Eclipse 3.4 to get the new plug-ins for Palm webOS development.

To install Eclipse

  1. Download Eclipse 3.4.2, also called Ganymede.
  2. Start Eclipse.
  3. When prompted for a workspace location, accept the default (/home/YOUR_USER_NAME/workspace).Note: The workspace location must be an absolute path with no spaces.

To find and install updates

  1. On the Help menu, select Software Updates and open the Available Software tab.
  2. Click Add Site.
  3. In the Location field, type  https://cdn.downloads.palm.com/sdkdownloads/1.1/eclipse-plugin/eclipse-3.4/site.xml  and click OK.
  4. Open the site in the list, expand the Palm Mojo SDK category and check Palm Mojo SDK.
  5. Click Install and accept the license agreements.
  6. Restart Eclipse when prompted.

Aptana

To improve the development experience, Palm recommends installing the Aptana Studio plugins. Instructions for installing Aptana are available at www.aptana.com as well.

  1. On the Help menu, select Software Updates and open the Available Software tab.
  2. Click Add Site.
  3. In the Location field, type http://update.aptana.com/update/studio/3.4/ and click OK.
  4. Open the site in the list and check Aptana Studio Installer for Eclipse 3.4.
  5. Click Install and accept the license agreements.
  6. Restart Eclipse when prompted.

Using Eclipse with the Plug-Ins

This section describes how to run Eclipse and use the debug launch configuration.

Running Eclipse

  • Mac: In the Eclipse folder (inside the Applications folder), double-click Eclipse.
  • Windows: Find and run eclipse.exe (its location depends on where you installed Eclipse).
  • Linux: At the command line, type: eclipse

Selecting the webOS Perspective

  1. Select Window > Open Perspective… > Other…
  2. Select webOS from the Open Perspective dialog.
  3. Click OK.

Generating a webOS Application

From the New Project menu:

  1. Select File > New Mojo Application.
  2. On the next screen, type a name in the Project Name field.
  3. Enter your application info:
    • Title
    • Vendor
    • ID
    • Version
  4. Click Finish.

From the New App toolbar menu:

  1. In the Eclipse toolbar, click the Mojo Wizard icon and select New App from the drop down menu.
  2. On the New Project Wizard screen, type a name in the Project Name field.
  3. Enter your application info:
    • Title
    • Vendor
    • ID
    • Version
  4. Click Finish.

Adding a scene to your webOS Application

From the New Project Menu:

  1. Select File > New > Mojo Scene.
  2. On the New Mojo Scene Screen, make sure the correct project is selected.
  3. Enter a name for your scene and click Finish.

From the New Scene toolbar menu:

  1. In the eclipse toolbar, click the Mojo Wizard icon and select New Scene from the drop down menu.
  2. On the New Mojo Scene Screen, make sure the correct project is selected.
  3. Enter a name for your scene and click Finish.

Running a webOS Application

  1. Select Run > Run Configurations…
  2. Select Palm Application and click the New Configuration icon to create a new launch configuration.
  3. Change the name.
  4. Select your project from the drop-down list.
  5. Select the Target:
    • Palm Emulator if you are using the emulator.
    • Palm Device if you are using a device (make sure your device is in Developer Mode).
  6. Click Run to install and run the application.

A launch shortcut is also available: In the Projects view, select the project and choose Run > Run As > Mojo Application. If you previously created a launch configuration, that target will be used. Otherwise, a dialog will pop up so you can select a target.

Debugging a webOS Application

  1. Select Run > Debug Configurations…
  2. Select Palm Application and click the New Configuration icon to create a new launch configuration.
  3. Change the name.
  4. Select your project from the drop-down list.
  5. Select the Target:
    • Palm Emulator if you are using the emulator.
    • Palm Device if you are using a device.
    • Under “Debug Options”, choose debugging options as follows:
    • Inspectable: Makes the application’s DOM available to the Palm Inspector. Equivalent to the following command:
      palm-launch -i <appid>
    • Mojo debugging: Enables debug logging in the mojo framework. Equivalent to the following command:
      palm-launch -p "{mojoConfig:true, debuggingEnabled:true}" <appid>
  6. Click Debug to install and run the application.

A launch shortcut is also available: In the Projects view, select the project and choose Run > Debug As > Mojo Application. If you previously created a launch configuration, that target will be used. Otherwise, a dialog will pop up so you can select a target.

Stay Updated

When new Eclipse plugins are available (currently you are notified through email), you can install them through the Eclipse Update Manager.

  1. On the Help menu, select Software Updates and open the Installed Software tab.
  2. Select Palm Development Tools and click Update.
  3. Click Install and accept the license agreements.
  4. Restart Eclipse when prompted.

Enabling Developer Mode

To install and test applications on a webOS device, you’ll need to enable

Developer Mode on the device.

  1. In card view or in the Launcher application, type the following:
  2. upupdowndownleftrightleftrightbastart
    
     
    
  3. Tap the resulting Developer Mode Enabler icon to launch the application.
  4. In the application, move the Developer Mode slider to the On position.
  5. Tap Reset the Device. When reset is complete, Developer Mode is enabled.

Jul 27 2009

ColdFusion Try and Catch

In order for your code to directly handle an exception, the tags in question must appear within a cftry block. It is a good idea to enclose an entire application page in a cftry block. You then follow the cftry block with cfcatch blocks, which respond to potential errors. When an exception occurs within the cftry block, processing is thrown to the cfcatch block for that type of exception.

Here is an outline for using cftry and cfcatch to handle errors:

<cftry>
   Put your application code here ...
   <cfcatch type="exception type1">

      Add exception processing code here ...
   </cfcatch>
   <cfcatch type="exception type2">
      Add exception processing code here ...
   </cfcatch>

   ...
   <cfcatch type="Any">
      Add exception processing code appropriate for all other exceptions
here ...
   </cfcatch>
</cftry>

Jul 17 2009

IE on Ubuntu

Are you a web developer like myself needing to test crossplatform and would really prefer do it all on 1 OS (not Windows) well I have the solution IEs4Linux

Type this in a Linux command terminal:
===================================================================
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

===================================================================

ie6