Archive for the ‘Computers’ 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.

Leopard OS-wide umask support

Thursday, February 19th, 2009

Recently at work we noticed problems with files and directories on network shares (namely SSHFS via Macfusion) that weren’t set to group write even with -o umask=0002 in the extra options field of the SSH Advanced tab in the mount options. Viewing the FUSE mount via its system directory would show group write, however logging in with traditional command line SSH would show the files and directories not to have it.

The simpler solution therefore would be to set umask system-wide, for GUI and CLI in Leopard, so it would be applied to everything without worrying about individual configuration options on our SSH, NFS and Samba mounts. A quick Google search revealed a recent Apple Support article that offered a convenient solution – a file named launchd-user.conf stored in /etc that holds a single line with your umask requirements, e.g.:

umask 0002

I’ve created a package installer which you can download at the link below that installs the file for you if you’re not comfortable adding it yourself. You’ll also need to restart after you make these changes.

LeopardUmask.pkg

Caveats:

  • The Apple Support article notes that it is for setting a system-wide umask in 10.5.3, brief research indicates that you may require at least this version of Leopard for it to pick up the umask from the file.
  • As the file is located in /etc, it will set the umask for all users – a possible solution for individual user support would be to place a custom launchd-user.conf file in your home directory (~/launchd-user.conf), though I haven’t tested this.

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.

SCO

Monday, September 17th, 2007

You may know SCO (but probably won’t) as the company that tried to sue some of the major Linux vendors accusing them of copyright infringement based on it’s ownership of the UNIX source code copyright. It assumed that Linux contained UNIX source code, and that it owned the copyright for it – neither of which turned out to be true. It was p0wned in the courts (mostly thanks to the Novell case in which ownership of UNIX source code was found to be with Novell), hounded by Linux fanboi’s and eventually filed for Chapter 11 bankruptcy last week to the cheers of, well, pretty much everyone except SCO. Anyway, the point of all this is that there’s been some rather imaginative and amusing headlines on tech and IT news sites and blogs as a result, which I’d like to feature here:

Paul McNamara, Network World: “SCO files Chapter 11, threatens business as usual”

Egan Orion, The Inquirer: “SCO files Chapter 11 bankruptcy – Seeks court protection from its own lawsuits”

And my personal favourite,

John Paczkowski, All Things Digital: “Chapter 11, in Which SCO Finally Gets What It Deserves”

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?

My Life in Four Games

Wednesday, January 11th, 2006

A recent blog post by my good friend Josh caused me to break out in a fit of nostalgia not seen since I moaned about Christmas several weeks ago.

Games used to be really good. Don’t get me wrong, I enjoyed every second of Half-Life 2; it’s breaktakingly vast world, it’s surprisingly advanced graphics engine and a storyline that could floor a Hollywood screen writer, even a Jewish one. But it is all those things in combination that are required nowadays, along with a multi-million dollar budget (and an expensive graphics card).

Gone are the days when you could be just as suitably entertained by a wise-cracking, badly animated amateur pirate (although I hope to prove this wrong at pirate night in a couple of weeks time).

So, for your pleasure, here is a brief history of classic games (otherwise known as my social life from ages 9-14, and subsequently 15-17 and 19-21)…

1) Theme Park - The only game I’ve bought a new PC to run. Well, bought for me to run. I had a 386 with 2MB of graphics memory which unfortunately wasn’t enough to run the game (despite what the minimum system requirements said) so after buying me Theme Park for my birthday and me informing them it wouldn’t run, my parents also upgraded my PC to a 486 with an 8MB video card and a 256MB hard drive with a CD-ROM drive. Neat. It came on 6 floppies and took ages to install. Was it worth the wait? 100 gaming hours later and I’d say yes. Gone are the days when games still had obvious spelling mistakes…

2) The Secret of Monkey Island - It’s amazing how such a simple Disney ride has inspired endless creativity in multiple mediums. Written using the adventure game engine that produced a string of fantastic games, The Secret of Monkey Island showed you that clicking on stuff for hours really wasn’t that boring. Even the music was amazing. This was the third game in the “SCUMM” series, and instantly became a classic. It’s the most sought after game on the internet, though unfortunately still protected under ESA unlike other point-and-click classics such as Beneath a Steal Sky and Flight of the Amazon Queen which you can get for free. Joey was always a much better name for a robot than a sitcom character anyway. The good news is, if you’ve got a copy, processors are so powerful now that you can play it on your phone.

3) Simon the Sorcerer – I personally preferred this to Monkey Island, mostly due to the fact that I had the CD version which said everything and there was therefore no need to read any of the badly coloured subtitles, unless I was trying to secretly play it whilst my parents were in bed. It was, at the time, the funniest thing I’d ever seen in my life. It’s still up there, although having watched as much Simpsons and Scrubs as I have up until now it’s been pushed off the top spot. It’s more than worth getting hold of and playing if you haven’t though.

4) RollerCoaster Tycoon 1, 2 – Ah, full circle. Like life, and other things. I have an obsession with theme parks, specifically with rollercoasters, and the way in which they work. I remember seeing a tiny preview of RollerCoaster Tyccon in a copy of PC Zone some years ago, not long before it was due out. I crapped my pants, and so my obsession with RCT (as well) was born. I’ve spent at least twice as long playing this as whatever’s in 2nd place to it. I’ve designed more fantastic coasters than I’d ever care to admit. And yet, as true as this cycle of games itself, I find myself reinstalling RCT every few months, just so I don’t go completely insane. It’s still not occurred to me to ask Tussaud’s for a job, though.

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.