Recent Films

Welcome to the Jungle

Mid-Afternoon Sessions

Will4Point9

EKS Aberdovey Visit
Recent Photos
www.flickr.com
This is a Flickr badge showing public photos and videos from ctr. Make your own badge here.

Friday, July 30, 2010

GameKit, iPad and iPhone

Filed under: Coding, iPhone — Chris Ross @ 8:33 pm

To get an iPad and an iPhone talking to each other you will need to implement the optional delegate method:

- (GKSession *)peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type {
return [[[GKSession alloc] initWithSessionID:@"ApplicationSessionID" displayName:[NSString stringWithFormat:@"iPad - %@", [[UIDevice currentDevice] name]] sessionMode:GKSessionModePeer] autorelease];
}

Otherwise they will not find each other as they are different application. Hope this helps, had me scratching my head for a while.

Friday, April 9, 2010

Wind Groupie

Filed under: Coding, Kiting — Chris Ross @ 8:46 pm

A while ago we had a planned to spend all our time kiting in Wales for a while. However, the weather conspired to stop that and we have only had one day. We did however spend upwards of an hour trying to work out what to do. Do we come back home? Do we stay and risk it not blowing and miss out on other fun things? Not one piece of software or website could concisely answer that question. It involved looking at different sites for predictions, live weather and tide states. Life shouldn’t be that hard.

So I wrote Wind Groupie.

It is now in a state where I can show off one part of it – the iPhone application. I am planning on iPad and desktop versions of the system to make it really easy to track weather with ease.

Now to check out Wind Groupie.

Wind Groupie First Screen

When you start the application you are presented with a list of known locations. They are sorted in a very specific order: rating then name. Each row has a direction arrow that details the currently known wind direction and a colour code that indicates the strength. In the above shot you can see that Greatstone has a rating of two ticks and
a label stating when the next favourable conditions are. Already we are one up – we can see that only one spot has good conditions for kiting coming up – we need not waste time looking at other spots unless we want to.

Current Conditions

Tapping on a location will take you through its detail view. You get a map of the location, a nice friendly arrow showing you the direction of the current wind state. This is exceedingly useful, no point knowing the wind direction if you can’t see how that relates to a spot. If you tap the arrow, you get the chance to open the location in Maps.

Go to location

This view also provides a number of details: current wind direction and strength, the nearest tide change for the location with its time and height, whether or not you are likely to see rain, air temperature and finally sun rise and sunset. If you tap on the wind details you are taken through to the wind detail view:

Wind Data

You are presented with recommended sessions, wind history and the list of weather forecasts the application has access to. At the point part of the magic comes out to play. The recommended and ratings on other sites are very much related to the wind speed. Wind Groupie takes it to the next level. Ratings are based upon:

  • Wind direction in relation to the operating range of the beach and the ideal wind direction.
  • The strength of the wind and how close it is to 25 knots.
  • The tide conditions – how close the time slot is to the ideal tide state for the location.
  • The light conditions – when it is between sunrise and sunset.

It combines all this information into a rating, scans the forecasts and reports back what it finds. Tapping on a recommended session or forecast will pop up a graph so you can see the forecast and how it is due to change over the duration of the forecast:

GFS Wind Data

WRF 9K

Forecast With Recommended Slot Highlighted

This all leads to a very swift and pleasant data discovery when it comes to the wind and kite based activities.

Much nicer than any other application.

So what is next? Got some more data display to be done for tidal information, automatic updating, notifications, improved network error handling and lots of testing. At the moment it is very much a personal project to play with ideas and some data whilst refining my iPhone OS programming skills.

That being said, let me know what you think!

Monday, January 4, 2010

New Years Resolutions

Filed under: Coding, Kiting, Mountain Biking — Chris Ross @ 8:50 am

I can haz none?

I’ve no intention of having resolutions so to speak. I’m already fairly fit and healthy, I eat well – both healthy and tasty – so the regular ones are already covered.

Instead I have more of what I’d call goals:

I.) Ride the 100 mile South Downs Way Randonee mountain bike ride in June. Going to be savage but a good target to aim for, what I’d say is the mountain biking equivalent of a marathon.

2.) Finally land a Flat3. Last summer I finally got to unhooking, in Rodrigues I played at static handle passes, this year I shall land a Flat3. (There are other tricks I want to improve, try and have fun doing but a Flat3 is the main aim)

3.) Learn OpenGL ES to the point of being able to publish a small Open GL based game to the iPhone app store.

There is a goal for each area of hobby interest: kiting, biking and programming.

Lets see how things go.

Monday, June 15, 2009

Whilst I wait…

Filed under: Coding, Kiting, Mountain Biking — Chris Ross @ 10:01 am

… for a database dump to complete downloading, I thought I’d write a cheeky post covering the last few days.

Last week was excellent. Two customers migrated cleanly and working nicely. My new kite showed up and I even got to fly it on Thursday. Had a great session and found the kite to be as nice as I’d hoped it would feel when I finally got my own. The loops are clean, jumping feels great and it can be trimmed in a treat giving it massive range. It even looks sick:

JN PrimaDonna3 9m

My own bar and lines should be arriving this week which will be excellent. The demo kite I borrowed from JN UK is leaving this week so I can’t steal that bar and lines to fly it! Today, Wednesday and Thursday looks windy so I can’t wait to get back out.

I also got my bike back on Friday. I upgraded the wheels from the off-the-shelf Alexrims+Stub hubs to Mavic EN521 rims, black DT Swiss spokes, black DT Swiss brass nipples and Hope ProII hubs front and rear.

Mavic EN521 rims with DT Swiss Comp spokes and Black brass nipples

Hope ProII hub front and rear

What is the advantage? I was told I’d not feel much difference but the wheels would be stronger and a bit more solid. I’d disagree, the difference is staggering. Out on the ride at the weekend I was tearing down the hills with more control and finesse than ever before. They are much more solid which in turn gives a much more intimate feeling with the bike and the surface it is rolling over. I was throwing the bike round much more than I have previously done, it responded and there was not a trace of any change in the wheel state (unlike my previous wheels that had started to warp).

I also upgraded my front rotor to 185mm – it bites so much harder than the smaller 160.

The ride on Saturday was also excellent. I did the massive bomb hole/drop off at the end of OTF which I’d promised I’d do next time I was there (previously I had chickened out, it was like riding out our first floor flat window down an almost vertical slope until it curved out at the bottom). I nailed it. I also did some drop offs to get some air. They were similar to part of the Judges seat at Pitch which I am determined to do. Apart from those spikes of adenaline, the ride was friendly, chatty and a good social ending in some great cake and banter at Parklife.

Sunday was an odd day. No wind. No riding. No work. I was tired and generally did not a lot!

I hope you had a great weekend, tonight I’m going to go for a fly and then work on a website for my sister.

Monday, June 8, 2009

Whilst I am blogging.

Filed under: Coding, iPhone — Chris Ross @ 9:55 am

I made a few more tweaks and changes to the demo browser for the iPhoneFerite engine. It now does “fake” bookmarks and expands on nib file usage. The UI has been tweaked and a bookmarks button added. The button, when clicked, will slide up a modal view controller to show the bookmarks. Tapping on a bookmark will load it.

Loaded darkrock.co.uk from a bookmark

"fake" bookmarks

To show the user interface being built in Interface Builder:

Interface Builder Designs for the Browser

The next demo is a basic RSS feed reader.

Sunday, June 7, 2009

A Better Browser

Filed under: Coding, iPhone — Chris Ross @ 9:52 am

I’ve managed to put in place the code to allow nib files to be loaded – thanks to some excellent documentation from Apple on what happens. As such, I’ve managed to not only reduce the code required to write a web browser in iPhoneFerite, but also provided some extra functionality at no extra cost.

Firstly the code:

class NibTestOwner extends UI.NibFileOwner {
   object webview;
   object textfield;
   object button;
   object view;
   object activity;

   function buttonClicked_( object sender ) {
      .activity.startAnimating();
      .textfield.resignFirstResponder();
      .webview.loadRequest(
         NSURLRequest.requestWithURL(
            NSURL.URLWithString('http://' +
               .textfield.text())));
   }
   function webViewDidFinishLoad_( object sender ) {
      .activity.stopAnimating();
   }
   function textFieldShouldReturn_( object sender ) {
      .buttonClicked_(sender);
      return false;
   }
}

object app = UIApplication.sharedApplication.delegate;
object owner = new NibTestOwner();

if( NSBundle.mainBundle.loadNibNamed_owner_options_("NibTest", owner, null) ) {
   owner.view.setFrame(app.canvas.frame());
   app.canvas.addSubview(owner.view);
   app.tabBarController.setSelectedIndex(0);
   owner.textfield.becomeFirstResponder();
}

The advantage of this approach is that it is a) quicker, cleaner and faster, b) the way you do it if you were using the Objective-C SDK and c) allows you to get pixel perfect control layout and configuration:

Interface Builder constructed UI

The next set of challenges involve the ability to inherit Objective-C classes and override existing methods. I think I will have to write some code that automatically builds Objective-C classes from the functions declared within a ferite class. I’ll provide some updates at the next junction.

Saturday, June 6, 2009

Hacking time

Filed under: Coding — Chris Ross @ 9:15 pm

I’ve been hacking on porting ferite to the iPhone. This is mainly to see “if I can”. It has involved creating an application that compiles in ferite, the modules and some objective-c bridge code I wrote about 6 years ago. It seems to work fairly well. So well in-fact that I wrote a web browser in ferite. Only a simple one, but it works. I am going to take you through a set of screen shots and then show you the code. I will attempt to update my progress here as new and exciting things occur.

When you load ferite on the iPhone, you get this very nice splash screen:

Spash Screen

You are then presented with the application. It is two parts, a blank UIView canvas and an edit view. By default the application loads the demo.fe in the application’s scripts directory. At the moment that is the web browser demo. It is important to note that the canvas is on the play tab.

The empty canvas

When clicking on the edit tab, there you get an UITextView to edit ferite code to run. Clicking run executes the ferite code and if you are lucky it’ll do something. The browser code shows an alert once the browser has been setup.

An alert welcoming to the browser

Clicking ok will snap you back to the play tab where you can now see an text field, a load button and still some white canvas. The textfield grabs first responder status and allows you to enter a URL. The keyboard has been setup to make it URL compatible.

Entering URL

Tapping “return” or “Load” will cause the page to be loaded. In this case it is apple.com.

Page Loaded

I wasn’t quick enough first time round so I decided to load my home page to show the activity indicator added to the canvas and shown when the web view is loading.

Loading - Showing Activity Indicator

And even this site renders nicely in the browser:

My Homepage Loaded

This is only a basic script and the UI kit version of ‘hello world’, what is important to note though is that 80-90% of the technical hurdles in writing any application have been overcome in getting the technology in place to do this demo. Exciting times. I’ve no idea what the long term goals are of this little technical playing but it is quite fun and I get quite a kick out the notion I can write code on my phone and have it run.

For those interested, the code to run this demo looks like this:

class Delegate {
  object web_view;
  object web_activity;
  object web_url;

  constructor( object view, object progress, object url ) {
    .web_view = view;
    .web_activity = progress;
    .web_url = url;
  }
  function loadButtonClicked_( object sender ) {
    .web_activity.startAnimating();
    .web_view.setDelegate(self);
    .web_url.resignFirstResponder();
    .web_view.loadRequest(
      NSURLRequest.requestWithURL(
        NSURL.URLWithString('http://' + .web_url.text())));
  }
  function webViewDidFinishLoad_( object sender ) {
    .web_activity.stopAnimating();
  }

  function textFieldShouldReturn_( object sender ) {
    .loadButtonClicked_(sender);
    return false;
  }
}

object canvas = UIApplication.sharedApplication.delegate.canvas;
object web_view = UIWebView.alloc().initWithFrame(CGRectMake(0, 42, 320, 369));
object button = UIButton.buttonWithType(UIButtonTypeRoundedRect);
object progress = UIActivityIndicatorView.alloc();
object textfield = UITextField.alloc().initWithFrame(CGRectMake(5, 5, 230, 31));
object delegate = new Delegate(web_view, progress, textfield);

UI.prompt('Welcome, this script creates a demo browser on the canvas');

canvas.setBackgroundColor(UIColor.blackColor);

web_view.setScalesPageToFit(1);

textfield.setBorderStyle(UITextBorderStyleRoundedRect);
textfield.setPlaceholder('Enter URL...');
textfield.setAutocapitalizationType(UITextAutocapitalizationTypeNone);
textfield.setAutocorrectionType(UITextAutocorrectionTypeNo);
textfield.setKeyboardType(UIKeyboardTypeURL);
textfield.setFont(UIFont.fontWithName_size("Helvetica", 17.0));
textfield.setContentVerticalAlignment(0);
textfield.setDelegate(delegate);

progress = progress.initWithActivityIndicatorStyle(UIActivityIndicatorViewStyleGray);
progress.setFrame(CGRectMake(210, 10, 20, 20));

button.setFrame(CGRectMake(240, 7, 72, 25));
button.setTitle_forState_('Load', UIControlStateNormal);
button.addTarget_action_forControlEvents_(delegate, 'clicked:', (1 <<  6));

canvas.addSubview(web_view);
canvas.addSubview(textfield);
canvas.addSubview(progress);
canvas.addSubview(button);

UIApplication.sharedApplication.delegate.tabBarController.setSelectedIndex(0);
textfield.becomeFirstResponder();

Anyway, I hope this post provides an alternative to the twitter feeds.

Saturday, May 2, 2009

Internet Explorer window.event undefined

Filed under: Coding, Website — Chris Ross @ 10:27 am

I recently ran into a problem where window.event was undefined.

The issue was a global variable called ‘event’ declared in an imported Javascript file. Renaming the variable caused the problem to evaporate.

This is being put here incase someone else runs into the same problem.

IE7, Internet Explorer, window.event, event, undefined, onclick.

Thursday, January 22, 2009

Brazil; Laptop; Wedding; Weight

Filed under: Coding, Health, Life — Chris Ross @ 2:58 pm

Brazil was excellent.

Laptop is now back up to speed with a 320Gb disk in it. I have TimeMachine doing backups of both my machines.

Wedding ring has arrived, fits and looks sick.

I’m also trying to lose weight. Before Holiday: 15st3, After Holiday: 14st8, Now: 14st4.

Thursday, August 7, 2008

Tweaking TextMate

Filed under: Coding — Chris Ross @ 8:04 am

This is what TextMate looked like before:

This is what TextMate looks like now:

I tweaked out TextMate using a visual mod that changed some of the resources it uses to make the folding of blocks more obvious, the tabs to be nicer and the tab bar change colour. This make those features easier to use which is really nice. I also installed ProjectPlus which provides various features such as colouring based upon the labels in Finder and SVN status flags. If it provided CVS status flags, it’d be bloody perfect.

UPDATE I did this by using ProjectPlus and sublteGradient Leopard. Sorry for not putting this in the original post.