Tuesday, July 24, 2012

PHP Inline HTML

http://www.4webhelp.net/tutorials/php/echo.php

The article in the link above describes the process of adding inline HTML to PHP code instead of "echo '<html>';". It seems like it's much faster to not process each echo statement with PHP.

This is definitely a big "oh!" moment for someone still learning PHP.

Jquery Mobile - Only Load Once

If you only want something to load once, you can use the "pageinit" event.

Here's an example of some code with "pageinit":

$(document).delegate("#yourPage", "pageinit", function(event) { alert( "ALERT!"); });


The code above would not run if you visited the page again.

Monday, July 23, 2012

Make Phonegap Responsive

The following was absolutely mandatory for me to get my phonegap app to be responsive: https://github.com/cargomedia/jquery.touchToClick

Without modification, Phonegap will wait for a "double-click" after the user taps. This results in a noticeable delay. With the plugin above included, it removes the delay.

Other plugins I tested wanted me to use selectors for each element I didn't want delayed.

Monday, July 16, 2012

Prevent Scrolling

http://hankchizljaw.co.uk/tutorials/prevent-window-bounce-phonegap-1-7-ios-tip/13/05/2012/

The above link is the most simple solution I've found to prevent phone gap from scrolling outside of the bounds.

Thursday, July 5, 2012

Using Quotes In mysql_fetch_array()

According to this blog post: http://www.securityandcaffeine.com/2008/04/03/php-mysql-and-mysql_fetch_array/

mysql_fetch_array() can be sped up dramatically by including quotes, like this:

 $result['2'] rather than this $result[2]


I just changed my code to use quotes, and I haven't noticed a big speed increase (that's probably not where the bottleneck is).


Edit: This is probably misleading according to the good people at stackoverflow. http://stackoverflow.com/questions/11345894/mysql-fetch-array-quotes-increase-speed

Tuesday, July 3, 2012

Sisyphus.js

I'm really impressed with sisyphus.js and its usage of HTML5 localStorage. It makes it so users won't need to re-enter data into a form when they close the window.

It's super easy to implement, you only need to include the following in your header:

<script type="text/javascript" src="sisyphus.min.js"></script>

And, you will need to activate it on the form you want to save with something like this:
$('form').sisyphus();

Source:  http://simsalabim.github.com/sisyphus/