Quick and easy way to validate email strings. I picked this bit of code up from somewhere, not sure where….Think it was the Zend site. Credit goes to the original unknown author, not me.

<?php
function is_email($address) {
$rc1 = (ereg(‘^[-!#$%&’*+./0-9=?A-Z^_`a-z{|}~]+’.
‘@’.
[-!#$%&’*+\/0-9=?A-Z^_`a-z{|}~]+.‘.
[-!#$%&’*+\./0-9=?A-Z^_`a-z{|}~]+$’,
$address));
$rc2 = (preg_match(‘/.+.ww+$/’,$address));
return (
$rc1 && $rc2);
}
?>

Quick tip for you PHP/Opera Users!

In Opera, go to Tools –> Preferences, and click on the search tab. You should “Add a new search engine” and fill in the blanks. Here is what I use:.

  • Name: PHP
  • Keyword: p
  • Address: http://www.php.net/search.php
  • Query string: pattern=%s&show=quickref

You have to check “Use POST” to be able to type in a query string.

Click OK, and then click Ok.

From now on you will be able to search the PHP function list by typing “p function” in the address bar. You can change “quickref” to “all” if you want to search all php.net sites, or “manual” for the online documentation.

Enjoy! I orignally picked this tip up from PHP.net, don’t know the exact URL tho.

When Apache generates any web pages or error pages, some important information about the version and other details implemented on the system are displayed in th web site server header. For example, the information text may be like this:

Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b

Server: Apache/2.0.53 (Ubuntu) PHP/4.3.10-10ubuntu4 Server at xx.xx.xx.xx Port 80


The line in the server header expose important version and variant information about the Linux operating system and Apache software used on the machine, indirectly expose the possible security holes that are existed to the hackers, or at least make malicious attackers easier to identify your system for available attack points.

To ensure that the Apache HTTP web server does not broadcast this message to the whole world publicly and fix possible security issue, modify these two directives ServerTokes and ServerSignature in httpd.conf file.

  1. Login as root user or perform a sudo to the web server.
  2. Open and edit httpd.conf or apache2.conf (in Apache 2) with vi or other text editor. The Apache config normally located in /etc/httpd/conf/ or /etc/apache2/ or /etc/apache/ (for Apache1.3) depending on which Unix you’re using.
  3. Locate the line with ServerTokens. You can perform a search by typing “/ServerTokes” and hit Enter.
  4. In Apache 1.3, you will likely to see a line starts with #ServerTokes Full In this case, remove or delete the # character (by pressing d key). Also modify the Full to become Prod (press r key to replace one character, or R to replace multiple characters), so that the line becomes ServerTokens Prod. In Apache 2.0 or 2.2, the line normally does not exist. So the search will fail. In this case, go to the bottom of config file, and add the new line with the following text. You can add new line by pressing o key.ServerTokens Prod
  5. Next, search for ServerSignature. In Apache13, the line should just above the line of ServerTokens. Edit the line so that it looks like this, and in Apache2 which doesn’t already have this line, add in at new one.ServerSignature Off
  6. By now the Apache configuration file should have this two directives set as below:ServerSignature Off
    ServerTokens ProdThe first line “ServerSignature Off” instructs Apache not to display a trailing footer line under server-generated documents (error messages, mod_proxy ftp directory listings, mod_info output, and etc) which displays server version number, ServerName of the serving virtual host, email setting, and creates a “mailto:” reference to the ServerAdmin of the referenced document.The second line “ServerTokens Prod” configures Apache to return only Apache as product in the server response header on very page request, suppressing OS, major and minor version info.
  7. Save and close the config file by pressing Shift-Colon, and then type wq keys, and hit Enter.
  8. Restart Apache. Typical command is service httpd restart or /etc/init.d/apache2 restart.
  9. Now, you will get only the Apache in the server response header:Server: Apache

Some Programmer Humor

This was sent to me by my brother. I do not in any way take responsibility or claim writing any of it. I am sure this has been passed around on the internet since the internet was conceived as a bunch of tubes. Thats a bad attempt at humor BTW.

All credits to (unknown) original author. Additions made by several others , and by myself

How to Shoot Yourself in the Foot using:

Ada
After correctly packing your foot, you attempt to concurrently load the
gun, pull the trigger, scream, and shoot yourself in the foot. When you
try, however, you discover you can’t because your foot is of the wrong
type.

APL
You shoot yourself in the foot, then spend all day figuring out how to
do it in fewer characters.

Access
You try to point the gun at your foot, but it shoots holes in all your
Borland distribution diskettes instead.

ActiveX

Ole_Registration_Error: Cannot find object “ActiveFoot”,download the latest drivers.

Assembler
You try to shoot yourself in the foot, only to discover you must first
invent the gun, the bullet, the trigger, and your foot.

Basic(interpreted)
You shoot yourself in the foot with a water pistol until your foot is
waterlogged and rots off.

Basic(compiled)
You shoot yourself in the foot with a BB using a SCUD missile launcher.

Visual Basic
You’ll really only appear to have shot yourself in the foot, but you’ll
have had so much fun doing it that you won’t care.

C
You shoot yourself in the foot.

C++
You accidentally create a dozen instances of yourself and shoot them all
in the foot. Providing emergency medical care is impossible since you
can’t tell which are bitwise copies and which are just pointing at
others and saying, “That’s me over there.”

Cobol
USE HANDGUN.COLT(45), AIM AT LEG.FOOT, THEN WITH ARM.HAND.FINGER ON
HANDGUN.COLT(TRIGGER) PERFORM.SQUEEZE RETURN HANDGUN.COLT(45) TO
HIP.HOLSTER.

Concurrent Euclid
You shoot yourself in somebody else’s foot.

dBase
You buy a gun. Bullets are only available from another company and are
promised to work so you buy them. Then you find out that the next
version of the gun is the one that is scheduled to actually shoot
bullets.

Delphi
MyFoot := TFoot.Create( Self );
Gun := TGun.Create( .45, SOFT_NOSED_BULLETS, 6 );
Gun.Aim( Self.MyFoot);
while Gun.BulletsAvailable do
Gun.Shoot( Self.MyFoot );

FORTH
Foot in yourself shoot.

FORTRAN
You shoot yourself in each toe, iteratively, until you run out of toes,
then you read in the next foot and repeat. If you run out of bullets,
you continue anyway because you have no exception handling ability.

HTML
<a target=”http://body/lower-half/leg/foot.appendage”>Shoot here</a>

HyperTalk
Put the first bullet of the gun into the foot left of leg of you. Answer
the result.

Java
The gun fires just fine, but your foot can’t figure out what the bullets
are and ignores them.

LISP
You shoot yourself in the appendage which holds the gun with
which you shoot yourself in the appendage which holds the gun with
which you shoot yourself in the appendage which holds the gun with
which you shoot yourself in the appendage which holds the gun with
which you shoot yourself in the appendage which holds the gun with
which you shoot yourself in the appendage which holds…

Microsoft
>ActiveX Object “Foot” not found.
>”Foot” will possibly be included in the next release.
>You can upgrade for $500.
>Press OK to Retry or Esc to cancel.

Modula2
After realizing that you can’t actually accomplish anything in this
language, you shoot yourself in the head.

Motif
You spend days writing a UIL description of your foot, the trajectory,
the bullet, and the intricate scrollwork on the ivory handles of the
gun. When you finally get around to pulling the trigger, the gun jams.

NeXT
We don’t sell guns anymore, just ammunition.

Paradox
Not only can you shoot yourself in your foot, your users can, too.

Pascal
The compiler won’t let you shoot yourself in the foot.

Perl
1. You go to CPAN and download Geek, Body::Foot, Gadgets:Gun and
Accesories::Bullet modules.
2. Then:
#!/usr/bin/perl -w
use strict;
use Geek;
use Body::Foot;
use Gadgets::Gun;
use Accesories::Bullet;

my $me = Geek->getBorn($ENV{’USER’});
my $foot = $me->{parts}->{feet}->[0];
die “No feet (maybe both were cut off?), stopped”
unless defined $foot;
my $gun = ($me->{money} >= Gadgets:Gun::price ? Gadgets:Gun->buy() : Gadgets:Gun->steal);
my @bullets = map { Accesories::Bullet->new() } (0..5);

$gun->load(\@bullets);
while ($gun->{bullets})
{
$gun->shoot($foot);
last if $foot->shot();
}
print “Looser!\n” unless $foot->shot();

PL/1
After consuming all system resources including bullets, the data
processing department doubles its size, acquires 2 new mainframes and
drops the original on your foot.

Prolog
You tell your program that you want to be shot in the foot. The program
figures out how to do it, but the syntax doesn’t permit it to explain it
to you.

PHP

After loading the gun you notice your foot is missing after some noob PHP programmer forgot to validate his input and now some cross site scripting has inflitrated and stole all your bullets.

Smalltalk, Actor, et al
After playing with the graphics for 3 weeks, the programming manager
shoots you in the head.

SNOBOL
If you succeed, shoot yourself in the left foot. If you fail, shoot
yourself in the right foot.

Sun
Just as soon as Solaris gets here, you can shoot yourself anywhere you
want.

Unix
% ls
foot.c foot.h foot.o toe.c toe.o
% rm * .o
rm: .o: No such file or directory
% ls
%

XBase
Shooting yourself is no problem. If you want to shoot yourself in the
foot, you’ll have to use Clipper.

Windows95
>shoot self in foot
I don’t see any self here.

>shoot me in foot
There is no you in the foot.

>shoot foot
I don’t know which foot you’re talking about.

>shoot left foot
You don’t have the gun.

>get gun
You take the gun.
You’re lantern just went out.
* * * YOU HAVE DIED * * *
Press OK to confirm.

Google Android SDK Now Available!

The Software development kit for google’s new mobile OS is now available! My hope that by Google realizing a new open source mobile platform that it will change how mobile phones are produced and distributed. To me it seems Google is not trying to directly compete with the iPhone but diminish the iPhone market by making the mobile platform more open and more competitive. How you ask? Well by giving all phone makers the ability to get a hold of a quality, free mobile OS platform that can compete with the apple iPhone, its only a matter of time before the market has a dozen or so Phones that can do what the iPhone can do, better, faster, cheaper and with more style. Open source rules.

Found a great little snippet of code to use for converting from American to Euro date format and back.

$date=’12/31/2006’;
print ereg_replace(”([0-9] )/([0-9] )/([0-9] )”,”\\2/\\1/\\3″,$date);

Thanks to last-child.com for the Snippet.

A new Zune

Well looks like Microsoft is taking another swing at an mp3 player. Hopefully it will do much better. I do like the fact that the first gen Zunes are getting all of the features of the new zunes. Score one for Microsoft.

 

From Engadget:

Hard drive Zunes

  • It’s called the Zune 80 and, shockingly enough, it has 80GB of storage.
  • Uses the new Zune Pad — four way touch-sensitive d-pad (with up, down, left, and right buttons).
  • It will sell for $250 (with “premium” headphones).
  • Available only in black (to start).
  • Screen size has increased to 3.2-inches (from 3-inches). As far as we know the resolution is still QVGA.
  • Dimensions are 61.1 x 108.2 x 12.9mm (2.4 x 4.25 x 0.5-inches), some 1/3rd smaller than the classic Zune.
  • The classic Zune will now be known as the Zune 30 — it’s not going anywhere. More on that in a sec.

New flash Zunes

  • Zune 8 and Zune 4 are the names for the 8 and 4GB flash based models.
  • Also uses the Zune Pad.
  • These will sell for $200 and $150 respectively.
  • Both will be available in pink, green, black, and red.
  • It will feature a 1.8-inch screen (compare to the nano’s 2-inch screen).
  • Dimensions are 41.4 x 91.5 x 8.5mm (1.6 x 3.6 x 0.33-inches) — compare to the new iPod nano, at 69.8 x 52.3 x 6.5mm (2.75 x 2.0 x 0.26-inches).

Everything else

  • New Zunes ship in November, date not yet announced.
  • All Zunes (including the Zune 30) will have a new, redesigned interface and feature parity. In other words, early Zune 30 adopters will have all the same software features as new Zune 80, 8, and 4 users.
  • Additional native video codecs for h.264 and MPEG-4 — users no longer need transcode those file types to WMV.
  • Zune can FINALLY sync video from your Media Center PC! Jeez, took you friggin long enough, guys!
  • WiFi sync to host computer! Includes moving over music, movies, photos, podcasts, etc.
  • Podcast support! (Sorry, no over the air downloads — sync only.) Podcasts can also be shared via WiFi.
  • The 3×3 song sharing DRM has had its three day restriction removed, but users can still only play files three times.
  • There is still NO wireless music store.
  • The Zune software is all new and rewritten, and is supposed to actually be more than a rebadge of WMP10 now. Friggin finally.
  • The Zune music store is going DRM-free, with over 1m MP3 tracks being made available for download. Other details (like which labels, whether there is a DRM-free upgrade path is for users who’ve bought music with DRM, price differences, etc.) are not yet revealed.

National Broadband Strategy

When you think about the world today, do you see most shopping and services are done in brick and mortar shops. It has always been done this way, but things are changing. Today we have global marketplaces with global reach via the internet, but why then is the US slipping in the world on broadband penetration into our country?

For lack of a better reason it appears to be apathy, our lawmakers, our people are getting more and more apathetic. We just don’t care to see beyond out little lives and how it affects the big picture. We are a nation always on the leading edge of technology and revolutionary new ways of doing things, so being 11th in the world on broadband penetration seems like we are dropping the ball on technology. At least now we have a few FCC commissioners willing to go before the senate and spout the virtues of building a plan and executing. They are talking about gathering useful data and then spurring competition in the broadband market by giving tax credits and investment subsidies, this will get us part way to where we need to be but the other part is you.

Well not you particularly, because if your reading my blog there is a good chance your on broadband, what I mean is us the people demanding more, and better service. When we know technology is out there and could make things better we living in a market economy should demand what we want. If you want something, there is a good chance there is someone willing to sell it to you.

Without the push for a broader national broadband strategy, how much farther are we willing to fall behind in technology?
Ars Technica

Facebook Code leaked

Well the code for facebooks index page has been leaked and I had a chance to look it over. I was curious as I develop in PHP on enterprise level apps and wanted to see how they do their code. Here are my few impressions:

Pros:
They use templates, That is always a good thing, it separates code from HTML.
Its clean, you can tell they use coding standards.

Cons:
Little evidence of OOP (Object Orientated Programming.)

The link to the code has been taken down with Facebook slapping a cease and desist on the blogger. But if your still curios you can find screen shots at http://bayimg.com/lAFLaaAbl

A scrollable Div

Well I was asked if I could out content in a window that was scrollable without using an iframe. I personally dislike iframes so I was happy to oblige. Its actually quite a simple task when you get down to it, so lets get started.

1. Create your div.

<div>Paragraph or two of text here….</div>

2. Add the styles to the div.

<div style=”overflow:auto; width:200px; height:200px;”>Paragraph or two of text here….</div>

If you’re using a linked stylesheet or defining it in the header you would use this CSS:

div.scrollable {
width: 200px;
height: 200px;
overflow: auto;
}