Strings


I went over some selenium tests today and found this code that creates a string that is used in order to test that validation is fired whenever the text entered in a text box has a greater length that allowed.

 
var temp = new StringBuilder();
for (var i = 0; i < 52; i++)
{
      temp.Append('x');
}
longerThan50Chars = temp.ToString();

 

This is all good and working code but it can all be replaced with just one line.

public static string longerThan50Chars = new string('x',52);

author: Vlad Balan | posted @ Saturday, September 04, 2010 1:21 PM | Feedback (0)

Check if an email address is valid


/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i
 
This regular expression will check if an e-mail address is valid.An extended comparison here

author: Vlad | posted @ Sunday, June 20, 2010 4:14 PM | Feedback (0)

Multiple Google calendars sync on the IPhone


In order to be able to sync multiple calendars on your iPhone you need to first select the calendars that you want to sync. For some reason not all calendars are synced automatically... https://www.google.com/calendar/iphoneselect

author: Vlad | posted @ Saturday, June 19, 2010 10:20 AM | Feedback (0)

Remember kids


When creating jQuery custom utility functions always use this pattern because it protects the use of $.

(function($){
   $.foo = function(argument) {alert(argument);}
})(jQuery)

author: Cyby | posted @ Sunday, November 29, 2009 4:14 PM | Feedback (0)