iPhone & iPod Detection

For detecting iPhone / iPod / iPad users and redirecting them to their iPhone-compatible website you can use this simple code snippets:

PHP

1
2
3
4
5
6
7
8
9
if(
    strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') ||
    strstr($_SERVER['HTTP_USER_AGENT'],'iPod') ||
    strstr($_SERVER['HTTP_USER_AGENT'],'iPad')
)
{
    header('Location: http://yoursite.com/iphone');
    exit();
}

Javascript

1
2
3
4
5
6
7
8
if(
    (navigator.userAgent.match(/iPhone/i)) ||
    (navigator.userAgent.match(/iPod/i)) ||
    (navigator.userAgent.match(/iPad/i))
)
{
    //Your redirection code here
}

.htaccess

1
2
3
4
5
6
7
8
RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]
RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$
RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301]

Ultra-light jQuery calendar

New concept for date selection jquery calendar.

Autor Blog: http://roberto.open-lab.com/2010/04/06/ultra-light-jquery-calendar/
Download page: http://bugsvoice.com/applications/bugsVoice/site/test/calendarPickerDemo.jsp
Download: Ultra-light jQuery calendar

AS3 Condicional Switch Stament

Imagine we can use switch staments with conditional operators other then strict equality.

This way we can do a code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var value:int = 2;
switch(value){
    case < 1:
        trace("Value is less than 1");
        break;
    case 2:
        trace("Value definitely equals 2");
        break;
    case >= 3:
        trace("Value is greater than or equal to 3");
        break;
    case > 1 && < 3:
        trace("Value is greater than 3 and less than 5");
        break;
    case !== 5:
        trace("Value definitely doesn't equal 5");
        break;
}

Navigating the web I have find one solution:

1
2
3
4
5
6
7
8
9
10
11
12
var value:int = 2;
switch (true) {
    case value < 1:
        trace("Value is less than 1");
    break;
    case value == 1:
        trace("Value equals 1");
    break;
    case value > 1:
        trace("Value is greater than 1");
    break;
}