Since posting Simple Mobile Browser Detection in PHP I have received feedback indicating that an iPad is not considered a mobile device. It ultimately depends on your definition of ‘mobile’, but I see their point in that tablets are very different from cell phones. Screen size and browser capability are pretty different between mobile phones and tablet/pads, so I can understand why you’d want to distinguish between them.

So I updated my code to detect just mobile phones:

function is_mobile_phone()
{
	$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
	$mobiles = array("iphone", "ipod", "blackberry", "nokia", "phone",
		"mobile safari", "iemobile");
	foreach($mobiles as $mobile)
	{
		if(strpos($ua,$mobile)) return true;
	}
	return false;
}

I removed ipad and kindle since those are easy to detect. I removed android, palm, and mini since some of those can be tablets. I added IEMobile for Windows phones. But the most significant change is replacing ‘mobile’ with ‘mobile safari’ and ‘iemobile’. Google had pointed out that it’s best to look for android AND mobile, but it’s just as easy to search for ‘mobile safari’. Most cell phones have a string similar to:

“Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; T-Mobile G2 Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1″

Whereas most tablets have a string resembling:

“Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10″

I came across a couple user agent strings that don’t follow these rules, but weren’t very popular devices. This should cover 95% of the cases.

 

In developing TaskShot, I wanted to determine which users were using their cell phones to browse the site. A quick search yielded many large classes, bloated snippets, and code that did way too much. All I needed was to detect if they were coming from a mobile phone or not.

I figured the simplest way would be to check the user-agent header for a few keywords. I got this list of keywords after browsing through this recent list of mobile browser agents

Here’s what I came up with:

function is_mobile()
{
	$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
	$mobiles = array("android", "iphone", "ipod", "ipad",
		"blackberry", "palm", "mobile", "mini", "kindle");
	foreach($mobiles as $mobile)
	{
		if(strpos($ua,$mobile)) return true;
	}
	return false;
}

I’ve collected lots of data so far and it seems to be pretty accurate, but as always let me know if you have any improvements!

 

I came across ConceptFeedback.com when looking for ways to get input on my Task Management App. The idea is simple – submit screenshots of your website to their community and as long as you have reviewed 5 other sites you’ll get people to review yours. There’s also a paid option where you can have expert reviewers look over your concept for $99 each. I opted for the free plan.

Pros:

  • I did get some useful feedback. I had submitted a screenshot and asked people to visit the demo and try to create and assign a task. Two problems areas were quickly identified:
    • It didn’t work on a Mac. I’m a proponent of browser testing, and although I had tested vigorously on Chrome, FireFox, Safari, and IE 7, 8, and 9, I had neglected a Mac. Apparently the right click menu doesn’t work, which extremely limits the features.
    • No one understood the difference between the 2 lists. The list on the left is all tasks by project. The list on the right is assigned tasks by staff. People were trying to drag tasks from the right list to the left, which doesn’t make sense if you know what they’re for.
  • It was free, and reviewing the 5 other sites before I could post mine was pretty easy. Some people provide just logos for review, which were quick to do. Other entries took me about 10 minutes each to provide useful feedback for them. I’m sure you could get it done quicker with weak input, but I didn’t want to do that.

Cons:

  • It was a bit buggy. The icons pointing out good, bad, info, etc. were mixed up. I would provide input about a ‘good feature’ and it would remark it with a big red X, very counter-intuitive. Also, one of my reviews just disappeared. I had 4 reviews submitted, but now there are only 3 visible, even though it still maintains a count of 4 in the description. Where’d it go?!
  • Support was nonexistent. I submitted the contact form hoping to get help locating the missing review. A week went by with no response. Then I found the owner’s email address and personally sent him an email. Still no response. I even checked my spam folders. Is he extremely busy or just doesn’t care?

Here’s a link to my specific project: http://www.conceptfeedback.com/concept-page/5771/task-management-system/

Overall, I’d do this again. It was relatively painless and provided decent insight that surprised me, just don’t expect any help if you run into problems.

 

In developing one of my task management projects I was playing around with creating a tracking pixel that could be used to measure performance. When this pixel was placed on the page, I noticed in Safari and IE the browser would ask me if I’d like to open or save the file.

Safari said:

Do you want to open or save this file?

Name: pixel.php

Type: PHP File

Internet Explorer asked:

Do you want to open or save pixel.php from taskshot.com

Both had the buttons to Open / Save / Cancel

 

As you can tell, this is not what I wanted to happen, in fact, it would probably scare people away. So I looked to fix it. Here’s the code I was using:

//spit out pixel just in case browsers want it
$im=imagecreate(1,1);
$white=imagecolorallocate($im,255,255,255);
imagesetpixel($im,1,1,$white);
header("Content-type: image/jpg");
imagejpeg($im);
imagedestroy($im);

I thought something had to be wrong with the header, and after trying another file type with success, I tried changing the content-type from jpg to jpeg.

header("Content-type: image/jpeg");

Surprisingly enough, that was all it took to fix it. I don’t remember where I got this sample code from, but it was wrong. Content type for JPEGs should be image/jpeg, not image/jpg.

 

As I work myself up the ladder at my job, I find myself managing more and more tasks and people. When it was a couple of us, and a few project this was not a problem. Back then I kept everything in a simple text document. Every day I’d re-prioritize the bulleted list in notepad and make notes next to each item as progress was made. But after a few months that file became an eye sore.

So we tried the common project management tools: Microsoft Project, 37 Signal’s Basecamp, 5pm.com, Todo.ly, and even the new Trello. And all failed.

It’s not that they’re bad tools. They are great tools…for some companies. But our company works differently. We don’t have due dates. We don’t have recurring tasks. We don’t need to exchange large files around. We simply have a few clients, which always have a few outstanding tasks (which are constantly being re-prioritized), and a few staff members. I couldn’t find something that worked for our setup.

I simply wanted a tool that could allow us to:

  • drag and drop tasks for easy prioritization
  • look at any project at know where we were at without several clicks
  • let me know what each person in our office was working on at a quick glance

I wanted a tool that didn’t exist.

So I built one.

TaskShot is my side project that aims to tackle the needs of task management where I work. And hopefully it can be used by others, because I know we’re not the only company that works this way. We’re already using it at my job and I’m very pleased with it so far.

I’m still developing a few core features, but if you’re interested in checking it out soon, you can submit your email from TaskShot‘s welcome page and we’ll let you try it out.

 

I have a script that needs to be run on a couple different servers every night. Problem is that each server has different database credentials, so I need to set the correct user name and password for each, otherwise it won’t work.

I thought about having a config file for each, but I wanted all code to be pulled from my git repository and not rely on other files that are supposed to be there.

First I thought it would be no problem – just check the $_SERVER[’SERVER_NAME’] and set credentials accordingly. This works fine when running through the shell, but when triggered through cron it kept failing. The problem is that when cron scripts are run most of the $_ENV variables aren’t set.

My workaround was just to use the __FILE__ ‘magic constant’, which is set even with cron. Luckily the different servers have different paths where the script is running from, so Example code:

if(strstr(__FILE__,"/serverpath1/"))
{
	$user = "xxx"; $pass = "xxx";
}
elseif(strstr(__FILE__,"/serverpath2/”))
{
	$user = "yyy"; $pass = "yyy";
}
 

I was surprised to see that Google’s new +1 code that we’re supposed to slather all over our pages doesn’t work in Internet Explorer 7. It simply just doesn’t show up. I wonder if this is a glitch, or if Google has just stopped supporting IE7 altogether.

 

I recently came across 2 blog posts which I found extremely refreshing. They have to do with people working their lives away so they can retire as soon as possible. Here are a few quotes from them…

Most people are still buying into the same old industrial age myth of “work sucks, so do as little of it as you can so you can live your life when you aren’t working.”

For years, we have been taught that work is something you have to do … so that you can do what you really want while you are not working.

I think a quote from Earl Nightingale is appropriate here.
“In an age where we’ve come to nearly deify leisure time, we’ve almost lost sight of the fact that virtually all of our satisfactions, rewards will come not from our leisure, but from our work.”

Life shouldn’t be wasted working towards for your retirement, it should be spent doing things you love.

There have been lots of positive comments, including this one:

Excellent! I am in the process of starting my own business, a bakery, because it is my passion and I love doing it. Living life day to day and being unhappy doing so isn’t what life is about. Have fun everyday, every hour, every minute. Thats what it is about.

I hope to be there one day…

Here are the original links:

http://www.37signals.com/svn/posts/1121-early-retirement-is-a-false-idol

http://www.entrepreneurslife.com/thoughts/entry/what-i-hate-about-the-4-hour-work-week/

 

I recently did a lot of research concerning the effects of your driving speed on your car’s fuel efficiency. I was very shocked by all the info and results I found. I was also shocked that there wasn’t 1 site that explained it all together. So, I created one:

http://www.mpgforspeed.com/

The site gives you the detailed numbers and facts, and explains why it is. As always, comments are welcome…

 

I just realized I have been running incorrectly for the past 10 years of my life.

I was a sprinter in high school track. I was taught at the time to always run on my toes. It made sense, and sense then I have always ran on my toes.

However, I didn’t make the connection that running on your toes is targeted for sprinting only! Whenever I ran long distances I was running on my toes. This was not a problem until recently, when I realized I have shin splints.

So I did some research, and this is what I find out. When you’re walking, you should strike your heel first. When running, your feet should hit the ground flat – no heel or toe first, but both. When you’re sprinting, go toes first. I’m going to take a couple days off from running to let my shin/calves heal and then try again, only this time running more balanced.

I also found the following advice, which I’m going to try out: “A proper distance running stride is difficult to describe without showing it, but it is truly thing of beauty. It should feel almost like you are pulling the ground underneath you as you glide over the road/trail/field.”

© 2012 ShaneLabs Suffusion theme by Sayontan Sinha