Sunday, January 29, 2012

Grand central dispatch plus blocks = bliss

I've been doing some iOS programming recently and needed to load a UITableView with images from a web site.

You don't want to load images synchronously as the view scrolls or it kills the user interface response so that needs to be done in another thread. There is some nice code around to do that but after watching the Stanford lecture on the topic I'm totally turned on to the GCD block pattern where a lump of code is written in line but gets run in another thread.

Here's a snippet from my - (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath

// Load the image with an async block executed in another thread
dispatch_queue_t downloadQueue = dispatch_queue_create("image downloader", NULL);
dispatch_async(downloadQueue, ^{
 NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageUrl]];
 UIImage *image = [UIImage imageWithData:imageData];
 // this has to be back on the main thread
 dispatch_async(dispatch_get_main_queue(), ^{
  cell.imageView.image = image;
 });
});
dispatch_release(downloadQueue);

The effect is that you scroll the table view and the images load later. The code looks pretty ugly (to my eye) but it's much simpler than any alternative and great to have it right there in line rather than off in another mystery object.

Wednesday, January 25, 2012

Six point plan to halt movie piracy

Bouncing off the Megauploads story, I had an opportunity to reflect on RNBreakfast on why there is a widespread problem with people obtaining illegal copies of (in particular) movies.

I think the problem stems from the big studios failing to keep pace with the technology habits of the general public, this has turned Mr and Mrs Average  into a pirate, not because they want to be, but because they can't get what they want.

Here's what I think studios should do to give people what they want and start receiving the money which is currently flowing to Megauploads and friends:

  • Make new content available everywhere in the world at the same time.
  • It should be easy to purchase, without needing to join an ongoing service.
  • The price should be fair so that risky pirate alternatives don't seem worth the effort.
  • Price should slide according to quality - phone size to 4k TV video, extra for 3D, extra for multi-channel sound, extra for extra features.
  • DRM should be permissive and allow a user to move the purchase around their devices.
  • Upgrades should be available - if I rent the phone version I should be able to upgrade to HD later.
Finally, all of the fights over territory and fragmentation of titles across stores should just be solved. I should be able to rent any movie, or TV show, or music, or book, or whatever that has ever been made on any of my devices.

Audio from this morning here.

Tuesday, January 24, 2012

Coffs Harbour Radio Expo, a bit smaller this year

For many years we've headed north to Coffs Harbour at this time of year for the radio expo. Alas, this year it wasn't on - but we decided to go anyway.


It's a lovely place, we often discuss the idea of moving there to escape Sydney. There was a confluence of radio though as I'd just sold an IC-718 on eBay and the buyer was Scott, VK2AET, who lives not far north so we met up and had our own little radio expo in a cafe.


Scott's a great guy and recently lost a lot of gear in a lightning strike to his house - hence the interest in the Icom radio. We had a very interesting chat and I hope to catch up on air in the near future.


Despite the deteriorating weather, we had a great time including a chance to view the film Hugo which I highly recommend, particularly to film buffs.

Wednesday, January 11, 2012

Ericsson phone catalog

Rob, VK2ZNZ, showed me a marvellous catalog of old Ericsson telephone handsets. These are drawings but many look photo-realistic and show great skill by the artists.

Ericsson Type AC 110 "Magneto table telephone"

Ericsson Type AC 210 "Magneto table telephone"

Ericsson Type AB 140-145 "Magneto wall telephone"

Ericsson Type AC 130-140 "Magneto table telephones"

Ericsson Type AC 1000 "Extension table telephone without generator or bell"

Ericsson Type BC 1300-1301

Ericsson Type BC 2050 "Battery ringing table telephone"

Ericsson Type CL 510

Ericsson Type AC 100

Rob has some of these phones and you can truly say they were built to last. I called him on skype and he answered on a magneto table telephone.

Kodak Zi8 pocket HD video camera to watch out for

Dave, VK3ASE, tipped me off to this one. There's a, now obsolete, video camera from Kodak (soon to be obsolete too), called the Zi8. It has two things I look for - high quality video and an audio input port. Here's some test footage, but I recommend you go to YouTube and switch to HD to watch it here.


Highlights are burnt out and it really needs a tripod to get good quality. It's much better than my existing Canon video camera and very compact.

Here is an example of the 15cm close up mode:



Incidentally, I'm selling this IC718 on ebay at the moment.

I paid a little over $80 for the Zi8, they're a bit hard to find but they are out there.

Here's a picture from Kodak's site.


Native recording format is .MOV containing H.264 video with AAC Audio so it's perfect for my uses and uploading to YouTube.

Sunday, January 08, 2012

Charming sketches from travelling friend

Old friend Jennifer Lewis has just returned to Australia after working in London and Indonesia. She's been doodling in a sketchbook too good effect.


Check out her blog with scans of her sketches as she's not getting much traffic so far. Great stuff!

Friday, January 06, 2012

SyPy in the pub with Malcolm Tredinnick

An informative, entertaining, tasty, thirst-quenching meeting of the Sydney Python group was held last night in a pub in the Sydney CBD (instead of at Google for a change).


The new venue had has pros and cons. On the plus side, we could order Thai food which was delivered to us when ready; it's a nice central location, just near Town Hall; and the house beer was just $3.60 a scooner. The down sides were some street noise and a bit of a flow of patrons through the presentation looking for dunnies.

Malcolm, a long time Django contributor, ran through the top security risks and talked about how Django protected us from ourselves in general. I've had the experience of one of my apps being formally externally security audited. Being a Django app it came up pretty well except for a few things that I had introduced.

Malcolm pointed out that Django's attention to security ironically makes us more likely to be kidnapped and "rubber hosed" by attackers!

It was great to get together and as always the chats with others in attendance were interesting and valuable. Thanks to the organisers, particularly Dylan.

Tuesday, January 03, 2012

A perfect day: work, social and soldersmoke

The weather has turned in Sydney and we have very pleasant sunny days with a refreshing wind.

Today I woke early and went for a brisk walk listening to a podcast. In the morning I worked, doing a geospatial project converting a Django project from Google Maps 2 to 3 as well as working to handle complex polygons efficiently (tens of thousands of points) with holes in them.

Lunch with Jonathan, then some more work followed by some quality shed time.

A kit arrived from QRP Kits, it's a DC40B CW transceiver. I'm still struggling to learn CW and I thought that having a CW only transceiver might help with my motivation. Instructions are good and it was lovely working in the shed with a breeze through the window blowing the solder smoke.

Over the past week there have been numerous visitors to the shed. Dave, VK3ASE, George, Bob, Dave VK2HLG, and Indy (ham call coming soon).

I'm on 20m WSPR and band conditions are really good. I'm running just 1W (the minimum my rig will go down to) and getting spotted right around the globe including by K1JT himself.


My reception seems quite low in noise and I'm also hearing lots of stations.

Thursday, December 29, 2011

Xmas present to self: Sony MDR-7506 Headphones

In this age of tiny computer speakers, or worse - laptop speakers, it's easy to forget just how good music can sound in a decent set of headphones.

I must be a bit of an addict as over the years the headphone collection has grown to more than ten pairs. While you generally get what you pay for, it's not always the case.

There's a bit of a balance to be struck between comfort and quality. When walking (where I listen to podcasts) I use either a little Bose on-ear pair or the Apple in-ear headphones - although I don't like the noise I hear as the cord moves around.

At my computer I've ended up using a Sennheiser HD 212Pro which I find very comfortable and pleasant despite a pronounced bass boom.

On the podcast front, I was a dedicated listener to Leo Laporte's TWIT network but the ads have grown to be so long as to sometimes go for five minutes or more. I'm also finding the density of useful information and unique insight has dropped. They do a great job and it must be hard to keep up the pace.

This year, 2011, I've discovered Dan Benjamin's 5by5 podcasts. I'm addicted to Hypercritical with John Siracusa and Talk Show with John Gruber. Host Dan Benjamin is a great host and sensitive interviewer, further he clearly cares about audio quality. Dan sounds great and chastises guests when their audio breaks up (I'm looking at you Gruber).

Dan has kindly published details of the equipment he uses and when he raved about the Sony MDR-7506 for just US$85 I thought I'd track down a pair. Foolishly, my first thought is I'd visit the local Sony Centre, imagining it would be like an Apple Store with every thing they make. The Sony store looks like an Apple store without any customers. They told me that the 7506 is obsolete and sold me the nearest thing: MDR-ZX500. While comfortable, they are disappointing lacking sparkle and I was soon back to the 212Pros.

In a Twitter exchange, Dan urged me to get the originals and today they arrived.

I really like the MDR-7506 headphones, wide response, smooth low end, sparkling high end response. They are comfortable and the curly cord is convenient (I often run over the long Sennheiser cord with my chair).

Here in Australia I ended up paying AU$167 (including fast shipping) via eBay seller onlyonline.

Tuesday, December 27, 2011

Shed visit from VK3ASE

Dave came to check out the shed. Unfortunately during coffee he was struck by a car...

Seems OK now.

Incidentally, WSPR on 20m is the busiest I've seen it:


Monday, December 26, 2011

Apple Lion Internet recovery a good thing

It used to be that I was in a tiny minority who used a Mac. I've always regarded this as a competitive advantage - I got on with my work while others fought with viruses, weird behaviour and a generally hostile environment.

Something's changed and a few years ago fellow programmers all switched to Macs, now this has broadened to the extended family too.

One potential drawback is that I'm the tech support "go to" guy.

A sister-in-law, who's never used a Mac, recently went wild and purchased a second hand 17 inch Macbook Pro. She used it for a day and then dropped it which killed the hard drive. Very upsetting.

She left it with me on Xmas day and I've just had the pleasant experience of using Apple's Lion Internet recovery feature.

Lion has a recovery partition on the boot drive which lets a tech person do a disk utility Repair or even a clean install. In this case the drive was damaged and so by booting holding down Command-R and choosing a Wifi network, the machine downloads this software from Apple.

In the future, when most machines out in daily use have this feature, it will be fantastic for front line support people - in the past we've had to build up a collection of software CDs for every different model.

I replaced the damaged drive with an old drive I had lying around. Turned out it contained Ubuntu which booted up and looked great. After re-formatting the drive, the install takes about half an hour.

Friday, December 23, 2011

Elecraft KX3 is coming

A new ham radio is about to become available and like too many others, I'm waiting to find out the price and place my order. The Elecraft KX3 looks like a worthy successor to the popular Yaesu FT-817 for portable low power operation.


This radio covers 160-6 meters, power 10W, weighs 0.7kg, and can draw as little as 150mA on receive.

Elecraft have said that they plan to start taking orders in December with delivery in February. As I write, December is running out rapidly.

There is an active Google group with over a thousand members who are currently all asking if there's any updates yet. Actually, the conversation turned amusing yesterday with people joking that they'd received theirs yesterday and others offering second hand units for sale. Elecraft's Wayne Burdick N6KR is chipping in every now and then to politely answer every question but the big one.

I can't remember seeing so much excitement before the release of a ham radio product before. Merry Xmas Elecraft, now finish it off and we can all take a break.

Elecraft are so quaint. I love how they've configured their Apache web server so we can view directories.

Update

Just placed my order on 28-December.



Huge archive of scanned 73 Magazine

Stephen, VK2BLQ, sent around an email pointing to a great archive of scanned issues of a popular ham radio magazine from my childhood, "73 Amateur Radio".

They come up in a rather strange order, like all the Decembers together, but they are high resolution scans saved as PDFs so perfect for reading on an iPad for inspiration.

It's a great way to see the march of technology from 1961 through to 2003.

Early editions are valve technology, later there are hybrid rigs with solid state drive to a valve final. Gradually digital frequency displays creep in and there's a marvellous time when having an LED is a feature worth advertising.

There's lots of ads featuring girls with big hair caressing equipment.

This collection, for me, represents what may be a golden age, before everything in electronics just turns into computer chips surrounded by surface mount components.

A few of the home brew group seemed interested in grabbing the set for later viewing so I wrote a little python script to download them from archive.org to share around. (I think I'm being throttled but it's going pretty well).


#!/usr/bin/python
"""
Download pdfs of 73 magazine.


Items at: http://www.archive.org/download/73-magazine-1968-09/09_September_1968.pdf
"""
import os
import urllib2


MONTHS = ('January', 'February', 'March', 'April', 'May', 'June',
          'July', 'August', 'September', 'October', 'November', 'December')


START_YEAR = 1961
END_YEAR = 2003
OUTPUT_DIR = "73 Magazine"
MISSING = ('73 Magazine/73-Magazine-1975_11.pdf',
'73 Magazine/73-Magazine-1975_12.pdf',)


def main():
    if not os.path.exists(OUTPUT_DIR):
        os.mkdir(OUTPUT_DIR)


    for year in range(START_YEAR, END_YEAR + 1):
        for month in range(1,13):
            monthName = MONTHS[month - 1]
            fileName = "%s/73-Magazine-%d_%d.pdf" % (OUTPUT_DIR, year, month)
            if not os.path.exists(fileName) and fileName not in MISSING:
                editionString = "%d-%02d/%02d_%s_%d" % (year, month, month, monthName, year)
                url = "http://www.archive.org/download/73-magazine-%s.pdf" % editionString
                print("Downloading: %s..." % url)
                print("To: %s" % fileName)
                pdfData = urllib2.urlopen(url).read()
                outFile = open(fileName, "wb")
                outFile.write(pdfData)
                outFile.close()
            else:
                print("Skipping: %s" % fileName)


if __name__ == "__main__":
    main()

If you stop the script and re-start it, it will not re-download any that it has. Otherwise it's pretty basic stuff.

Thanks archive.org! Look out for the ladies with tech:


iMac mysteriously shutting down

My wife's 24 inch iMac recently started exhibiting an annoying fault - it would, seemingly at random, just switch off.

Not a crash, not a shutdown, it just powered off.

My first thought was some sort of thermal problem tripping the power supply but oddly it did not seem related to the machine being busy or having been on for a long time.

I ran the Apple Hardware Test software which on very recent machines is built right in (you boot while holding the D key). On this machine it was on the second install CD, you insert the CD, reboot and hold the D key to get it.

Hardware test is a blast from past and uses the old System 7 GUI. I ran all the tests in the most thorough version, which takes hours, and everything came up clean.

The most reliable way to trigger a power off was rapidly launching a bunch of apps so that lots of icons were bouncing together. Very mysterious.

In the end the quickest way to trigger an instant power off was to run the iTunes visualizer. There's the clue - the graphics card.

The local Apple store took a few days and $600 to replace the graphics card and now we're good to go. I've never bought AppleCare, my Apple equipment has been fantastically reliable and the most likely problem - hard drive failure, I can fix myself. AppleCare on this machine would have been $268 per year so it would have broken even on this fault.

Wednesday, November 30, 2011

Australian PV Solar Energy Exhibition

Today I visited the Australian PV Solar Energy Exhibition at Darling Harbour in Sydney.

There were a lot of Chinese PV Solar cell manufacturers on hand and it seems like wholesale prices are diving to an incredible 77 cents per watt (we pay around $5 per watt retail so there's a good margin somewhere).

Interestingly, polycrystalline panels seem to be almost as efficient as monocrystalline and the extra area due to them being rectangular may be the reason.

The gentlemen at Alco Battery Sales were very kind and patiently answered a bunch of questions I had.

Something seems to have gone wrong with the show's timeline and apparently about two-thirds of the Chinese exhibitors didn't get time to clear customs to allow them to attend so it was much smaller than planned.

Several of the manufacturers commented that the withdrawal of the NSW solar rebate scheme had impacted them in a very negative way along with the instability in Europe. Happily, Germany, which has the largest solar program remains strong.

The standout in the show for me was the LED lighting, which I believe will take off in the next twelve months.


Above is a demo showing an incandescent 40W bulb producing the same output as an LED replacement using less than a tenth of the power. LED lights last much longer and in summer there are also savings in the need for air-conditioning.

Awaiting approval are 240V bulb drop-in replacements, 12V AC halogen replacements and 240V fluorescent tube replacements (you remove and bypass the starter).

Monday, November 28, 2011

A talk about setting up a small solar power system

At Sunday's Amateur Radio NSW Home Brew Group meeting I gave a talk about what I've learned about low voltage solar electricity systems.


My thanks to Peter, VK2EMU, for the opportunity to speak and to John, VK2ASU, for shooting the video.

If you find this interesting and want to know more there is a book "Small Solar" available for less than $3 from Amazon for the Kindle and in the Apple iBookstore for iPad.

Sunday, November 27, 2011

Back on WSPR on 20m but not on Windows

I have an MSI U-200 netbook that dual-boots Windows XP and Linux. For a long time I used Ubuntu but when I upgraded to 11.04 wireless networking wouldn't work and being unable to figure out the magic incantation decided to try Fedora.

There's no built WSPR for Fedora that I could find so I've been running it under Windows XP. Lots of people were spotting me (running under 5W from an ft-817) but I got no decodes of other stations at all. This morning I checked out the WSPR source and built it. All of a sudden I'm receiving lots of stations.


Ubuntu has been good to me but I found the switch to Unity a little premature and, quite frankly, Gnome 3 has all the good bits as far as I can tell and seems a lot more complete. It's weird that a desktop could ship without a simple way for a user to add a launcher to the dock (or whatever it's called).

Can't explain why I get no decodes on Windows. Perhaps the sound card is not right?

Thursday, November 24, 2011

Learning iOS 5 programming with Paul Hegarty

When I need to do a bit of Cocoa programming I normally turn to the excellent books from Big Nerd Ranch. iOS 5 and Xcode 4.2 has changed normal practice quite substantially and I was struggling along trying to re-interpret the old code in the new environment.

A couple of days ago the latest videos of the Stanford computer science class covering iPad and iPhone App development turned up in iTunesU.

This course presented by Paul Hegarty is fantastic. It's a best case example of good teaching by a master of what he is presenting. Even the questions from the class are spot on.

I've just got to lecture 4 which took place the day after Steve Jobs died. Paul gives a nice tribute and talks about the years when he worked at NeXT and how Jobs valued the aesthetics of things so much that FMRI scans of iPhone users match up with them feeling love (rather than the expected addiction).

He ends each lecture with "if you have any questions... I'm here."

Update

I'm still ploughing through these lectures and continue to be super-impressed with Paul Hegarty's teaching style and overall knowledge. It's wonderful that Stanford feels comfortable to release lectures of such quality for free to the public - great stuff, a credit to everyone involved!

Humbly, I'd like to propose some constructive feedback:

  • The slides are sometimes very wordy - fine when it's code, but often just descriptions that could be shortened.
  • Sometimes it's hard to read the code shown in Xcode, it ends up being rather soft, perhaps there is a more video friendly font?
And, an Apple TV complaint. The damn thing over-scans and I can't find a way to turn it off. So I lose the menu bar on my TV. I know it's there in the movie if I look in iTunes but you can't see it on the TV. The overscan is not in my TV.

Thanks Paul Hegarty, you are doing great work - thanks for sharing.

To be specific, here's a wordy slide example:


Update

Eight months after this post, I have two apps in the store by me and am now a full time iOS developer for a major media company which publishes a large number of apps. I'm loving my work and continue to learn more each day about iOS programming.

Tuesday, November 22, 2011

HP Laserjet 1022n prints every second page

A note to myself really. We have an old but reliable HP Laserjet 1022n laser printer but ever since Snow Leopard it has been printing every second page, with a blank page in between. I used a generic CUPS driver but the quality is very poor.

I've found a solution for me, that might work for others. If you set the printer's resolution to 600dpi it seems to print all pages and the quality is good. Here's how the setting looks in the print dialog box:


I've saved this as a preset so it comes up by default every time and has worked for me for several months now. This problem has many threads in Apple's support forums and HP's boards so I'm not alone. Hope it helps someone else.

Sunday, November 20, 2011

QRP Portable at Fisherman's Paradise

Just returned from a weekend away, four hours south of Sydney at Fisherman's Paradise. Here's my QRP portable station:


My antenna was a random wire, about 6m long, thrown to a tree from the balcony.

The ZM-2ATU antenna tuner does a fine job with a random wire and a counterpoise and never fails to tune up easily.

Fine copy on the WIA Sunday broadcast on 80m, 40m but best on 30m. I called back on 30m and while the VK2WI station couldn't make me out a few other stations relayed my presence. VK2BGU, VK2BGL, VK2JE and VK2HL were all very strong to me.

Local birdlife came to listen in and stayed for some snacks:


After lunch we went for a walk among the mosquitoes and looked at the local boats.


Back in Sydney and a big week ahead.