Archive of articles classified as' "Coding"

Back home

Source order of jQuery Mobile – don’t overlook it

23/04/2012

I normally don’t like doing stupidly short posts but I feel a need to publish the stupidity of my oversight on this one. It didn’t take long to spot it but still…

I’ve recently been converting a mobile app to be web based and had been noticing a few unexplainable problems with it such as the back functionality being inconsistent and clicks not registering half the time. That was before I noticed that at some point I had moved the source order of my script links in the head of my document.

So I just wanted to highlight for anyone else out there that has had a lapse of sense that this is how it should be:

 

No Comments

Rubber banding issue using iScroll 4 with jQuery Mobile – Fixed

24/02/2012

It’s obvious and has been for a year or two now that mobile is massive and will only get… massive-er. However mobile app development in it’s current stage of evolution is not exactly a nirvana. I’ve made my opinions clear on where the development of mobile apps ultimately lies but along the way native apps will be important stopgap.

A recent mobile phone app that my company got commissioned to design and develop required that the user be able to scroll through content within the mobile view-port. It was decided that the project would utilise PhoneGap + jQuery Mobile. This was to be able to build the app within a short time frame whilst still being able to target iPhone, Android and BlackBerry. The other main reason being that the budget wasn’t large enough to employ an Obj-C and Java programmer. Bet this sounds familiar to you right?

So with the groundwork laid let me get to the point!

Read the rest of this article »

7 Comments

Isn’t Modernizr great! but watch out for a bug in version 2!

7/09/2011

modernizr

The Good

Not too long ago I was developing a website for a pretty high profile technology conference. Of course it was being built with HTML5 and all that good stuff. As I’m sure you know dear reader if you plan on using features available in modern forward looking browsers you really should provide a fall back for older (read IE) browsers that don’t support the new approaches.

Instead of me just telling you what library is best why not give it a search using a term such as ‘detect browser features‘. What comes up top? Modernizr! Honestly you really should look into reading a few review of this library.

If you are a web developer and you don’t know about or currently don’t use this library you’re really really missing out! I’ll assume you know why simply detecting the user agent of the browser and serving customised code to it is the wrong path, if not read up.

Of course if you can’t use browser detection then what is there. capability detection. Essentially this is what modernizr does. It tests the current browser for certain capabilities and then appends a class to the page’s body tag to let you test for the inclusion/exclusion of that certain feature. For example if css3 background gradients are not supported then the body tag will have a class of ‘no-cssgradients’ whereas if the browser does support it then the class will be ‘cssgradients’.

What this offers the developer is priceless. A reliable and easy to implement method to do the right thing (capability detection). No more is there an excuse for mere browser detection.

The bug!

Now the thing is I was a bit lazy one morning and instead of going to the modernizer site and downloading the most recent copy of the library I simply grabbed one that I had already downloaded not too long ago. That was my mistake!

The version I was using was 2.0. Here’s the thing. Version 2.0 has a bug in it that causes IE7 to not visually display the webpage. It will either be white or the previous page displayed. If you view the source of the page it’s all present. This had me scratching my head a bit as well as unleashing a torrent of unsavoury terms at the test PC running IE7.

After trying a few investigatory things to prod the page and try and direct my search in the right direction (try searching Google for ‘blank webpage’!) I eventually thought about Modernizr. Not for any particular reason, it’s just that when you don’t have a clear idea of what is causing a problem the mind tends to wonder and come up with solutions.

So I head to Google and narrow my search down to focus on Modernizr issues, sure enough after opening and closing a few tabs I hit on this page – https://github.com/Modernizr/Modernizr/issues/296.

The takeaway

The takeaway from this little article is to keep on top of new releases of libraries you use on your sites. I learnt my lesson. I saved 5 minutes but ended up loosing an hour or two. Learn from my mistake. Oh and if you happen to be using modernizr well done but make sure if it’s version 2 you update it!

If you happen to know of any other interesting bugs with modernizr do let me know. I hope this article can help someone in the future.

No Comments

Tip using PHP’s system/exec command running under MAMP

4/08/2011

For a few hours yesterday I was driven mad by not being able to get a simple system command to run at all. Let me quickly detail what it was that threatened to drive me round the bend.

The database powering a high traffic site we developed for a client had become too big to be backed up using the standard PHP method. In my case I was using Codeigniters database backup utility. All this does is put a nice wrapper around the standard approach. As an aside if you haven’t looked into Codeigniter I would recommend you do so. Compared to the other frameworks available it is one of the fastest (Cake coming in the slowest) and easiest to get going with. Escpecially in it’s 2.0 version rev where it dropped it’s support for PHP4 (finally!) it is I think a brilliant choice to build your web sites/applications on. Of course the other good approach being WordPress.

Anyway back to the tip! If (when?) your database becomes too large to backup using PHP you have to use another approach. Luckily MySQL has a backup program built into it. You can access it via the shell. It’s called ‘mysqldump’. It isn’t bothered by the restrictions that bug PHP such as a scripts memory limit or max execution time. Because of this it can backup large databases. Now to be clear the database wasn’t massive. I’m not talking terabytes but merely a few hundred megabytes.

The first and most common command that most tutorials/troubleshooting guides show is something similar to this:

Read the rest of this article »

1 Comment