Archive for the ‘The Internet’ Category

Solving NSURLConnection leaks

Monday, June 29th, 2009

Recently I was having a problem with NSURLConnection showing memory leaks in Instruments even though it was being correctly allocated and released. On investigation it seemed the problem may be lying with the cache policy, however I was using NSURLRequestReloadIgnoringLocalCacheData in the NSURLRequest to completely ignore any caching requirements and was confused as to why allocation problems would then be associated with caching.

I’m still not exactly sure what the problem is (according to this thread it may be due to having the NSURLConnection run in a method that’s detached from the main thread) however, forceably setting the capacity of the URL cache before initiating the connection using the URL request seems to solve the problem. For example:

[[NSURLCache sharedURLCache] setMemoryCapacity:0];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
 
NSURLConnection *connection =
	[[NSURLConnection alloc] initWithRequest:request delegate:self];

Hey presto! No more NSURLConnection leaks.

iPhone, Mac calendar collaboration with Google Calendar

Wednesday, November 26th, 2008

My boss came to me this morning with an interesting conundrum – could we come up with a push-compatible synced calendar solution for the company computers and mobile devices, as free as possible, without having to run an Exchange server. The stipulations were that it had to be push-compatible, dynamically synced and had to allow the continued usage of private calendars on mobile devices (namely the iPhone). There were many half-way solutions that involved subscriptions to private calendars and iTunes syncing, but we wanted something a bit more on-demand and universal.

Our first thought was to make use of the (in this case, rather lacking) capabilities of Leopard Server running on our office Xserve – this was, unfortunately, the first stumbling block; as Leopard Server’s CalDAV implementation in iCal Server lacked the ability to push any changes made down to our devices.

Several hours of research, dead-ends and spurious theories later we came up with the solution – iCal and iPhone calendar harmony, with a little help from Google and an excellent (and free) service called NuevaSync.

1. Backup

As always, back up your current calendars and settings – that includes your mobile device. Changing your current calendar setup will inevitably result in losing some data, especially on the iPhone where all current calendar data is lost when switching to a new one in the process outlined below.

2. Create your calendar

The first step is to create your shared, collaborative calendar. This is done with Google Calendar, namely as it’s the easiest calendar program to integrate into various client solutions (including the following ones), with the added benefit that you can guarantee yourself access on-the-go with Google’s own web applications. You must however be prepared to hand out the login credentials of the Google account used to create the calendar – as the following steps require that level of access. The easiest thing to do is to create a unique Google account specifically for your shared calendar.

3. Sync it with your computer

Google publishes private “feeds” from within Google Calendar that allow you to view the calendar if it’s not set to public (which would rarely be the case), but these are read-only and offer limited flexibility. For that we turned to Google Calaboration, which implements CalDAV to support real-time, dynamic calendar syncing. Google currently supports iCal v3+ (Leopard onwards) and Mozilla Sunbird, which was cross-platform enough for us.

iCal integration is as easy as selecting the calendars you wish to use

iCal integration is as easy as selecting the calendars you wish to use

Sunbird integration is simple as per the instructions, and iCal setup involved simply downloading an application from the above link, entering your Google account name and password (as mentioned above) and selecting the calendar to be synced – this creates a new calendar entry in iCal, that will dynamically sync with your Google calendar in real-time.

Our Google calendar now appears in iCal, fully editable

Our Google calendar now appears in iCal, fully editable

4. Add the calendar to NuevaSync

As mentioned before, NuevaSync is an incredibly handy (and more importantly, free) service that is crucial to creating the push-compatible calendar environment we need. This is because it takes your Google calendar and runs it through an Exchange server complete with ActiveSync capability, which will push any changes to your mobile device as long as it supports it (including the iPhone with software update 2.0 and above). Creating an account and adding your calendar with NuevaSync is easy, and well documented at their site. Once you’ve done this, you’re ready to add your calendar to your mobile device. In this example, we’ll use an iPhone.

5. Adding the calendar to your iPhone

As we mentioned before, NuevaSync makes use of Microsoft Exchange functionality, so we added a new Microsoft Exchange account to the iPhone by going to Settings -> Mail, Contacts, Calendars -> Add Account… This will give you a list of account types, and obviously “Microsoft Exchange” is the one we’re looking for.

You’ll then be presented with a list of options, the meaning of each in relation to your NuevaSync/Google Calendar accounts is documented on the NuevaSync site, but in brief Email is your Google accounts email address, Server (which may not appear until you’ve clicked the “Next” button after entering the other account information) is www.nuevasync.com, Username and Password are your NuevaSync details and Description can be anything you like.

Once you select “Next” you can turn off Email and Contacts and turn on Calendars for the new account, and you may be prompted to delete your existing calendar data if some exists on your iPhone. As you’ve already backed up your data anyway, you can safely accept this. Voilà, you should have a fully synced, push-compatible calendar on your iPhone tied to your Google Calendar account.

Thankfully, our iPhone can have a Christmas Day too.

Thankfully, our iPhone can have a Christmas Day too.

6. Private calendars, too

Our other stipulation was that we had to also support staff members’ private calendars (as their phones are necessary to organise all aspects of their life, not just work) without updating the shared collaboration calendar. Unfortunately, as far as we can tell, this is (currently) the only non-free area with regards to our setup. Once Exchange calendar syncing is turned on on the iPhone, it will no longer allow you to sync your calendars with iCal, and only one Exchange account can exist on the iPhone, barring any multiple NuevaSync/Google calendar options. Our solution to this was to use MobileMe, which it turns out was a fairly convenient solution – the iPhone allows Exchange and MobileMe accounts to coexist, and MobileMe will push any iCal calendars (excluding our Google one) to your iPhone and vice-versa. The Family Pack version of MobileMe appears to be the most cost effective solution – it supports 5 accounts, each with push calendar ability, working out at £17.80 per staff member.

So there you have it! iCal to iPhone shared, collaborative, push calendar ability with cross-platform support additionally with private calendars with some help from Google, NuevaSync and MobileMe. At least until OS X Server 10.6, anyway…

List of caveats:

  • It’s not completely free with regards to a Mac/iPhone setup, but it’s damn closer than with Microsoft Server and Exchange licensing thrown into the mix.
  • The calendar isn’t truly collaborative, as it’s effectively multiple users editing the same calendar. This means that any events are editable by anyone, and it’s hard to keep track of who added what. Thus it’s only really effective for smaller organisations.
  • There may be additional roadblocks with regards to other mobile platforms, including Android and Symbian. As we’re a company largely devoted to Apple’s hardware (at least amongst those requiring push calendar support) I’d appreciate any comments/feedback on other mobile platforms.

YouTube

Friday, October 20th, 2006

I’ve had several people ask me recently why on earth Google would want to buy YouTube, considering the fact that 1) they already have an online video service (Google Video) and 2) people keep going on about how YouTube is breaking copyright law, several hundred thousand times over. There were many specific questions, some pondering, some interesting and others lacking in point: who on earth would want to take on a company that is perceived to be in so much trouble with the major media conglomerates? Will Google change YouTube to the point that I can’t watch TV ads from 1997 anymore? How on earth do they make any money considering they don’t sell anything? How will this affect me, considering I spend most of my waking day searching through YouTube for videos of Borat? Let me quell your fears with some hearty breakfast facts!

YouTube makes money. Lots of it. Thousands per day. There’s adverts on YouTube – and along with Google’s philosphy, adverts = money. With so many users visiting the site on a daily basis, it’s not hard to see that they’re making a lot of money from people simply willing to look at the adverts. More importantly, YouTube is a market leader, and is therefore of great interest to venture capitalists, who like to affirm they’re faith in taking humungous risks with large sums of cash by plugging money into whatever catches people’s interest. Sequoia Capital has invested around $12 million in YouTube alone.

The more important point, however, is that of why Google would want to buy a company that is under such scrutiny from eager beavers waiting to pounce with any number of copyright lawsuits in hand. After all, once being snapped up by a company with literally billions in free capital, wouldn’t IP enforcement agencies and their lawyers not be even more eager to pursue what are for the most part largely legitimate cases against one giant rich offender? The point largely missed, even by big firm financial analysts, is this: that Google doesn’t necessarily have something, indeed anything, to gain by snapping up YouTube – it may in fact be a logistical headache – but that it has the most to lose by not taking the site under its umbrella.

YouTube is a fairly small company despite it’s market position. It has, by latest figures, 67 employees in the company – in comparison to this, Google has a figure approaching 10,000. The chances are the large part of these are IT professionals in one sense or another; project managers, web developers, hardware administrators etc. who organise and maintain the day to day running of the site. The chances are equally similar that although having legal advisors, they’re legal department doesn’t approach the kind of bait-requiring complexity that Google enjoys. In the face of several convincing IP lawsuits, and with it’s very obvious position of breaking IP law across the board, it’s unlikely that YouTube would have been able to hold its own and would have had to cave on several key positions. In this scenario, it would be Google that would have come off worst. Cases like this would have had a tendency to set precedent on several battlefields that Google itself is currently fighting on. It’s own video service, news and most importantly book search have come under intense criticism over the past year or so from those most readily defending copyright law in the US. It’s important that in these cases that others are fighting, the outcomes swing in Google’s favour, otherwise it would have found the going increasingly tough in getting it’s way in such situations. YouTube was in the unfortunate position of being the most vulnerable to these kind of attacks; having a site who’s infrigement is blindingly obvious, but being so weak in corporate terms so as not to be able to defend itself. Google’s acquisition was simply giving it the ability to allow its own legal team(s) to take care any such matters, rather than to affect the service and its millions of avid customers.

In the end, Google had very little choice – the $1.65 billion fee wasn’t so much for YouTube itself, but for the peace of mind that the major internet copyright battle was still left for Google to fight.

Under Surveillance

Sunday, May 14th, 2006

I went to Manchester to see Dave Matthews friday, having left the world to read my recent interview, and I’ve come back with some interesting web stats, as the following image shows:

Web stats by country

Some of the countries stand out as being rather out of the ordinary. Most of these are fairly explainable though – the chances are somebody in France is going to have the intelligence to use a computer. Even a DMB oriented member of the US military might find themselves perusing the internet, it’s not as if there’s anything going on in Iraq at the moment. But the sudden jump in the number of hits from the US Government is what disturbs me the most, especially considering they don’t appear on the stats at all before May. Perhaps there are some more liberal minds in the overly right-wing Senate and House of Representatives. Or, far more likely, Dave is part of some massive Republican conspiracy. Perhaps those indicted in the CIA leak case will turn out to be Rove, Libby and Matthews?

Either way, I seemed to have gained a new audience as a result of my foray into semi-professional journalism. Other interesting tidbits from my stats:

- “england football club” is my second highest search string click-through (after “nancies uk”)
- Britney Spears is featured in 5 of my top 20 search strings
- Thanks to my site URL being misquoted in the DMB Rhyme & Reason newsletter I was featured in (as nancies.uk) people have had to search for that URL in Google to find my site. With all the spying going on it’s probably not a bad thing, to be honest.

Dear Mr Blair

Tuesday, March 14th, 2006

I was musing with Josh this evening about the Computer Misuse Act and its apparent vagueness in 1) what contemplates actual misuse, and 2) the punishment one would receive in offending it. There are plans in the works to introduce a new bill which would update the current computer misuse specifics, especially in regards to network-based attacks, such as Denial of Service attacks and the production and promotion of tools which aid these (which is where a lot of vagueness on behalf of the government comes in again).

So this got me thinking – I couldn’t knowingly carry out a DoS attack on a specific target without incurring what appears to be some serious penalty (like several years in prison). So why not just apply the same logic to the new computer misuse act in the same way the government and legal system applies laws and penalties to non-tech situations?

For example; the law declares that it’s perfectly legal to protect yourself from assault using “necessary force” for “self-defence”. At the moment, if someone were to attempt to DoS me, and in retaliation and “self-defence” I quickly DoS’d them back, myself and the offending party would face prosecution under the computer misuse act. However, my attack was only in self-defence, in order to protect my(computer)self, so I think I should be immune to any prosecution.

And onto another example, the “pre-emptive strike”. The government seems to think this is a perfectly fair, reasonable and legal stance to take in the 21st century. After all, if I’ve got the name of a suspected spammer, and have the tools at my disposal to stop him before he has the chance to spam me, shouldn’t I be allowed to?

Coup d’Microsoft

Saturday, January 7th, 2006

I’ve previously mentioned that I’m a big geek so this post will come as no surprise either.

I stayed up tonight to review minute by minute updates of Larry Page’s keynote speech at the 2006 CES. For those of you who don’t know what that is, I’d stop reading, because its only going to lessen your respect for me (of what little you had anyway) if you carry on.

As it turns out, he announced some pretty neat things. He waxed lyrical about some power supply bollocks, which I presume was supposed to have some seminal meaning about the interconnectivty of mobile phones and USB. To be honest, this whole “everybody needs hundreds of devices for everything that can all connect and talk to each other in their home” idea has yet to convince me, considering I still tape things on VHS and stick CD’s in my stereo upstairs. But maybe America is different. Soon you’ll be able to download videos from Google that aren’t just teenage girls singing into hairbrushes and dancing along to the latest Kelly Clarkson tripe. But they’re going to cost you between $0.99 and $1.99, and it’s all CBS shows too unfortunately. But apparently you’ll be able to get hold of the original Star Trek, and seeing as how the Charlie Rose show is aired on CBS I might be able to get that incredible acoustic performance of “The Stone” Dave did a few year’s back. Plus, Letterman’s on CBS, and he loves Dave. So for now, Google = Dave = good.

According to Engadget.com, ‘General opinion around us is this is one of the best keynotes ever. Incredibily entertaining yet sincere. Jason says, “There was no spin. I still don’t know what Viiv is about, but I understood everything they showed today perfectly’. Don’t worry, I don’t know what Viiv is about either.