![]() |
| HDR of San Francisco with 3 RAW 14Mpx Exposures processed in Photomatix Pro (Unlicensed ^_^ ) |
The musing and sometimes not so wise words of Jonathan Dalrymple, Global Traveller, Programmer, Financial Rocket Scientist, Conspiracy Theorist, Part-time comedian, full-time funny man and whatever else i randomly decide to do.
Friday, July 15, 2011
Sunday, July 10, 2011
This is what 16k miles looks like
Monday, July 04, 2011
The Golden Gate
This was some what of a rambling post, but i just wanted to share some of these awesome pictures.
Tuesday, May 24, 2011
Core Data & Multi-Threading, part 1337
So if you need to refer to an object on multiple threads you need to use it's NSManagedObjectID. Thats all well and good, but what if you need to call [NSManagedObjectContext save:] multiple times. Well in short it's gonna suck. Well thats cool you say, i can just use the id anyway ... Not quite. There are two types of ID's, permanent and temporary.
Now in my experience Core Data seems to get confused when you use temporary ID's to look up objects on another NSManagedObjectContext. So really to stop these conflicts we need to get a permanent id, but we need to obtain one of these ID's without saving the NSManagedObjectContext.
Well are you ready for the magic ... Shazam
[NSManagedObjectContext obtainPermanentIDsForObjects: error:]
This awesome method will take an array of managed objects, and give them permanent ID's. From my brief tests the overhead is minimal compared to the traditional save method.
Thats all i've got for today, keep on trucking.
[]'s 4 life
Monday, May 09, 2011
Asynchronous Core Data searches with Blocks
I was recently fortunate enough to be able to drop iOS 3 support on a project. This meant that i could start to play around fully with Blocks on iOS. One thing that has always got on my nerves is that there is no built in support for asynchronous Core Data searches.
Previously i tried to wrap up potentially long operations in a special FRCoreDataOperation a subclass of NSOperation. However this was a pain, as i would then have to subclass it or modify the parent class to provide me with a simple callback when the task was complete.
What i really longed for was the way in which you make Ajax requests in jQuery, that of course requires closures, which are of course provided in the form of Blocks. So after hacking around for a bit i came up with this.
Now this is my first real time using blocks outside of simple things like iteration etc. It means that i can do
Now here's the part where i pat myself on the back. The callbacks are executed on the main thread, after the async fetch request is completed. Plus it gets better, The NSArray, for the onComplete block contains a list of the returned objects that are registered with the NSManagedObjectContext for the main thread, or in other words the NSManagedObjectContext you used to perform the fetch.
Once i touch down in the valley i plan to extend this to manage saves as well, making the basic CRUD operations with Core Data "scroll like butter".
Sunday, April 24, 2011
Roaming in jamaica
One flip side this country is a very different to the one I left. But for the most part different for the better.
Going to my grandparents house for the first time in 10 years has been fairly emotional. I'm still expecting to see them around house despite the fact the both have been dead for sometime.
I've compared it to a time machine, as it feels like I've just fast forwarded into the future. One without two people that I had come to know and love so well.
When I landed the lady at customs asked why I hadn't been back in so long (10 years), I'm slowly learning that it's because I knew subconsciously that it would be an emotional roller coaster.
Tuesday, April 12, 2011
Animating a series of images with CALayer
So you want a to animate a series of images, flip book style. While it is true you can use UIImageView, everyone knows that is for wimps. Real men (& ladies ;) ) use CALayer (like a boss)...
But how? Well you might have some how got in your head that CALayer's contents property supports a NSArray of CGImages. Well this is not the answer, remember that the contents property takes an 'id'as a argument so it supports virtually everything under the sun and then some. Hell, if you felt like making crazy things happen you could just throw a NSData object in there.
Anyways, the actual solution is to use a CAKeyFrameAnimation, to manage the rotation of your images, control the frame rate, and ultimately the duration.
Well all is said and done it should look at this
Sunday, April 10, 2011
Drawing text with a Gradient
Problem
You want to draw (unicode) text with filled with a gradient.
Solution
Since my middle name is now "Core Graphics", let me help you out. It's actually pretty simple. Create your desired gradient in a your image editor of choice, and save it as a PNG. Import it into your project and then ...
Yep folks thats it. Now if you find that your gradient is slightly out of place, you can use CGContextSetPatternPhase to help. You of course would use this before your drawing statement. The docs say:The pattern phase is a translation that Quartz applies prior to drawing a pattern in the context. The pattern phase is part of the graphics state of a context, and the default pattern phase is (0,0). Setting the pattern phase has the effect of temporarily changing the pattern matrix of any pattern you draw. For example, setting the context’s pattern phase to (2,3) has the effect of moving the start of pattern cell tiling to the point (2,3) in default user space.
So when all is said and done you get this lovely effect
Saturday, April 02, 2011
Problem: Symbolicate won't ... um symbolicate.
Thursday, March 31, 2011
Coming to America
Anyways the trip is split into 4 parts, over two months.
A. New York city
B. Jamaica
C. Los Angeles
D. WWDC in San Francisco.
Interestingly, I have no return ticket, not because I'm planning on becoming an illegal (please note TSA) but because I'm not sure if I'm coming back to the UK or if I will carry on heading west, and reunite myself with the Chinese people (they miss me you know).
The first leg is booked for April 18th, so as song says I'll be "new York da da da dada da new York" HOV ...
While WWDC should be a blast the most emotional part will be going back to Jamaica almost 10 years to the date that I left.
Bon voyage
Tuesday, March 15, 2011
Jonathan @ 24
....
Yeah so that's it, fascinating don't you think. But seriously my 23rd year was a good year, and I'll strive to make my 24 th even better, with the usual smattering of travel adventures, odd situations and hard core forking.
Thursday, February 10, 2011
Creating Push Notification certificates that you can use .cert -> .pem
To further aid this, threw together a little shell script that takes two arguements, the certificate.p12 file and the private key.p12 file and creates a apns_certificate.pem file. Saves a bit of typing and also gives you a hard copy of the commands needed to create the certificates
Wednesday, February 09, 2011
From Russia With Code
Wednesday, January 19, 2011
Why does Darren Bent cost £18 Million?
It is slightly hard to do this as few things are actually official, but as Rafa says lets work with the facts (that are mostly rumours).
Darren Bent is rumoured to earn £50k a per week, and had 2 years left on his contract at sunderland.
That means that his contract excluding any bonuses or commercial rights is worth about £2.6 million a year or £5.2 million. I believe this should be his 'book value', and the value that would stated on Sunderlands accounts.
Next Darren's move to Sunderland from Tottenham cost £16 million, with a cash component of £10 and the additional £6 million to be paid in various (i assume) performance related bonuses. Now i would guess that a club like sunderland structured the majority of these payments to be done over a period of time, being that Bent only left a year and half ago, they probably haven't paid this total sum yet.
Lastly as reported, a cause in the deal with Tottenham, was that Sunderland had to pay them 10% of his next transfer fee, something they would also need to take into consideration when negotiating with Aston Villa.
So lets do some basic addition with the numbers above
£5.2m (contract)
£10m (purchase price from spurs)
£15.2m
Now lets say that Sunderland have a policy of trying to maintain a profit margin of around 10% margin on player sales, that puts us in a range of £16.72 million.
Now we are missing one thing, Spurs cut. Thats 10% right?
10% of 16.72 million is £1.72 million
Which i assume sunderland passes on to Villa, so we get £18.39 million. If if they can't legally do this £16.72 still isn't far off the headline £18 million figure that we see in the press.
In fact depending on how much sunderland and already paid tottenham in bonus related payments, they might not have even made a profit. Also i dont know if Darren's 50k p/w wage is before or after tax, because if it is after tax, the value of his contract to the club is effectively doubled. due to the 50% tax rate.
Not accurate, not throughly researched, but certainly interesting.
Next, how the hell did they work out 'CR7' was worth north of £70million?
If you got any insight for me please share either on twitter @veritech or in the comments.
Friday, January 14, 2011
Tuesday, January 04, 2011
NSNotificationQueue, Coalescing and SIGABRT
I've come to love many cocoa API's over the last year. One i've been late to embrace is NSNotificationQueue. What can i say that hasn't already been made clear ... it's a queue for notification objects ... well almost it has one particular feature that makes it totally awesome, Coalescing.
Coalescing is useful for when you want to call a method multiple times but only have it execute it's action once every so often. Since i've started coding for iOS i've been a fan of simply calling [UITableView reloadData] to refresh my table views, it's simple concise and i don't have to worry about index paths etc. However if you are drawing complex cells, and you need to call this method while you process some data you really don't want to happen every single time, the user isn't playing COD, they just want to see their data, and not have it flick around. So in my UITableViewDataSource classes i do this ...
With the handler to the reloadNotification calling the actual reload method. This means that in one area of my app, where i am listening for NSManagedObjectContextObjectsDidChangeNotification (gotta love cocoa conciseness )the reload method gets called just once instead of 10+ times.
Awesome right ....
Well there is a problem, you might have noticed that enqueueNotification: takes a postingStyle. This calculates when in the duration of the run loop the queue will attempt to deliver your notification. Because i want my Run loop to be a free spirit and not care about what my crazy background threads were doing i would usually choose NSPostWhenIdle. Well i did till today.
The problem is the UITableView that this data source is assigned to can be dealloc'd at anytime, and while my dataSource is a good cocoa citizen and removes it's self as an observer before it is dealloc'd the notification has already been assigned it's target and is waiting till the run loop is idle ... read waiting till after my object has been dealloc'd. This of course means the the objective-c runtime attempts to call the reload method on dealloc'd object, and we all know what happens when that happens ... Well i thought i did. I code with NSZombieEnabled on, so in such a situation i expect to see a nice friendly message saying i've sent a message to an invalid object ... I got that message ... sometimes. Instead 9/10 times i got a big, fat, bold SIGABRT.
Oh, but you have stack traces ... um no. When crap happens in the objective-c runtime, you close your eyes and pray that they will go away, well thats what i do.
Anyways the solution was to ensure that notification was dispatched as quickly as possible, so NSPostNow was a much better fit. My professional($_$) opinion is that unless you have a long running object (ie the app delegate) or a singleton, never use the NSPostWhenIdle.
Conclusion
NSPostNow > NSPostWhenIdle
(9 out of 10 times)
Friday, December 31, 2010
2010: My Highlights
Float-Right (aka my career)
I've been self employed for entire year! Thats right folks a whole year. In that time Float-Right has really grown. While i'm not quite groupon, and i haven't bought that Aston Martin Rapide yet, i'm happy with what i've been able to achieve in that time. I've had some help mind you, not only in the form of my Mum, who has kept me snug with regular cups of tea, but also my small but loyal twitter following who make up for the lack of work colleagues.
2011 should see Float-Right do more work internationally, not only in terms of client base, but also in terms of where i will physically be located (thats right, i'm going back to Espana!). Also i hope to finally meetup with the rest of the iOS/Mac dev community at WWDC this year. As a result please send me work! Flights to San Francisco, hotel stays, and WWDC tickets are not cheap. Even my budget travel ethos doesn't cover me on this one.
Travel
In 2009 i travelled to China, Hong Kong, Barcelona,Spain & Paris,France. I thought that was fairly amazing. Well i think it's fair to say i've had another good year, visiting Amsterdam( Netherlands), Barcelona(Spain), Sevilla(Spain), Tel Aviv & Jerusalem (Israel).
Despite now being essentially banned from a number of nations thanks to my visit to Israel, my list for 2011 is even bigger. Argentina, Australia, USA, Switzerland, Norway and of course my new home (in the sun), Sevilla.
Moments
Have had a lot of interesting moments and times this year, but here are some of my highlights.
* Encouraging Ezra (@ezrabutler) to take a boat trip in international waters for his birthday ... this was about 1 month before the infamous flotilla incident
* Meeting Joaquin. Not that it was bad, it was just overwhelming.
* Hanging with Jason and his friends in Sevilla, he really helped make that experience amazing.
* My "lovely" trip to sunny barcelona, hint, it wasn't lovely, and it damn sure wasn't sunny.
* Being confused for a homeless person on the streets of Barcelona at 2am.
* Meeting Jonathan/Joe (@improvmonkey), full of interesting facts and views on life, the world, and the babylonians. I've never met a grown man that can party like that. I can't mention Joe without mentioning some other folks i met on that trip; @ahoova @llan_peer and @guy.
* Amsterdam with the lads, while people find this hard to believe i don't smoke, but that was hilarious. Especially the trip to the park on the last day. Shout out to @andrew_francis & @jai_morjaria. We gotta do that again.
* The sheer number of people that i met in Sevilla, too many to name them all (well i might have forgotten some of their names ... ). Strangely two of my favourites were both Aussies, Amy & Jardana.
* While i also met her in Sevilla, she deserves a bullet point all to herself, Serpil, aka El Professora, the woman that helped beat my spanish into shape, while also showing me what being truly multilingual looked like. She was also a really nice person!
* Buying stuff in a spanish shop in chinese. Absolutely hilarious.
* FOWA after party, that's always funny.
=======================================================
Anyone else noticing that all the good stuff happens overseas ... i'm just saying
=======================================================
* Geeky i know, but i finally purchased my first ever Macbook pro :)... which i put a rather large dent in three weeks later :(
* Living in a hostel(s) for two weeks. It was awesome at first but really started to get depressing towards the end.
* Finally having a piece of published software! Only took 22 years.
* Having a flight cancelled for the first time in my life.
* Watching the sunrise on beach in Tel aviv.
* The way people (who aren't from California) get excited when i tell them i make iPhone apps for a living, (putty in my hands i tell you...)
* My cafe con leche experience ... aka hot milk with a tea bag in it. Priceless.
* Completely stopping Web Development, i can't explain how great that is.
* Meeting the Girls as @andrew_francis and i call them, hilarious night. Good people.
* Saying the Stweetfight app would only take a couple of hours (thanks @samwilliamh)
* Doing a standup like performance for a roof terrace full of germans.
Well that made me smile, if no one else. So lets give away some awards.
My most hilarious moment of 2010 ...
Watching Nykia drop off a chair. Being 2010 it's on video of course
My most depressing moment of 2010
Letting go one of my early clients.
My happiest moment of 2010 ...
I can't pinpoint a single moment, but as the above shows all the time i spent outside of the UK were my happiest times. (i'm still game for the passport swap if you are)
My Saddest moment of 2010 ...
My grandmothers funeral, never have i shed that many tears in so little time
Goals for 2011
I have many, being the continuously improving sort of person i am, but here are a few.
* Go back to spain (por todos tiempo)
* Go back to China (on my to the DPRK perhaps ....)
* Build a Mac App
* Discover this work/life balance that people talk about
* Go somewhere i haven't been
* Improve my Spanish & Chinese, especially my ability to read the latter.
* Starting learning Arabic
* Pray a little/lot more, at this rate someone might confuse me for an atheist! I'm actually a christian shock horror!
To everyone, best wishes in 2011. Don't forget it's just like 2010, but your older this time ^_^
Thursday, December 16, 2010
Offscreen drawing on the iPhone using NSOperations, CGImage, CGLayer
The key thing to remember is that the drawing coordinates are inverted. This means that CGPoint(0.0f,0.0f) is actually the bottom left not the top left corner. I'm lead to believe this is a hold over from the Postscript drawing system that originated on the mac, and this is how the big boys do it. So stop whining and code.
Nicely it would appear that the UIImage representation methods automatically invert the image, so you only have to invert your coordinates for CGContext drawing calls.
Exactly How?
NOTE: This code will not work unless you have a image named sample.jpg in your bundle or change the assignment to the backgroundImg variable.
Friday, November 19, 2010
Ultimo Videos de Sevilla
Sunday, November 14, 2010
End of an era
It signals the end of Samuels surname. My grandparents only had girls, 3 of them to be exact. While my surname might be Dalrymple, I identify more with my maternal side of the family, and felt more in touch with that side of my family.
It was also that side of the family that was the first to come to England during the wind rush years, and is partly why I hold a British passport, and thus am able to live in Sevilla.
My grandparents did a lot for me, not only did they raise me but much of my personality and drive developed as a result of their influence. So I owe them a lot.



