Posts tagged: Software

Validating an e-mail address

Question: How do I verify if a string of characters is a valid e-mail address?

First, you can only be sure about the second half of the e-mail address (the domain), as (in order to protect the anonymity of their users) many e-mail servers don’t give immediate responses when checked to see if the first part of the e-mail address is valid (although some will send a bounce notification at a later date, once an e-mail has been attempted).

Second, you can only TRULY verify if the domain address is accurate if the testing application has internet access.

So, without making a DNS call (or before), you can’t be absolutely sure that the user or the domain actually exists, and can never be sure if the user (and therefore the email) is an actual e-mail address.

But you can check to see if the format is valid using a regular expression. And this is where things get REALLY tricky, as how restrictive you want to be in your filtering depends on you, and while there is a defined standard, simply adhering to that standard may exclude e-mail addresses that are in use.

It seems that the most common regular expression that is suggest on the web is the following:

^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$

This will cover ALMOST all e-mail address you will run into, and will exclude obnoxious e-mails like badpirate@gmail.com.nospam

However, it will exclude a few e-mail addresses that are in use (but are probably being excluded and having trouble in lots of places:

  • kevin@yesthistldexists.museum – Yes .museum is a valid Top Level Domain
  • kevin@kevin@logichigh.com – Yes the current e-mail RFC doesn’t allow this type of e-mail address HOWEVER older RFC’s did, and so there may be some folks still using this format (and not being able to use this format in lots of other places)
  • ??@??web.jp – International characters in domains and user names are already being normalized to ascii friendly code by browsers and e-mail clients, so they are being used regularly, however if you are checking before that normalization occurs, these sorts of e-mail addresses will get tossed

Therefore, I’ve also written a super lax e-mail format checker that will catch all scenarios. This reg ex would probably be best used if you plan on checking to see if the domain exists after checking to see if the format loosely matches SOME format that COULD be in use :)

^.+@.+\.[A-Za-z]{2}[A-Za-z]*$

Finally, if you’d like to implement this in cocoa code:

BOOL NSStringIsValidEmail(NSString *checkString)
{
	NString *stricterFilterString = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
	NSString *laxString = @".+@.+\.[A-Za-z]{2}[A-Za-z]*";
	NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
	NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
	return [emailTest evaluateWithObject:checkString];
}
  • Share/Bookmark

PirateWalla iPhone

Coming soon!

Arrr… For the truly compulsive GoWalla user.  This here application will perform an ever growing spiral search from your current location and will find any booty (items) you have not collected yet in all nearby locations.  Yarr.. and it can be fine tuned to even help you lower the issue numbers of your existing collected items.
Why would you want to do all of this?  Because you are compulsive.  And gotta have them all.
Why am I charging $5??

  1. This tool is incredibly effective at helping you find rare items.  Rare items that I might also need.  Rare items that other users of the application would just as soon hope that YOU never find.  By making it cost as much as a draft beer, I can assure that only the devoted pirates find the treasure.
  2. The Gowalla API be a shifty one.  Gowalla changes the way their backend works ALL THE TIME, and with NO WARNING.  I could do this application for free… but the upkeep would soon make it not worth the effort to update, and it would be a free broken application.  By charging a few bucks, I can make it worth my time to deal with the GoWalla headache.
  3. I’m a pirate.  Yarr.  Need dub-loons to buy rum.
  • Share/Bookmark

PirateWalla

I made a tool that should be useful to people who play GoWalla too much.  Currently, it has two functions:

  • GCD – Gowalla Compulsive Disorder – Gives you a score based on how many items you’ve collected and how cool (low number issue) they are.
  • Search Oahu – Searches ALL of Oahu and your friends inventories for items that you need in your collection and tells you where to find them.

Enjoy.

PirateWalla

  • Share/Bookmark

Malama Card Application

Just finished another iPhone Application, and you can find it in the Apple Store for free starting today!  Start getting great savings around Hawaii using this Malama Card Application built for Kamehameha Schools.  And keep your ears open for more great applications from Logic High Software!


Fast Tube by Casper

  • Share/Bookmark

Beta Testers Needed

Hey everybody, I’ve got a new geo-location based game coming out very soon that I’d like to beta test a little bit before it’s launch.

Specifically I’m looking for iPhone 2G, 3G and 3GS owners, preferably in the Oahu area as the game is multi-player and depends on having friends to battle with, however if you have a few friends who are also iPhone owners and want to test it out in your area then that is dandy as well.

Sign up for the beta tester mailing list to be a tester

  • Share/Bookmark

You call that art?

He sat in a poorly lit corner of the furniture crowded coffee house.  His apparel would become outdated if you described it.  Pen in one hand, and a black notebook in the other he bent over his work.

She was at the counter, chatting with the barista, biding her time until she noticed him.  The attraction instant and subconscious.  A primal understanding, here was a mate with talent.  The way young girls swoon over pop stars, or the girl at the bar goes home with the guy that clears the pool table.  She approached the table and sat.

He glanced up from his work, immediately taken in his own way, physically reacting to his own unconscious understanding of her quality.  He felt fueled and inspired by it.  Whether or not he realized it, sitting across from him was the only reason he practiced his art.  His designs the human equivalent of carefully pruned plumage.  He smiled at her, and went back to work, with passion and drive.  He could work the rest of his life sitting across from her, the power of woman so subtle and strong.

She sat and watched him work for a while, without saying a word.  Enraptured in the way he would look up every now and again, making her wonder, is it a portrait?  Or maybe a poem.  Perhaps he’s writing a screenplay.

Is it about me?

“Can I see?”

He clutched the notebook close to his now palipitating chest.  This was his work, what would she think?  It is a big moment, but he has courage and confidence.  He smiles, and pushes the notebook across the table.

She looks at it slowly moving it from side to side.

“What is it?”

Perplexed with a sprig of disappointment she looks to him.

“Code.”

Read more »

  • Share/Bookmark

Software Blog

I’ve taken the Logic High Software portion of this blog in house so that I can access some of the better features of wordpress.org

All the old posts will remain here, but new posts will be made at http://software.logichigh.com

See you around!

  • Share/Bookmark

Fix a string in PHP for use in Unix Filenames

Language: PHP

Problem: You are trying to use a string as or in a UNIX filename (for instance, passing a filename to a command within the exec() function) and addslashes() falls short because it doesn’t include spaces or ampersands.
Solution: It’s rough but it works fine.  Run your strings through this function first, and don’t use surrounding quotation marks (no need).  If you’ve got a better one or have questions, leave a comment :)

function makeUnixFilename($string)
 {
 return str_replace("&",'\&',str_replace(" ",'\ ',addslashes($string)));
 }
 
  • Share/Bookmark

Gamers Assistant 1.1 available now!

Check out the new version of gamers assistant in the iTunes store!

I’ve also added two new howto videos to show off the new features and functionality

Find them, and read more in the gamers assistant blog.

Finally… Because it’s a new version, here are some free codes (Let me know if they are all used up)!

XEXEY3XEYNEJ
RJWTTYYPE64E
6MTFMXWLKNT3
NLFT6T4JTFA3
9KW6AJWTH7EA

  • Share/Bookmark

Gamers Assistant howto – Dungeons and Dragons setup

Check out gamers assistant in the iTunes store!


Fast Tube by Casper

Sample How to – setup Gamers Assistant for use with Dungeons and Dragons

  • Share/Bookmark

WordPress Themes