Josh Schumacher: A PHP Developer

The biggest and the best in the Northwest

Josh Schumacher: A PHP Developer random header image

Logging in Grunt

March 4th, 2014 · No Comments

I gave a lightning talk at the December SeattleJS Meetup on logging in Grunt. It was a quick and dirty walk-through on using the grunt.log api to add custom log messages, the use of --verbose and --debug when running grunt tasks and a few small bonuses about using color strings in your log messages and using the awesome grunt-prompt library.

Pro Grunt Logging on slid.es (the easiest way to view the presentation below is by using your back/forward arrow keys or opening the presentation in a new window).

Here are some additional resources:

→ No CommentsTags: Javascript

Installing pecl_http on OS X Mavericks (10.9)

October 23rd, 2013 · 1 Comment

After updating to OS X 10.9 I discovered apache wasn’t working correctly. Fixing apache was a simple fix – during the upgrade, the shipping version of Apache and PHP was updated so they installed a new http.config and removed my php.ini.

To get Apache up and running (and configured) again, run a diff of /etc/apache2/httpd.conf (this is the new httpd.conf created by the OS install) and /etc/apache2/httpd.conf.pre-update (this is the backup the installer created of your previous install).

To get PHP back to it’s previous state, copy /etc/php.ini.default (created by OS install) to /etc/php.ini. You can find your previous php ini with a -previous extension in /etc/ (mine was /etc/php.ini-5.2-previous). Do a diff between your old backed up php.ini-5.2.previous and the new php.ini, you’ll find a couple of settings you want to restore in php.ini.

The last headache I had was with pecl_http. I attempted to sudo pecl install pecl_http and I got the error:
checking for zlib.h... not found
configure: error: could not find zlib.h
ERROR: `/private/tmp/pear/temp/pecl_http/configure --with-http-curl-requests --with-http-zlib-compression --with-http-magic-mime=no --with-http-shared-deps' failed

This issue was finally solved by updating Xcode to 5.0.1 and then installing “Command Line Tools (OS X Mavericks) for Xcode”. The tricky part is Apple no longer lets you install command line tools from within Xcode – they have a new Downloads for Apple Developers site where you can download and install Command Line Tools (OS X Mavericks) for Xcode. You will need a free Apple Developer account in order to log in and download the command line tools.

After installing the command line tools, sudo pecl install pecl_http worked. I restarted apache and was good to go!

→ 1 CommentTags: Uncategorized

Fixing NIL errors from ‘XML-RPC for PHP’ library

April 25th, 2012 · 1 Comment

I was working with the pyapns push server, sending XML-RPC requests from PHP. A common response from pyapns is <nil/> which isn’t handled by default correctly by XML-RPC for PHP and instead you are given the error, 'Invalid return payload: enable debugging to examine incoming payload found not-xmlrpc xml element NIL'.

To solve this error, there is a $GLOBAL variable you can set after you have included xmlprc.inc that will change how the library interacts with nil elements.

  1. require_once('lib/xmlrpc.inc');
  2. $GLOBALS['xmlrpc_null_extension'] = true; // correctly handle <NIL> responses from pyapns
  3. $client = new xmlrpc_client(PYAPNS_RPC_PATH, PYAPNS_HOST, PYAPNS_PORT);

→ 1 CommentTags: Uncategorized

WordPress: transition_post_status action

October 11th, 2011 · 2 Comments

I needed an action to monitor for posts being published, unpublished or updated after they were already published in my WordPress plugin. I discovered Post_Status_Transitions and specifically the transtion_post_status action that is called for every change to a post’s status. I then check if either the $old_status or the $new_status variables are ‘publish‘ and then I know the article is either being published or being unpublished.

An important note when you are implementing the transition_post_status action

When you call add_action, you need to modify the $accepted_args parameter. The default value is 1, it needs to be changed to 3.

The action transition_post_status (as defined at http://codex.wordpress.org/Post_Status_Transitions) sends three parameters, $new_status, $old_status, $post.

If you only write add_action('transition_post_status', 'my_function'), the default number of parameters that are sent to my_function is 1 so you will only get the $new_status parameter and the other two params won’t be sent.

The correct syntax to add a transition_post_status action is: add_action('transition_post_status', 'my_function', 10, 3); my_function will then be called with all three parameters ($new_status, $old_status, $post).

Some good reference posts if you’re working with this action:

→ 2 CommentsTags: Uncategorized

XCode4 – The operation couldn’t be completed. No such file or directory.

April 6th, 2011 · 3 Comments

When attempting to share an application after archiving in XCode4, I kept getting an error message, “The operation couldn’t be completed. No such file or directory.” It appears that there was a similar issue in XCode3 that could be resolved by turning on “Generate Debug Symbols” but that did not resolve the issue for me at all.

Resolution: After clicking Share… in the Archives section of the Organizer, click on the identity dropdown. Do not allow it to use the Automatic Profile Selection, instead manually choose the correct profile to sign your archive.


If you manually select the identity to sign your application, you shouldn’t get the error message and you should be able to successfully save and share your application.

→ 3 CommentsTags: iPhone Development · iPhone SDK

Remove .svn directories from Zend Studio 7

October 29th, 2009 · 8 Comments

I recently upgraded from Zend Studio 6 to the Zend Studio 7.1 beta. During the upgrade, all of my .svn folders showed up in the file browser (who would ever want to see their .svn folders in the file browser…).

Project_File_Browser

To remove these svn folders from your project, right click on the project > Build Path > Configure Inclusion / Exclusion Filters…

Configure_Inclusion_Exclusion_Filters

Click “Add…” next to the “Exclusion patterns:” box. Add the rule “**/.svn/”. The “**/” will make it a recursive rule. Click Finish and your annoying .svn folders should now be hidden in the file browser.

Add_rule_to_remove_svn_folders_from_zend_studio_project

→ 8 CommentsTags: PHP · PHP Development

Enable Samba Access For A User (Linux)

October 23rd, 2009 · 1 Comment

If you are attempting to connect to a samba (smb) share and you are denied, there’s a high probability your user account hasn’t been granted access to the samba server yet. To grant a user access use the smbpasswd command line tool.

  1. SSH to the samba server
  2. Log in as root
  3. smbpasswd -a username
  4. Enter password (twice) – no characters will appear on the screen

Interesting note: if you aren’t logged in as root, the smbpasswd command line tool can be used to change you samba password.

→ 1 CommentTags: linux

Advanced iPhone Web Development

May 6th, 2009 · 3 Comments

Yesterday (May 5th, 2009), I gave a presentation at the Seattle iPhone App Developers and Designers Meetup titled, “Advanced iPhone Web Development.” This presentation focused on the unique capabilities available in WebKit on the iPhone and on possibilities for utilizing UIWebViews inside of your native applications.

You can download a pdf version of the presentation here: Advanced iPhone Web Development [PDF]

Advanced iPhone Web Development Slideshow (Best Viewed In Fullscreen)

→ 3 CommentsTags: CSS · iPhone Development · iPhone SDK · Javascript · Mobile Development · Web 2.0

The future of mobile web applications

March 18th, 2009 · 1 Comment

Thinking back three years ago, I was starting to play around with developing web applications for mobile devices.  The hot device of the time was the Palm Treo.  The default browser that came with the Treo, Blazer, really sucks.  It was rough trying to write pages that worked perfectly in Blazer.  Sure, simple, basic HTML rendered just fine but I had a background in developing for the traditional desktop web experience and I wanted to write awesome sites utilizing CSS and Javascript.  I wanted to write an AJAX application for mobile devices.  It would be icing on the cake if I could get it to work on lower end devices as well, but that seemed pretty pie in the sky at the time.

Webkit will be the future rendering engine of the mobile web (at least I hope it is).  It’s an amazing, full featured engine with bleeding edge web standards implementations of HTML 5 and CSS 3.  Webkit has been getting some great traction lately with some amazing devices implementing it as their default browser engine, Android, Palm Pre and of course the iPhone (and iPod Touch) have all fully embraced Webkit.  I want to see that list get a lot longer; I hope to start seeing Webkit on lower end mobile devices.

What makes Webkit so awesome?  How about CSS effects, blazing fast javascript execution (especially in their new Nitro engine in Safari 4), HTML offline support – including offline data storage and support for offline cache manifests, CSS gradients, CSS border radius and border images, CSS transforms, and a lot more.  On the iPhone, it now even has custom events to pass down gesture events to the DOM.  You can now do most things you could once only dream of doing in flash in straight HTML, CSS and Javascript on small devices stored in someone’s pocket.

The future of mobile web applications are social, location aware, providing a tailored experience based on user preferences.  Future mobile web applications will morph based on user behavior.  The will provide a graphically rich experience with beautiful design elements enhancing every aspect of the application.

→ 1 CommentTags: iPhone Development · Mobile Development · Web 2.0

Reading Common and Custom Values From Your Info.plist

February 19th, 2009 · 10 Comments

It seems like a pretty simple, common thing you would want to do in objective-c right?  All applications have an Info.plist (or a different plist file as defined in your “Info.plist File” property of your build target).  I’ve been pretty frustrated with the quality of google search results when trying to figure out how to do more or less mundane things with the iPhone SDK.  I’m going to start writting posts, especially when I have a hard time trying to find what I was looking for in search results.

Here’s the quick and dirty: I have a game that we’re building here at Treemo Labs, Tic A Tac Poker. We’re working on getting a lite version out the door. I wanted to read a custom value out of the Info.plist to tell if it’s the lite version or not. I couldn’t figure out how to read a simple value from the default property list file. Here’s some sample code to get the bundleIdentifier, bundle version and custom values from your Info.plist

  1. // Create a new NSBundle pointer
  2. NSBundle* mainBundle;
  3.  
  4. // The Info.plist is considered the mainBundle.
  5. mainBundle = [NSBundle mainBundle];  
  6.  
  7. // Reads the value of the custom key I added to the Info.plist
  8. [mainBundle objectForInfoDictionaryKey:@"myCustomKey"]
  9.  
  10. // Another handy thing I had to search around for a little
  11. // Get the value for the "Bundle version" from the Info.plist
  12. [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]
  13.  
  14. // Need the bundle identifier? (probably something like com.mycorp.product)
  15. [mainBundle bundleIdentifier]

For more information about the NSBundle, view the NSBundle Reference Documentation.

To see an alphabetical list of the standard keys you can use in an information property list file, along with a brief description and the platforms to which they apply (Mac OS X or iPhone) check out the Property List Key Reference.

→ 10 CommentsTags: iPhone Development · iPhone SDK · Objective-C