Need help?

I'm available for remote short term contracting or consultancy work. Please check out my LinkedIn profile for more details on my experience.

Please feel free to use the form below to contact me.



Code

Are you looking to find out how to include/require files on the fly using JavaScript? That's what we're going to go through in this article. The same functionality used in PHP to require/include other PHP files can just as easily be done in JS.

Before we can start, we have to download a JS library called RequireJS - this allows us to load files and modules asynchronously using JavaScript.

jon | April 22, 2010 | Comments (0)

In this quick tutorial I'm going to go through a simple example of how you can extend an object in JavaScript. The first thing you'll need to do is get jQuery, which you can get here: http://docs.jquery.com/Downloading_jQuery.

Once you have that included in your project, you can go ahead and extend an object by doing the following:

jon | April 22, 2010 | Comments (0)

If you're trying to programmatically figure out how to move or drag a view with your finger, then read on.

I was looking for a solution to this problem just the other day, and couldn't really find that much. What I needed was a view that you could move with your finger, and upon lifting the finger, it would snap into place at a set location. Seeing as I couldn't find anything like this, I decided to write my own custom view, which did just that.

The view I wrote extends UIImageView, but you can change that to UIView if you want. So how does this work you ask? Well, it basically takes a topLock, bottomLock, and whether it's moving on the x axis or not (if not, then it uses the y axis). The top lock is the x(or y) point where the view will lock into place, and same with the bottom lock. And how that works is that it'll check which one is closest, and lock it into that spot. So here's an example, if you drag the view up on the y axis all the way to the top and let go, it'll move it to the closest lock point (which will most likely be the top lock. This will also give that nice swing-back (gravity) effect that you see on the iPhone tableviews.

jon | April 22, 2010 | Comments (2)

I'm going to be referring to iOS related Objective-C, as the blocks were just released in version 4, so it's an interesting topic.

Before the blocks functionality, the typical way to do a callback would be to pass the delegate of the object which would be called to the worker object. Once the worker object finished the task, it would then reference a specific method (defined by the protocol), which executes the callback code. This approach works fine, but gets very bloated when you need to do certain kinds of tasks - not going to be getting to the protocols vs blocks in this article though. They do both serve their own purposes, and I'm just going to be getting into the relations they have to the Java anonymous classes.

jon | April 22, 2010 | Comments (2)

The process of parsing JSON in Android is pretty simple, thankfully. We'll be using JSONObject for all the parsing goodness - there are also some other JSON classes, but we'll just go through the basic ones to give you a general idea of how it works.

The first thing we will do is setup our JSON string, which we'll end up parsing.

jon | April 22, 2010 | Comments (65)

In this tutorial, I'm going to go through the process of setting up a Symfony project on a shared host (CPanel). I was unfortunately faced with this same problem, but was lucky enough to find the answers (after quite a bit of searching), so I thought an article would be in order. This article will also assume that you already have a database setup, with data in it.

jon | April 22, 2010 | Comments (0)

This article is going to walk you through some examples of how to use SAX to parse through XML documents, in an Android SDK environment.

There are actually 2 main ways of handling XML - SAX and DOM. The DOM parser loads the whole document into memory before it can work with it, which can be slow and uses up a lot more memory - the benefit is that you're not writing as much code. In this tutorial though, I'm going to be focusing on SAX, simply because it's the best for mobile devices, as they don't have a lot of memory. The beauty of SAX is that it goes through each element and attribute one at a time, and you can pick and choose which one you want added into memory, but you do need to write a lot more code (depending on what you want to do).

And before I forget, there is another called STaX, which is an XML pull parser, but I'm not going to get into that one.

jon | April 22, 2010 | Comments (23)

I'm going to go through the process of serializing and deserializing an object.

What this means is that we're going to convert an object into an array of bytes, which can easily be moved around or stored (for later use). And for deserialization we just take those bytes and convert them back into an Object.

jon | April 22, 2010 | Comments (5)

I wrote an article a few months ago, which walked you through the process of zipping files programmatically with Java - in an Android environment. Due to popular demand, I've decided to write up another article on how to unzip files.

The process is pretty similar, and you could probably combine them both in a single class, but for this example, I made a class called Decompress.

jon | April 22, 2010 | Comments (78)

This article goes through the process of combining 2 images (only works with PNG or JPG ). It will involve passing 2 Bitmaps, which will then get combined using the Canvas class - sounds simple huh?

jon | April 22, 2010 | Comments (4)

The concept of organising your JavaScript to this level may seem alien to some, but the advantages are limitless. This greatly improves maintainability and scalability, and as JS gets more and more advanced, so will the structure (from an architectural point of view).

Some of the best browsers to date have improved their JS rendering engine so much that you can basically build a full fledged application and wouldn't be able to tell the difference between a stand-alone app and the one running in your browser - amazing huh? Have you ever heard of OpenGL? Well, they're also coming out with WebGL, which will obviously be powered by JavaScript - say bye bye to flash and hello JS. If this alone doesn't convince you that it's growing extremely rapidly, then I don't know what will.

jon | April 22, 2010 | Comments (2)

The new OAuth protocol has been quick to becoming the standard for accessing secure data via APIs - it's also mandatory on some sites, or soon to become.

I'm about to show you a 3-legged process for obtaining an access token, which will give you access to the persons account that approved your request. With this token, you'll be able to update their status, and pretty much do what they can do, minus altering crucial account details.

jon | April 22, 2010 | Comments (164)

One majorly annoying issue that I stumbled upon, was the fact that I couldn't send multiple attachments using Intents to the Google Mail app. The quickest way around that was of course to compress all of the files into one (ZIP).

After searching around online, I didn't really find much on zipping files on your Android device - most of the articles were for standard java applications, which assumed that all your files were in the current directory that you wanted to zip.

So, I used what I could and whipped up my own wrapper class that allows you to easily zip files in Android!

jon | April 22, 2010 | Comments (378)

Have you seen other applications with Buttons (or other views, but mainly Buttons) that stay in one spot, even if you're scrolling through a list? These are commonly known as floating Buttons or Views.

This is actually used a lot on websites as well, and they may seem hard to produce at first glance, but it's actual quite easy.

I'll run you through an easy application that uses one floating button within a ListActivity, which is aligned to the bottom right of the screen - on top of the ListView.

jon | April 22, 2010 | Comments (6)

This is a subject that's seldom talked about, but can be quite important. The NDK basically allows you to port any native C/C++ code/libraries into your Android project, using JNI (Java Native Interface).

I'm going to go through a quick and simple example of how you can display "Hello World" in your Android application using some native C.

jon | April 22, 2010 | Comments (382)

The Android SDK makes it very easy to send emails from an application, but unfortunately, that's only if you want to send them via the built-in mailing app. For most situations this works fine, but if you want to send something out and don't want any input/intervention from the user, it's not as easy.

In this article I'm going to show you how to send an email in the background without the user even knowing - the application will do everything behind the scenes.

jon | April 22, 2010 | Comments (505)

The process for capturing, saving and displaying an image in Android can be quite annoying, especially if you want it to work across all devices.

With the release of the Sense UI (an HTC creation), it's made things 1 step more difficult. So, the reason I'm writing this article is because I've been stuck on this same issue for quite awhile, and there isn't enough information out there to let us know why it simply won't work.

Simply put, the Sense UI handles things differently when it comes to saving a new image after an intent was called (ie. new Intent(MediaStore.ACTION_IMAGE_CAPTURE)). In this article I'll show you how I overcame this problem and walk you through my code.

jon | April 22, 2010 | Comments (153)

Have you been trying to find a quick and easy way to format dates from a String? It can be quite tricky with Java (if you're new to it). So, I'm going to go through a few very simple steps to accomplish just that.

jon | April 22, 2010 | Comments (9)

If you're maintaining a blog and want a way to highlight code within your articles (for ease of reading), then this article may interest you.

I can't even begin to say how annoying it is to read a large chunk of code that has no color highlighting - this will improve readability and traffic to your blog (or whatever you decide to use it on).

jon | April 22, 2010 | Comments (2)

The Zend Config component is mainly used to access configuration files, but can also be customized to suit many different situations.

In this article I'll be going through an example of how you can extend Zend_Config and customize it to your liking (or my liking in this case). You'll also need to know (or should know) a little bit about the Zend Framework to understand what I'm talking about, and how to fit it into your projects.

jon | April 22, 2010 | Comments (1)