HTML validators


Producing valid HTML pages can be a difficult task. But since every web page has to obey some rules (a.k.a. standards), its structure can be validated either by the excellent W3C Markup Validation Service (free online service) or by using some browser extensions.

There is a very helpful extension for Firefox called HTML Validator, which validates each page by using W3C Tidy. A little icon at the lower right corner of Firefox shows the result for each page and it can be in one of three states: Valid, Warning, Error. Double-clicking on the icon reveals the source of the page, highlights any lines/tags with warnings/errors and provides the option to “Clean up the page…”

Another highly recommended extension for Firefox is the Web Developer extension which, among many other things, eases the validation process for HTML pages, CSS (cascading style sheets), links and feeds.

Visit The Light of the LAMP blog for more…

PHP web-based resources

For a PHP programmer, I can recommend two web-based resources, full of useful information.

  • PHP Classes has a vast amount of useful PHP packages in source code with examples.
  • Chris Shiflett is a blogger who writes on advanced topics about PHP programming.

Both sites have RSS feeds and are updated frequently with new stuff.

Visit The Light of the LAMP blog for more…

Environmental issues (part 2)

When working a lot with command line utilities, I usually find myself retyping certain commands. This fact is a good reason for someone to use aliases to save typing time and errors.

At first we have to check our most loved/typed commands. This can be done using:

history | cut -c 8- | sort | uniq -c | sort -nr | head -20

in order to show the 20 most frequently used [1]. Of course, the above commands combination must be an alias too [2].

After analyzing the output, we can decide which commands could be substituted by aliases, insert them in the ~/.alias file and use them after we “source” it [3].

[1] Explanation of the commands used:

  • history: show the last commands entered
  • cut -c 8-: cut the first 7 characters from each line of “history” output (cut off the number)
  • sort: sort the commands alphabetically
  • uniq -c: count same commands in a frequency table
  • sort -nr: sort the frequency table by descending counts
  • head -20: show only the first 20 lines

[2] alias hist_top20=’history | cut -c 8- | sort | uniq -c | sort -nr | head -20′ >> ~/.alias
[3] after editing ~/.alias, `source ~/.alias`

Visit The Light of the LAMP blog for more…

Environmental issues (part 1)

As a developer, I prefer working with command line utilities. That’s why I have devoted my first workspace area to an almost full-screen sized terminal window (I prefer gnome-terminal, although I’m working with KDE and konsole is just as good to work with) comprising of 3 or more tabs.

I want the first tab to always open mutt (the e-mail client that does almost everything), the second one to change to my most recent project’s directory (where I can edit the source files with vim — tabbed, using “vim -p”) and make a backup of the project’s database, the third to check some log-file, and the list goes on.

So, what’s the best way to automate these procedures?

Currently I’m using the output of the “tty” command and a case statement at the end of my ~/.bashrc file (comments included):

# show me from where I logged in
echo Logged in from $(tty)
case "$(tty)" in
# run mutt
# first change directory
cd ~/projects/projectName
# then perform a quick database backup
make back
# show me web visits, ignoring some of them based on certain criteria
tail -f /var/log/apache2/access.log | egrep -v "localhost|127.0.0|/(Thumb|images|Photo)/|favicon"

With arrangements like the above, one can “feel like home” by just logging in!

Visit The Light of the LAMP blog for more…

bash: quickly rename files

Since one cannot always have the tools she likes, here are some one-liners to rename certain files using only bash.
Rename all ‘jpeg’ files to ‘jpg’:

  • for a in *.jpeg; do mv $a ${a%jpeg}jpg; done

Remove the ‘photo-‘ prefix:

  • for a in photo-*; do mv $a ${a/photo-}; done

Rename ‘dsc’ prefix to ‘photo-‘:

  • for a in dsc*; do mv $a ${a/dsc/photo-}; done

Where can I find these recipes?
man bash 🙂

Visit The Light of the LAMP blog for more…

PHP: function is_me()

A very useful function to determine first if the visitor is the developer or not and then act accordingly.


/* check if client is me */
function is_me()
if (($ip=="") and (strstr( $br, "Firefox")))
return true;
return false;

If the visitor’s IP is (=localhost) and the browser is “Firefox” then the visitor is me!

Usage example:

if (is_me()) { error_reporting( E_ALL); } else { error_reporting( 0); }

With the above snippet, one developer can check for errors and warnings in a running system without the casual visitor noticing a thing. It is very easy also to view the web-page with another browser to check what the visitor actually sees.

Visit The Light of the LAMP blog for more…