Russell Broadbent

Yorkshire based web developer

February 3, 2013
by admin

Form Captcha for Presta Shop

Specification includes:
- A captcha security question to be added to various forms on a website built on Presta Shop

Solution:
- Some of the standard Presta Shop modules that would facilitate this only run a captcha validation check with javascript turned off. This is not a bulletproof solution as most spam bots/web trawlers will be browsing the web with javascript turned off. The most effective solution I have found so far is to user the php variant of Google’s recaptcha script

February 3, 2013
by admin

Mircrosoft email migration

Specification includes:

- Migrating all email (folders and actual emails) from an IMAP Outlook account on Windows XP to a hosted Exchange Server on Windows 7

Notes:
- Be sure to sync ALL email and their folders on the IMAP account prior to exporting. Microsoft Outlook uses an OST (Offline storage) file to store any retrieved email locally on the machine. When exporting the email as a PST file, ready for the Exchange Account, the export process only transfers email/folders that has been fully sync’d with the OST file.

February 3, 2013
by admin

adding/removing JSON Objects in javascript

I’ve been playing with JSON objects a lot recently and part of a javascript method I was developing required them to be edited. My initial approach for doing this would have been:

var method = {
 datas: {},
 add: function(obj) { 
  var i = this.datas.length; i++;
  this.datas.splice(i, 0, obj);
 },
 remove: function(i) { this.datas.splice(i, 1); }
}

However, for some reason this doesn’t work reliably 100% of the time. So to correct the issue I used jQuery to create a and format a new object, before it was added to the parent object.

var method = {
 datas: {},
 add: function(obj) { 
  var i = this.datas.length; i++;
  var new_obj = $.extend(true, {}, obj);
  this.datas.splice(i, 0, new_obj);
 },
 remove: function(i) { this.datas.splice(i, 1); }
}

February 3, 2013
by admin

HTML Form Builder

Specification includes:

- Ability to store and retrieve all generated form data from a database
- An intuitive front-end form render
- Must have the ability to use special form elements eg. Date picker, WYSIWYG editor
- Allow for field validation and subsequent action should validation fail

Solution includes:

- MySQL database to store and retrieve data
- HTML front-end with a javascript powered editor

August 20, 2012
by admin

iOS4 – Maps, significant change location service

There are two methods for determining a users location in iOS4. The first is to use the ‘standard location service’ by calling the following:

- (void)startStandardUpdates
{
    // Create the location manager if this object does not
    // already have one.
    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;

    // Set a movement threshold for new events.
    locationManager.distanceFilter = 500;

    [locationManager startUpdatingLocation];
}

This method however should only really be used when you require very precise location updates from the device as it is very power intensive.

The second and preferred method for getting a users location would be to use the ‘significant update service’ using a method similar to the following:

- (void)startSignificantChangeUpdates
{
    // Create the location manager if this object does not
    // already have one.
    if (nil == locationManager)
        locationManager = [[CLLocationManager alloc] init];

    locationManager.delegate = self;
    [locationManager startMonitoringSignificantLocationChanges];
}

Reference taken from here

August 16, 2012
by admin

iOS4 – Static Classes

Found a very useful article relating to the use of static classes, here.

The idea being that you should store your data objects in a static class that can then be referenced from anywhere in the App

To call the class use the following:

SingletonClass* sharedSingleton = [SingletonClass sharedInstance];
[sharedSingleton callAMethod];

July 18, 2012
by admin

iOS 4 – Web View Outlet

To set the request url of a UIVwebView object use the following

NSString *website = @"http://www.russell-broadbent.co.uk";
NSURL *url = [NSURL URLWithString:website];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[{UIWebView} loadRequest:request];

July 18, 2012
by admin

iOS 4 – Pan Gesture Control

To add a Pan Gesture Controller to an object simply click and drag the Pan Gesture object from the library and drop it onto the object you would like to control (eg. UIImageView).
Next in your class header file add

-(IBAction){method_name}:(UIPanGestureRecognizer *){var_name};

Then in your implementation file add

-(IBAction){method_name}:(UIPanGestureRecognizer *){var_name}
{
    CGPoint translation = [{var_name} translationInView:self.view];
    {var_name}.view.center =
CGPointMake({var_name}.view.center.x + translation.x, {var_name}.view.center.y + translation.y);
    [{var_name} setTranslation:CGPointMake(0, 0) inView:self.view];

}

Once you have implemented the above code simple connect your View’s Received Actions to your Pan Gesture Controller

July 18, 2012
by admin

iOS 4 – Loading custom plist data

To load data from a plist file first declare an array in your header file

#import 

@interface MyTableViewController : UITableViewController
{
@private
	NSMutableArray *dataArray;
}

@end

Then in the implementation file under the viewDidLoad method

@synthesize dataArray;

- (void)viewDidLoad
{
	// load our data from a plist file inside our app bundle
	NSString *path = [[NSBundle mainBundle] pathForResource:@"tableData" ofType:@"plist"];
	self.dataArray = [NSMutableArray arrayWithContentsOfFile:path];
}

providing your data file is called tableData.plist and not forgetting to synthesize the array

When the view unloads be sure to set this array to nil as it may be rather large

- (void)viewDidUnload
{
	self.dataArray = nil;
}