Tuesday, December 8, 2009

Gems in the Junk

I came across some somewhat useful stuff while clearing out the old files on my mac the other day. One thing that I really like is a quicklook plugin that I 'wrote' last year. I use it to preview binary files and files unknown to the OS (like with no extension). Anyways Ill put it here for anyone who wants it!

I am not responsible for any damage.
Batteries not included.

Monday, August 24, 2009

NSURLDownload defeated!

So I have been playing around recently with both NSURLDownload and NSURLConnection. NSURLConnection offers you much more control than NSURLDownload but at an expense; it throttles the CPU when multiple connections are made (And yes I have tested it, evening removing the delegate/custom behaviour to sample the bare bones of NSURLConnection vs NSURLDownload). I haven't found a good reason why this problem is there, in fact I thought this exact problem was supposed to be fixed with 10.6. Comparing Wget to NSURLConnection was not linear!! NSURLConnection CPU usage sometimes tripled on multiple downloads ( >1) where Wget stayed steady. In fact NSURLConnection's CPU usage was very sporadic. NSURLDownload kept itself pretty steady also, albeit slightly higher than Wget but thats to be expected. So I considered using CURLHandle and CocoaAsyncSocket but I really didn't want to have to write a lot of plumbing. So is there something I can do with NSURLDownload...

Well, NSURLDownload has its own limitations. Initially it looks promising, offering a clean interface for downloading/resuming url content. But this only works so far. Firstly you cannot set a particular point in a file to start writing to (if for example you implemented a custom resume technique). The output from class-dump did not show any way to get a handle to the file or a seek function of some sort :(

Now the second problem is that NSURLDownload's resume funcitonality depends on the presence of an ETag, used to ensure a resource's validity. You may have noticed that safari does not resume a download unless this is there. A lot of servers do not support this yet, instead offered a "Last-Modified" header value. So without this ETag, NSURLDownload does not offer any way to resume a download in its public interface, whereas in NSURLConnection you can do a partial-GET request (You can also do a partial-GET with NSURLDownload but it writes to a new file, again I had an implementation concatenating files but it was messy and meant quitting the application was slow).

Take a peek further into this class, again using class-dump, and there is a nice bit of functionality you can leverage. What I found was an internal function:

[NSURLDownload _initWithResumeInformation:(id) delegate:(id) path:(id)]

This seems like a good candidate for a dictionary of headers along with the usual params. I then ran a download using the iTunes download path from apple, cancelled it and read the resume info. There is an accompaning function for this

[NSURLDownload _resumeInformation]

This showed the following 4 NSDictionary key/value pairings:

NSURLDownloadBytesReceived = 4869281;

NSURLDownloadEntityTag = "\"e8e019-4d4bdb26-4a5ddsaffd28c1\"";

NSURLDownloadServerModificationDate = "Wed, 15 Jul 2009 00:54:25 GMT";

NSURLDownloadURL = "http://appldnld.apple.com.edgesuite.net/content.info.apple.com/iTunes8/061-6715.20090715.cfR54/iTunes8.2.1.dmg"


Using this, even without NSURLDownloadEntityTag works with servers that do not present an ETag. This leads me to believe that, when the ETag is not present, the download sets its resumeData to nil upon cancelling the download.


So now I can resume an NSURLDownload the way I want!!

Anyway I hope this helps someone else in a similar position!


Vector out!

Friday, June 26, 2009

帰ってきた

Back from Japan, so I thought i'd do a quick post just to share some of the photos with whoever wants to see them!

These are some photos from a few different places I went. Most were taken at the start of the journey but as time went on I became less and less motivated to take!
Good fun though! Id recommend anyone to go to Japan especially Kyoto, it was definitely one my favourite places!

For those of you who know me, you will know that I have the worst memory and find it hard to recall information on cue! That is why I kept a diary of this trip! Once I go back and read it I might blog about some of the adventures I had!


Friday, April 24, 2009

終わりがドキドキー

Hello me. 

Fourth year. (almost ) over, exams to come.
Projects. Done.

Cannot wait to finish college! And I never thought I would utter those words! 
Really, its kind of a relief to be finished. I'm not sure is whether this is due to the amount of work that was placed upon us or what but I have become pretty sick of the place. Though I will miss some elements, like good lectures ( though few and far between )  and friends - it is inevitable that contact will be lost, no point sugar coating it! Its interesting to think of the directions people will go, I'm not sure if many will enter the industry, from the chats I've had few have aspirations to do so. I'm not even sure if I will, right now I have many different interests in the IT sector, mainly graphics and software development, and could definitely see myself returning to college within a few years to post grad study.

Started watching Galileo recently as a possible replacement for GTO. Its not bad, has some of the same humour and general underlying theme (Hero of the people sort of thing). Here is a link on hosted on the omnipotent ~YouTube~



BTW: What do people want to do the day we actually finish? Dinner? Pub? Other??

Saturday, April 11, 2009

(sigh)

Introductions are such a pain. The report introduction that is ;)
Today was gonna be the day I finish this report but have not got past the starting line. Distracting myself installing OpenSUSE, watching lost, listening to Portishead, going to the beach and now with this...

Thursday, April 9, 2009

FYP

Submitted my software on monday and i'm relieved to not have to do it anymore, though it was fun. I had plans on finishing my report this week but cannot find any real tempo. At the moment I'm at 10487 words on 60 pages. However ( I am sooo sick of writing that word! ) there is a good few pages dedicated to pictures. I still have to write about LOD, lighting, camera, all those other things in my application that did not form part of the research! Sounds like a complete mine-field. Oh and the conclusion,Intro and future swork. Also I have most of my research papers either on my fried laptop or my Mac in college so its kinda annoying.
What I did do this week was convert my report to tex format so the maths now looks much better!

I packaged my software for use on Mac OS X leopard only. I was going to compile a version for windows but would be way too much effort with OpenGL. As far as I am aware the current OpenGL implementation for windows is 1.1 ( Its crazy! ! ) is it true?? That would mean i would have to specify extension points for a lot of my code! No way!
Anyways i put a link to the package here, it installs GLUT, GLUI, FreeImage libraries! So you might want to keep that in mind...
Also I have only tested this quickly on one other machine so I am unsure of its reliability!

Thursday, March 26, 2009

Why Japan? Why Japanese?

I cannot remember the amount of times I have been asked "why did you start Japanese?" or "why Japan?", and I find myself unable to answer. I started back at the start of second year (has it been 2 1/2 years already:!) and have been studying it slowly since then. Unfortunately I cannot afford it the time it deserves, especially these days with the quantity of work part that comes with a final year in college. It is real pity because everyday i forget more and more :( I have the worst memory ): .
So why Japanese? Is it the people? The culture? Escapism? The language? 女の子?
Yes it is these but there is something else about Japan that I cannot put my finger on. In fact I can't even explain it. Everytime I speak Japanese or do some Japan related activity I feel great! I'm not sure why or where it comes from. I wish I had a coherent answer for "why Japanese/Japan" and it actually really bugs me that I cannot explain why. I'm sure it encompasses lots of things but there must have been something that spurred me to feel this way.
Obviously Japan is not perfect, its got its flaws like every other nation, and there are things I do not agree with, e.g whaling, death penalty process (jury is still out on the death penalty itself, excuse the pun). But most of its culture is simply fantastic. The sense of loyalty amongst the population is remarkable, and the spirit of historic japan seems to be still evident nowadays.

There was the notion amongst samurai of being loyal to a master until death. Even if a samurai was disgraced in some way he would most likely commit the act of seppuku(切腹)which is death by disembowelment. The last known act of this was as recent as 1970! In modern Japan obviuosly people don't do this! However there is still the nature where once a Japanese person starts work at a company then that person will stay working there as long as possible and be completely loyal the company. I remember talking to some Japanese friends and they kept quoting things they had to do, calling it their "duty". I was shocked. A duty to whom? To a company, to Japan. It seems crazy and a bit like a totalitarain society but its these thoughts that help keep Japan so intimate and almost impermeable to foreign influence. Look at Ireland, what do you think epitomises Irish culture? When I am asked this question I cannot think of a suitable answer and just keep thinking of a pub with pints of Guinness splashing about. Don't get me wrong this can be great fun but its inherent to have a social scene as part of a culture. Ireland has lost its spirit in my opinion and been replaced by spoilt kids with too much free money. Actually I am not going to get into the problems with Ireland here, it would take too long.
So why Japan, the divine wind, the land of the rising sun ? Why Japanese? Can you tell me?