Author: Jamie

  • A Short Rant About Coding Conventions

    Yesterday’s article actually got me a little amped up about coding conventions – Comparing a while loop against a foreach loop of an array – because I never thought I would actually have to do a comparison between a while loop and a foreach loop on an array!  If we go back and revisit the post, I was reviewing a recent CakePHP commit for an optimization on the Hash class.  The code in question is three separate blocks of code that leverage the array_shift function to get the next value in the array with a foreach loop instead.

    (more…)

  • Comparing a while loop against a foreach loop of an array

    Are you confused by the title?  I was when I first got the idea to even write this blog as well.  I was recently perusing the CakePHP change logs and came across an interesting commit – Optimization for Hash Method.

    The optimization is quite simple, this code:

    [code]
    while (($key = array_shift($parts)) !== null)
    [/code]

    Is replaced with the following code:

    [code]
    foreach ($parts as $key)
    [/code]

    This is actually done several times in the commit.  It seems that the original developer is really keen on using the array_shift function.  Just in seeing this code, I thought the original code was odd to utilize that function so I immediately had to do a comparison and validate the optimization!

    (more…)

  • PhoneGap and Jquery Mobile – A Truly Winning Combination

    Any regular readers of jQuery tutorial may have noticed that I finally got around to updating and adding a new book under “My Books” on the right-hand side of the screen.  Yes, I not-so recently published my third book (and second with O’Reilly) earlier this year.

    The book is called 20 Recipes for Programming PhoneGap – Cross-Platform Mobile Development for Android and iPhone.  Throughout this book, I get you up and running quickly using the PhoneGap API along with the Jquery Mobile API to take care of the pesky mobile design issues. On occasion you may get errors like How to check for undefined in JavaScript so hopefully this will help.

    Much like I did when I released my MVC 3.NET book, I provided a free chapter from the book for my readers.  Well here is an excellent recipe sample from my PhoneGap book.  The goal of this recipe is to provide a standard approach to automatically fire (or trigger) a JavaScript function when a PhoneGap page has loaded – either on initial launch or after the user has navigated within the application.

    (more…)

  • Are you having CakePHP and NGINX Rewrite Rule Issues?

    In a recent blog post – It’s LEMP Not LAMP – I discussed about making the switch to using NGINX (pronounced Engine-X).  I had little-to-no issues getting by basic WordPress blogs up and running.  However, for some reason I couldn’t get my older CakePHP sites up and working.

    I was racking my brain forever, trying everything I could think of with the rewrite rules – thinking for sure this must be the root of the cause.  In the end I thought it might just be an issue with the version of CakePHP I was using, as it was an older version (1.2.x).  However, I just grabbed a clean copy from CakePHP’s Github of 1.2.10 and got it up and running without issues.

    I’m of course even more confused at this point, so why am I writing this blog post you ask?  The answer is simple, if you’re having issues with getting an old CakePHP site to work on NGINX, try upgrading your CakePHP version. (more…)

  • What I Learned This Summer

    Well – it’s Friday and all of the kids are back in school.  While this post is being published, I’m probably stuck in traffic!  I can’t believe it’s a new school year already, luckily my kids aren’t old enough so it’s just traffic that I need to get used to.

    This has been a great summer so far and I thought it would be a good idea to summarize the variety of things I’ve learned about – but have not necessarily blogged about…

    (more…)