Email Regular Expression June 10, 2006
Posted by Lucanos in : programming, php, javascript, snippet , 1 comment so farI found a site which had a very good regular expression to test email addresses, at http://www.codetoad.com/asp_email_reg_exp.asp.
However, one slight modification to their original test, which has been annoying me a bit as of late, is the addition of the plus symbol “+” as an acceptable character in the middle of the username section.
A terrific tool to test Regular Expressions is available at http://www.cuneytyilmaz.com/prog/jrx/. Well worth a visit.
The reason I have been using the “+” symbol and been running into lesser validators, is because GMail allows you to tack on tags behind your username to help you sort and manage your email inbox.
So I can subscribe to a newsletter with the address “lucanos+newsletter@gmail.com” (as “lucanos” is my GMail username) and then setup my GMail inbox rules so those emails are handled in a specific way.
It’s also a good way to identify sites which are selling your address, or spamming/ all you do, if required to provide an email address, is create one in the format “GMailUsername+SiteDomain@gmail.com“. Then, if I get spam to that specific email address I know where they got it from, as the culprit’s name will be included in the destination address.
Pretty tricky, hey?
Eternal Copyright May 25, 2006
Posted by Lucanos in : Uncategorized, programming, php, snippet , 1 comment so farNow, for the most part, I don’t like copyright. I far prefer the far more community-minded and development-driving concepts of copyleft, GPL and creative commons. The only times I use copyright is when it comes to my photography (especially for commercial uses) and major software work (like a contract or a large project).
Copyright, from my understanding, is established by simply putting the copyright symbol “©” (”Alt-0169″ in most word processors and “&0169;” in HTML) the word “Copyright”, your name or business name, and then the year. The year is meant to be the year the item/photo/whatever was first created, and then, if it was updated after that time, it’s meant to have a dash, then the most recent year when a change was made.
This is all well and good when dealing with something static. Like a plain vanilla HTML page with static information, or a photo, or something that doesn’t change. But what about dynamic pages? What about pages like those served using a Content Management System, or your own PHP & SQL concoction? With those kinds of items, the content is constantly changing (or has the potential to do so), so the year section in the copyright notice also needs to be chaning constantly.
How to do it…
Easy, provided you have the ability to write PHP code into your page templates. In WordPress that shouldn’t be too hard. I know that in TextPattern all you do is put the PHP betweeen the … tags. The rest? Do a little research, and if you still have problems, let me know…
The code?
$startYear = 2006; // The start year
$currYear = date(”Y”);
echo $startYear.( $currYear > $startYear ? ” - “.$currYear : “” );
All you do is put the “&0169; Copyright John Smith ” in front of that baby and Bob’s your aunty’s live-in-lover.
If you have any problems with this snippet, or any suggestions, please feel free to comment here and I’ll see what I can do to assist.
UPDATE
I have created a TextPattern Plugin to automate the insertion of these notices, as per above. The plugin, when given a start year, generates the dynamic year range (e.g. “2000-2006″) and includes the Copyright Symbol.
Download it here.