Josh Schumacher: A PHP Developer

The biggest and the best in the Northwest

Josh Schumacher: A PHP Developer random header image

Strategic Analysis: Google Presentation

June 3rd, 2008 · 5 Comments

Important: This presentation was created in December of 2006, the information most likely is out of date. I am posting this in response to the demand from slideshare.

During my senior year at Western Washington University, for a final project in my Management 495 class, I did group presentation, performing a strategic analysis of Google and the positioning in the search engine market. I posted this slideshow to slideshare and received an incredible amount of comments and messages asking for the presentation. The presentation currently has over 25,000 views and over 100 favorites.

Like I said in the disclaimer, this slideshow is a year and a half old so a lot of the information is out dated. Also, looking back at the slideshow, there are some formatting issues that I would resolve if I had to go back and do it again. The presentation, was put together using Apple’s Keynote software. This was a group presentation so I was not the only contributer. The other contributers were: Charity Thomas, Frieder Mack and Jennifer Bell.

You can download a pdf version of the presentation here: Google Strategic Analysis Presentation [PDF] (December 2006)

→ 5 CommentsTags: Web 2.0

Standardizing a way to represent an object in PHP

April 23rd, 2008 · 2 Comments

During the process of designing our API at Treemo, one of the first major design implementation hurdles we had to overcome was how to standardize a way to define what data in an object was “exportable” and can later be transformed into XML. The solution that I came up with defines a Node and a NodeCollection object.

When deciding what the data structure should look like, I wrote some pseudo XML that we need to be able to model.

  1. <channel>
  2.         <owner name="testuser" email="" />
  3.         <list name="foo">
  4.                 <item id="123">
  5.                         <files>
  6.                                 <image href="" />
  7.                                 <3gp href="" />
  8.                         </files>
  9.                 </item>
  10.         </list>
  11. </channel>

A Node has a (string) $type, (mixed) $attributes and (NodeCollection) $children. Using the above XML as a reference, our root node (let’s call it $root) would have $type = ‘channel’ and no attributes. You would then add two nodes to the NodeCollection $children, owner and list. Owner would have $attributes of array('name'=>'testuser', 'email'=>'') and $children would be an empty NodeCollection.

The biggest design decision made about NodeCollection was that NodeCollection implements Iterator. By implementing Iterator, you can later foreach over $children and it can loop through the elements with no problem. Implementing Iterator is a pretty cool design pattern – I’ll have to write a post about it in the near future. The ability to foreach over $children helps tremendously when writing ExportNodeToXml.

Wrapping up, pseudo code to export and object to a Node that can later be transformed to XML would look like this:

  1. class Channel implements iExportable {
  2.     public function toExportable() {
  3.         $root = new Node('channel');
  4.         $root->children->addNode(new Node('list', array('name'=>'testuser', 'email'=>''));
  5.         $root->children->addNode(new Node('list', array('id'=>'123'));
  6.         $root->children->getNode(2)->children->addNode(new Node('files')));
  7.         $root->children->getNode(2)->children->getNode(1)->children->addNode('image', array('href'=>''));
  8.         $root->children->getNode(2)->children->getNode(1)->children->addNode('3gp', array('href'=>''));
  9.     }
  10. }

→ 2 CommentsTags: PHP · XML

I love public radio in Seattle

August 3rd, 2007 · No Comments

For the majority of my life, my dad worked for a public radio station in Spokane, KPBX, so I’ve always had an affinity for public radio. Since moving to the Seattle area and spending a lot of time in my car commuting to and from work (usually about 35 min – 1 hour each way) I’ve been listening to a lot of radio. When I first started commuting, I listened to a lot of commercial radio but I find that stuff gets really old, really fast. I can only listen to Umbrella by Rihanna so many times before my head wants to explode.

Recently, I’ve rediscovered my love for public radio. With the trio of eclectic music from KEXP 90.9, dance and techno from C89.5 and local, national and international news from KUOW 94.9 I can always find something good to listen to. Not only am I aurally satisfied, listening to public radio often seems to put me in a civically minded mood – encouraging me to soaking up as much information and culture as my brain can handle.

On another note, I haven’t posted in a while – after graduating, I started at a company called Ascentium. They are an interactive technical marketing and consulting firm. I worked there as a web developer for about 2.5 months and then I decided I wasn’t really being challenged enough and I missed writing PHP a lot. So I left to start working at a startup that I had looked at during my initial job search right after graduating, Treemo.

I’ve been at Treemo since the middle of June and I’m loving it. We have some really cool stuff coming down the pipe in the near future. Right now, I’m working on writing an API – very exciting work. Now that I’m working back in the PHP biz, I’m going to start writing about developing PHP again. Stay tuned.

→ No CommentsTags: Life

PHP – Delete selected items from an array

March 22nd, 2007 · 30 Comments

I was enlightened the day I discovered array_filter. You may find yourself with an array of values and you want to delete some of those values from the array. There is no ‘delete element from array’ function built into php but you can use an even more powerful function, array_filter.

Let’s look at a simple example. I have an array containing values, some are numeric, some might not be. I only want my array to contain the valid numeric entries and I want to delete the other values. PHP has a helper function we are going to be utilizing, is_numeric.

  1. $data = array(42, "foo", 96, "", 100.96, "php");
  3. // Filter each value of $data through the function is_numeric
  4. $numeric_data = array_filter($data, "is_numeric");
  6. // Re-key the array so the keys are sequential and numeric (starting at 0)
  7. $numeric_data = array_values($numeric_data);
  9. // Print out the new, filtered data
  10. print_r($numeric_data);

The output from above is:

    [0] => 42
    [1] => 96
    [2] => 100.96

Pretty handy function. Notice how I ran my data through the function array_values, before that function was run, the keys were (0,2,4).

Another example with a user defined function. I have defined a collection of tags and I want my tag collection to only contain tags that match the criteria the user has requested.

  1. $tagCollection = array("AJAX", "Analytics", "CSS", "Javascript", "", "PHP", "Prototype", "Web 2.0");
  3. // Custom function used to filter the $tagCollection based on query sent to page
  4. function strTagMatch($val)
  5. {
  6.   $query = isset($_REQUEST['Tags']) ? $_REQUEST['Tags'] : '';
  7.   return (stripos($val, $query) !== false);
  8. }
  10. $tags = array_filter($tagCollection, "strTagMatch");

Voila! Deleting elements from an array has never been easier.

For more information, see the php documentation on array_filter.

→ 30 CommentsTags: PHP

Howto: Exclude developer hits in Analytics

March 16th, 2007 · No Comments

When developing a site, I visit it a lot – OK Josh, that was an obvious. Point is, I was tired of tracking my visits to sites that I maintain. I really care about tracking significant users and how they navigate the site and what pages they find valuable but I don’t care about my hits.

I put together a quick page that I can navigate to that will install a cookie for the browser. I can then check for the cookie in my standard header include so the Google Analytics tracking code isn’t sent to the browser.

The code to set the cookie (and make sure it’s installed correctly)

  1. setcookie("hideAnalytics", 'true', time()+(3600*24*365*30));
  3. if(isset($_COOKIE['hideAnalytics']) && $_COOKIE['hideAnalytics'] == 'true')
  4. {
  5.     print "Cookie installed";
  6. }

Similar (but inverse) code is then inserted in my header

  1. <? if(!isset($_COOKIE&#91;'hideAnalytics']) || $_COOKIE['hideAnalytics'] != 'true') { ?>
  3. <? } ?>

Analytics is a great tool and it’s going to be even more useful now that I won’t be tracking my own hits.

→ No CommentsTags: Analytics · Javascript · PHP

Facebook, meet iPhoto – iPhoto, meet Facebook

March 15th, 2007 · No Comments

Update: iPhoto ’09 now has native support for uploading to Facebook so you don’t even need to download a plugin. You can read about it on the Apple iPhoto Site. They also have a quick video tutorial on how to upload to facebook from within iPhoto.

Image copywrite Facebook

I am impressed. Facebook announced their long awaited iPhoto exporter today. What does this mean? I can finally quickly load my pictures that I already store in iPhoto into Facebook pain free. I have been waiting for this for months, I was excited when the mentioned this was going to become a reality and then they released the ability to upload pictures using the API. I was ready to go and start making this app myself but we were told they were going to be releasing this feature soon.

Facebook delivered on this plugin and they delivered well. I am impressed, you can even tag your photos from within iPhoto! I hope all OSX wielding, facebook dwelling, photo taking folks enjoy this as much as I do.

Download the iPhoto exporter, you won’t be disappointed.

→ No CommentsTags: Web 2.0

It’s a redesign –

March 12th, 2007 · No Comments

Last week, I decided it was time to freshen things up on my portfolio site. This was a great chance for me to test my css powers and modify the presentation of my semantic XHTML without changing the markup (well very minimally changing the markup – I modified some content during the redesign so I had to modify the markup a little). The navigation changed dramatically but the markup was still a division containing an un-ordered list. If you’re interesting in looking at my css, feel free to find inspiration. You can find the before and afters below.

The first design of
The redesigned

→ No CommentsTags: CSS · · Life

Playing well together: Prototype JS and PHP

March 2nd, 2007 · 4 Comments

I’ve decided that manipulating dates client side is a mess. I’ve been working on a multi-user php calendar for the past few months. One of the features I’m most proud of is an availability chart similar to a feature outlook has so you can schedule a meeting with multiple people and see when everyone is free and busy.

Availability ViewSince I’m using Prototype for my javascript library already, I took advantage of the Prototype Window Class to make modal and dialog windows. One of the downsides to this is it adds another step of complexity to ensuring everything is properly synchronized. For example, my scheduler window has to maintain in sync with it’s parent window if dates where changed at that level.

To start off, I create actions for nextDay() and prevDay(). These are simply fired onclick() on buttons with corresponding labels.

  1. function nextDay()
  2. {
  3. updateAvailabilityChart('next');
  4. }

Next we’ll define the updateAvailabilityChart() function. The arrayInviteUsers holds an array of user ids (this is out of the scope of this article).

  1. // param change = none, next or prev
  2. function updateAvailabilityChart(change)
  3. {
  4. var startString = window.parent.getStartDate();
  5. var endString = window.parent.getEndDate();
  7. $('availabilityChart').innerHTML = 'Loading...';
  8. var counter = 0;
  9. var params = '';
  10. arrayInviteUsers.each( function(user) {
  11. counter++;
  12. params += 'userid'+counter+'='+user+'&amp;'
  13. });
  14. params += 'startString='+startString+'&amp;';
  15. params += 'endString='+endString+'&amp;';
  16. params += 'change='+change;
  18. var url = 'get_availability.php';
  19. var myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onSuccess: loadedAvail });
  20. $('q').value = '';
  21. }

The above code will make an Ajax request to get_availability.php which will increment, decrement or keep the start and end dates the same and then return some cool response text starting with the new start date, new end date and html for the availability table. I defined a delimiter of ‘^^;;^^’ just so I can tell where data starts and stops. Below is the basic code in get_availability.php.

  1. $strStartTime = isset($_REQUEST['startString']) ? strtotime($_REQUEST['startString']) : time();
  2. $strEndTime = isset($_REQUEST['endString']) ? strtotime($_REQUEST['endString']) : time();
  4. if(!is_numeric($strStartTime)) {
  5. $strStartTime = time();
  6. }
  8. if(!is_numeric($strEndTime)) {
  9. $strEndTime = $strStartTime;
  10. }
  12. if($strStartTime > $strEndTime) {
  13. $strEndTime = $strStartTime;
  14. }
  16. $change = isset($_REQUEST['change']) ? $_REQUEST['change'] : 'none';
  17. switch ($change) {
  18. case 'prev':
  19. $strTime = mktime(0,0,0,date('m',$strStartTime),date('d',$strStartTime)-1,date('Y',$strStartTime));
  20. break;
  21. case 'next':
  22. $strTime = mktime(0,0,0,date('m',$strStartTime),date('d',$strStartTime)+1,date('Y',$strStartTime));
  23. break;
  24. default:
  25. $strTime = $strStartTime;
  26. break;
  27. }
  28. $strTimeEnd = $strTime + ($strEndTime - $strStartTime);
  30. print date('m\/d\/Y',$strTime);
  31. print "^^;;^^";
  32. print date('m\/d\/Y',$strTimeEnd);
  33. print "^^;;^^";
  35. $display = new Display();
  36. $display->drawDayAvailibility($usersArray, $strTime);

Finally, the Ajax request defined a function to be called when the request return successfully. This function will update the innerHTML of a div on the page and tell the parent window what the new start date and end date is.

  1. function loadedAvail(transport)
  2. {
  3. var entityParts = transport.responseText.split('^^;;^^');
  4. var newStart    = entityParts[0];
  5. var newEnd      = entityParts[1];
  6. var html       = entityParts[2];
  7. $('availabilityChart').innerHTML = html;
  8. window.parent.setStartDate(newStart);
  9. window.parent.setEndDate(newEnd);
  10. }

This is a very small piece of a very large project but it’s fun to share with others. If you have questions or could benefit from some more of the details going into this basic process, let me know and I can post more.

→ 4 CommentsTags: Ajax · Javascript · PHP · Prototype


February 20th, 2007 · 1 Comment

I am graduating from Western Washington University this March – just over a month from now. It’s an exiting time, classes are winding down, the job hunt is on and we’re looking for a place to live in the Seattle area. My girlfriend Megan is going to be doing her student teaching in a second grade classroom in Normandy Park, WA and is very excited for that transition in her life.

My job search has identified a couple of fun companies. I’m really looking for a PHP/MySQL/CSS/Javascript position so if you know of anyone hiring or if you are a potential employer – I’m your man. My resume is available online at:

→ 1 CommentTags: Life