Tuesday, July 03, 2007

Bonjour/Zeroconf fun on Linux

I have a headless Fedora linux box that plugs in to my home network and gets an IP address from DHCP.

To find it I've been pinging the broadcast address, in my case 172.16.1.255, and then trying to ssh to each of the IPs that answer until I find it. Very agricultural. Seems like a great reason to use Zeroconf.

To advertise the sshd service, put this in /etc/avahi/services/ssh.service:

<?xml version=\"1.0\" standalone=\'no\'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM \"avahi-service.dtd\">
<!-- See avahi.service(5) for more information about this configuration file -->

<service-group>

<name replace-wildcards=\"yes\">ssh on %h</name>

<service>
<type>_ssh._tcp</type>
<port>22</port>
</service>

</service-group>

Here's another example showing how to include the path in the http url:

<?xml version=\"1.0\" standalone=\'no\'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM \"avahi-service.dtd\">
<!-- See avahi.service(5) for more information about this configuration file -->
<service-group>
<name replace-wildcards=\"yes\">myservice on %h</name>
<service>
<type>_http._tcp</type>
<port>80</port>
<txt-record>path=/0/1/</txt-record>
</service>
</service-group>

It's a good idea to set the hostname to something reasonable in /etc/sysconfig/network and reboot.

As root:

# chkconfig --level 35 avahi-daemon on
# service avahi-daemon start

Now you can Command-Shift-K in the MacOS Terminal to browse for the sshd service.

Even better, you can use Chicken of the VNC client to browse for a VNC desktop by putting this in /etc/rc.local

# start vnc for my username at boot
su -l username -c "/usr/bin/vncserver -geometry 1200x900"

(Replace username with YOUR username).

As you, run vncpasswd and set a password. You probably want to edit ~/.vnc/xstartup to uncomment the two lines that give you the full gnome desktop. Reboot.

Now run Chicken of the VNC, do an "Open Connection..." and you'll see the host in the list. Mine comes up as Display 1, your's might be different.

I wish this stuff was just on by default.

Monday, July 02, 2007

Winning the war on tourists


My 14 hour flight arrived at 6:20am on Monday morning at Sydney International airport.

I got to a taxi at 8am. It's not the time that bothers me, it's all the other little things that added up to make it a stressful, confusing, and frustrating experience for me; and I dread to think how it was for the poor folks who don't speak English.

Running the gauntlet of customs, baggage and quarantine is a horrific experience.

Here's my suggestions for how to make it a better experience for the newly arrived:

* Have "fair queues" (where there is a single queue entrance and at the end people fan out to be served) everywhere.
* At the entrance to each queue station a person who checks that people are joining the right queue and have the documents and forms required when they are served.
* If the baggage conveyer fills up (because of the backlog at immigration) have someone take bags off rather than stopping the conveyer and holding up those who are waiting.
* Put a "stand behind this line" around the baggage conveyer so people stand back until they see their bag. This works really well in Japan.
* Have one person who's job is to enhance the experience for travelers through the whole process. If there is such a role, have them contact me or sack them. (Yesterday, in the US where they are on threat level orange, we had a fairly rigorous security process but it was clearly explained, fair and queue time was being actively measured).
* Signs in more languages are required.
* Make sure the TV monitors above queues are working (one was out this morning and people were being sent away for being in that wrong queue)

I felt bad for non-english speaking travelers who waited a long time to get to the end of the wrong queue and didn't have the form filled in. They were sent away with a wave. I also felt bad for me, who is cursed with always joining the slowest queue. Other's jump from line to line, trying to judge the complexity of processing the people or the slowness of the agent by appearance.

Clearly several flights arrive at once at this time, but it's no surprise. It didn't appear to be a staffing level problem, more an organisational problem. Individual staff seemed efficient and friendly, I have no complaint there.

The ultimate irony is just how fantastically efficient the duty free store is on the way in and the taxi rank on the way out.

Saturday, June 30, 2007

iPhones on sale in Bellevue, WA

It was a friendly crowd, friendly staff, and friendly security guards.

Other shoppers stood on the level above watching the queue wait patiently as the big iPhone demo screens in the window counted down second by second.

Two minutes out the black paper was ripped from the windows.

As the final seconds counted down the staff formed an honour guard and clapped the eager shoppers as they filed in to plunk down their $500 (plus a two year contract).

This all went really smoothly, but I think the real genius, from a telco perspective, is that these folks just bought the box and then headed home to do all the churning and provisioning via iTunes.

Safari on a big touch screen might be great but having your customers do their contract sign up at home, rather than holding up staff in your store is brilliant. I'll buy one, but not until it does 3G. 

Thursday, June 28, 2007

iPhone news story predictions

It's Wednesday, two days before launch, and I thought I'd predict the stories that we'll see over the coming weeks and months in advance.

iPhone dissassembled - yes, someone will pull one apart, within hours, and publish photos of the interior.

iPhone screen cracked - someone will sit on their phone and, yes, the glass screen will crack, duh.

iPhone screen scratched - despite the glass surface, folks will carry iPhones in a pocket full of keys or diamonds or something and it will scratch.

Complaints about AT&T's data network - this has started even before release by the reviewers. The iPhone makes people even more aware of how bad mobile carrier data services are.

How to unlock the iPhone's SIM lock - so you can use it with other carriers and take it abroad. I'm sure it's well secured but someone will figure this out. Will it be weeks or months?

Build and install your own software on iPhone - it's running MacOS X, it has a CPU with available tool-chains, people will figure out how to add software or turn on sshd. Hopefully Apple will release some decent tools at least for creating widgets.

Linux booting on iPhone - like on iPods, there's not much real point except to show that if you release hardware, someone will reverse engineer it enough to boot something else on it.

Replace the iPhone battery - it sounds like it worked great when new, but after a year of daily charge/discharge cycles, the battery will lose capacity and folks will want to replace it. Just like iPods, third parties will step up and offer kits or services.

New iPhone features in software alone - but not as much as we might hope. Like the iPods, this is a blank canvas for software to run on, but while there will be a few updates, I think we'll find that we are buying a new model to get the new compelling features every two years.

iPhone versions with more memory - hardly worth mentioning, but yes, within a year there will be iPhones with 16Mb and 32Mb. Here is a platform for showing movies, there needs to be a device with 100Gb.

iTunes on iPhone - you want that song, and you want it now right? You have a billing account with your carrier and an iTunes account. You can buy the tune and download it on the spot. The download will be unbilled by the carrier.

Multi-touch iPod range - all the larger iPods will come out in multi-touch models with large screens. Perhaps the nano will remain as it's such a good form factor and is so physically strong. The big question is will these new iPods have wireless and will they therefore include Safari and email.

iPhone inspired phones from others - already Nokia has re-considered their objection to touch screen phones. Apple claimed to own "multi-touch" but then Microsoft showed their table top interface which seems to work the same way. Yes, we'll see phones that are all touch screen from the others as well.

Stories we won't see

I'm going out on a limb here...

Skype for iPhone - Not in the short term (two years) this would harm the carriers potentially fatally. Imagine if there was an iPhone with a VOIP client and a WiMax modem. You wouldn't need a phone carrier at all.

MMS for iPhone - People are saying it's a missed feature, but really do we need old broken MMS on modern devices. If Safari on the iPhone is the real internet, then email is real MMS. It's time MMS died. 

An apology.

Sorry to anyone who was searching for one of these predictions and came across this posting, thinking that their dream had come true.

Let me know what I've missed. I'll put dates next to the items as they come true. Should be fun.

Saturday, June 23, 2007

Things I've learned in America

Obesity: It must be hard to not get huge here. A lot of people carry a lot of weight. The meal servings are enormous. I had a salad for lunch one day and it was so big I ate half and had the other half for dinner.

TV: Not much on. I feel we get the best of it in Australia anyhow. At night it's all ads for junk food and diet pills. Thank goodness for the Discovery and History channels.

Radio: Mostly "golden oldie" stations. Thank goodness for NPR (National Public Radio), it took me a while to find the local one as the bedside clock radio couldn't separate it from the stronger station next to it. Shops are full of satellite radio receivers which look cute. Analog radios in stores have a note on them saying that analog radio will be replaced with digital within a few years. I couldn't see any digital terrestrial receivers on sale.

It's a great pleasure to hear "A Prairie Home Companion" live on air instead of just the monolog excerpt we get via the podcast.

Walking: For my first few days here, I just tried to walk everywhere. It's really hard, the place is built for cars. In the end I hired the smallest car I could, a Ford Focus.

Driving: It's easier to drive here than in Sydney. The traffic is slower and the lanes are wider. There are excellent left turn lanes, clearly marked. You can turn right though a red light, which saves a lot of time. Even though I'm driving on the other side what what I'm used to I got used to it very quickly. Saw some great arrow traffic lights that change colour. I guess aside from the visual cue of the three lights we could just have one big LED light.

The pedestrian crossings are smart too, if the traffic lights are green your way and you push the crossing button the pedestrian light will go to walk if there is enough time to cross. Even better you often get a count down showing how many more seconds until the lights change so you can judge if it's safe to run.

Cars: are huge, as my colleague Ben pointed out recently. I don't think it's just because some people are big. Folks don't realise that all those big bars on the front of the vehicles don't save lives, quite the reverse. Having said all this, I've seen a lot of hybrid vehicles, not just Toyota but also Honda.

Navigating: While I don't find numbered streets very memorable, the system is starting to become clear. Here in Bellevue, roads running North/South are Avenues, roads running East/West are streets. The huge house numbers are actually a coding that includes the leading digits of the cross road. So 12345 would likely be close to a cross road called 123. I guess there's an assumption of no more than 99 houses on a block.

Shops: Home Depot has totally copied Australia's "Bunnings". Shopping malls are just huge. I even felt like driving to other parts of one, and I like walking! The staff are often rather robotic with a small collection of phrases ending with "have a nice day". If you talk to someone they are really nice. I think the training in customer service must value form over function in some dreadful way.

The local supermarket is Safeway and there is a club you have to join or you pay a much higher price on many items. (The amount varies a lot between products). I looked at the form and it seems you need a local address and you will give up your contact information for this money.

Seems like a very large proportion of shops have signs up saying they are looking for staff. Is there high turnover or something?

People: Really nice when you get to talk to someone. Quite different to the government from what I can tell. The folks I shared an airport shuttle with apologised for their leader. I chastised them for voting for him.

Coffee: Well Starbucks anyway. Unbelievably weak compared to what I'm used to. All bad milk froth. I asked for a double strength tall (which is really small and even then pretty big) to which they said it was already a double, so I got a quad strength, and that was weak. In the end I bought and "french press" (plunger) and find that the local coffee tastes pretty good.

Cheap wifi at coffee shops is a really good idea. Tons of people use it. In the morning there is a queue for the coffee and all the tables have people with laptops doing work on the internet. I don't know why we don't have more of this in Australia. It seems like the whole city is bathed in WiMax for $30 per month for 768Kbps or $37 per month for 1.5Mbs.

Anyhow, I've had a great time but miss the family. I hope I haven't put on too much weight...

Giant iPhone demo screens at Apple stores

These giant iPhones are in the window of the local Apple store here. They play a full demo movie that looks great. 
I commented to the guy watching that the phones are much bigger than I'd hoped. 

He laughed and said he was trying to figure out how to get out of his existing contract. 

Interestingly he said he was keen to see what third party applications would be available for the device.

The Cingular (AT&T) outlet in the same shopping centre just had a small board saying iPhone coming June 29. Interesting that the Apple store gets the flashy display but you have to go around the corner to actually get one.

Sunday, June 17, 2007

Bonjour (zeroconf) fun at an airport hotspot

I attended a great session on Bonjour at the WWDC presented by my hero Stuart Cheshire. The dream of zeroconf is that you can simply plug a device in to your laptop, with no other network infrastructure (such as DHCP servers, or DNS), and simply browse for it and start using it.

Stuart demonstrated a shared disk product from LaCie that did just that. Plugged it in and it came up as a file share, a web page for admin, and even a streaming music server in iTunes. Great stuff.

Another great technology is wide area zeroconf where you can grab a Bonjour control panel and add extra, non local, domains to it that will be searched as well. This multicast DNS stuff works on a local subnet, but I was wondering if it would also work within a hotspot at an airport... it does, I'm on a T-Mobile hotspot at Seattle airport and above is the visible shares I can see via the bonjour browser in Interarchy.

Clearly there's a potential security problem here and Mac users should be aware that their name and machine is visible. I had a look at the web pages that showed up and they were just the Apache welcome page in both cases.

Saturday, June 16, 2007

WWDC over for 2007

The Apple conference was huge this year. A record of more than 5,000 attendees. Fantastically organised but it's so big that there were queues for everything. 

When Leopard ships later this year it's going to be great. I can't wait to see what developers build on top of it.

As always with conferences, I got snippets of valuable information from the sessions, but the greatest insights came from conversations with other developers during breaks. Met a bloke today who builds highly scaleable apps in python which are deployed on Linux for telcos - he explained to me how they manipulate the global interpreter lock so that their heavy lifting threads make use of additional cores.

People came from all over the world, such as Mr Xin above, who assured me that his organisation looked fine on the web form. (From a distance I first thought it was that famous AACS key again).

I've had a hard time with jet lag this year. I seem to be in some unknown third time zone, not San Francisco, and not Sydney. Wide awake at 4am local time.

Incidentally, this is being created using the Safari 3 public beta which seems excellent to me.

Tuesday, June 12, 2007

Traveller's tip #12, video conference the kids

Perhaps I'm naive, but it does seem amazing to me that when travelling these days it's perfectly practical to video conference the kids from my hotel room in high quality audio and decent video.

To me, the quality of the internet connection in my room is probably the most critical factor in choosing a hotel.

Skype seems to be working pretty well these days, except for some stability issues. Even waved at the cat.

I'd prefer to use iChat more but so often I have trouble getting the connection no doubt due to double NAT.

Interesting that the internet connection here includes separate pricing for routable or non-routable IP addresses. This time I went for the cheaper non-routable IP for US$12 per day.

Contributed an item to SolderSmoke

I've been going to the NSW Home Brew group recently and last meeting I took a digital recorder along and spoke to some of the members about what they were up to. I thought it might be of interest to the SolderSmoke podcast and, indeed, it was.

Bill was very encouraging and has run the item in podcast number 62. His intro starts at 19mins 45 seconds in to the program (but listen to the whole thing).

Thanks to Bill for including the item, sorry about the roudy background noise, and thanks of course for the members who agreed to be interviewed. It was tough chopping down to ten minutes, I have enough good material for two more spots still in the can.

Sunday, June 10, 2007

In San Francisco for Apple WWDC

It's always great to visit San Francisco. It's such a cosmopolitan place. The streets are full of interesting people. Oddly a few people asked me for directions.

I'm here primarily for the Apple World Wide Developer's conference which is always a blast.

Qantas flight 73 is to be recommended. A direct flight from Sydney so it's just 13 hours. The in-flight entertainment system is excellent with a great choice of current and "art-house" movies. I watched: "Pan's Labyrinth", which was great but not for the kids (explicit violence including portrails of torture); "The History Boys", strangely overacted by the "boy" characters but enjoyable; "For your consideration", deeply funny exposé of hollywood and the Acadamy awards by the guy that made "Spinal Tap"; and most of "Zodiac", which looks really great and I can't wait to see it all.

Liked the food and had an empty seat next to me, so I can't complain. Didn't get much more than a couple of hours of fitful sleep so, right now, I'm going for lots of walks trying to stay up until a reasonable bed-time so that I'll be in sync for the week ahead. Sitting in a dim room watching a presentation, even about an interesting operating system, is very sleep inducing if you are jet-lagged.

Shared a mini-bus with some locals who apologised for their president almost immediately.

Had a couple of Skype calls over the $12 / day hotel internet. Excellent quality. One time during a video conference my computer screen went to sleep and Skype crashed, it's still rather unstable on the mac for some reason.

Had a look at some products not seen in the flesh before. A Microsoft Zune, that I couldn't turn on, it just displayed a mysterious power plug icon. I guess it was flat. A Sony Reader. Lovely eInk display, readable in direct sunlight. Annoying page turn reverse flashing effect, but for reading long texts I can see a role for it.

Don't expect much detail from me on the WWDC on this blog. I honour the non-disclosure agreement that everything except the keynote will be under.

Monday, June 04, 2007

Enjoying MIT physics lectures

Ben put me on to a gem in the new iTunes U area. There are freely available university lectures available and I've been watching the wonderful Prof. Walter Lewin going through the basics (to him) of electromagnetism.

The series is available either through the iTunes store or directly from MIT.

The good professor has a wonderful sense of humour and jokes about the dangers of working with 300KV gear, "if something goes wrong you'll get a replacement lecturer on Monday". I found the basic concepts of charge and how dialectics work utterly fascinating and the maths isn't terribly complex.

It's amazing how much basic physics is not common sense. His mix of lecture style with simple experiments to show the principles works really well and is highly accessible.

Seems to me that publicly funded educational institutions should put all of their course material up in the public domain, after all we've all paid for it. If MIT and Stamford can do it, what about TAFE?

Friday, June 01, 2007

Fedora 7 final review

Here are my initial impressions of Fedora 7 final on a modern Intel motherboard with built in video, ethernet and sound. I grabbed the torrent today.

Install was smooth. After that you create a user account and configure sound, then for some reason you need to reboot.

I set the machine to get an IP address via DHCP so the first thing I wanted to know was the IP address. Usually I run terminal and do a /sbin/ifconfig but terminal has moved to the "System Tools" menu. Fair enough I guess. I tried to find the IP address in System/Administration/Network but I couldn't find it there.

It might be good to make the IP address easy to find. The Places menu has a bunch of new locations, not just Documents but Music, Pictures, Videos, and Downloads. Seems like a good idea, but these are all folders that already exist in the home directory which does rather clutter things up. I'm unlikely to be doing much video on my linux box.

The updater killed the machine for a little while and then told me there were a number of updates. When I asked for them it said "Unable to retrieve software information" presumably the fedora updates site is being hammered right now. Still, the message wasn't informative.

First launch of OpenOffice was a bit slow, but after that it was really great. If someone wants a computer to to web browsing, word processing, spreadsheets and simple presentations then this Linux distro would do the trick. For everything else, get a Mac.

Under look and feel, there is something called "Desktop Effects" that can make windows wobble and do the Apple cube effect when switching desktops. This is surely a waste of time and just a pointer to what's to come in the future. I tried it but quickly turned it off.

Now that we have Firefox, one computer operating system is pretty much as good as another. I went to cnn.com, it said I needed Flash, I agreed and it was installed smoothly without re-launching the browser. Great stuff.

At work we deploy on Fedora 6, 7 comes with Python 2.5 so I'm pretty confident everything will just work (but I'll let you know).

My IDE of choice Komodo 4.1 seems to work just fine (actually a bit better than on MacOS).

So far, so good.

Sunday, May 27, 2007

Mini field day at Dural

Attended the mini field day at the WIA NSW Dural site today. Beautiful weather for it, a good turn out, got some useful bits and pieces though nothing major. Quite a few car boot sellers oddly selling complete HF setups with older style rigs.

The home brew team got together with a bit of "show and tell", I brought along my MMR-40 and compared notes with John, another builder. Stephen, VK2BLQ, showed an experimental 80m short vertical which we tried to tune up by using the "pin through the insulation" technique of finding the right spot in the coil.

Alan, VK2ZAY, told me he'd built a tiny 2m AM transmitter Fredbox last night and when we got home I could hear it at my place, which is about 5Km away. Not bad for an estimated 30mW!

Gosh, during the writing of this story Blogger appears to be down for several minutes. Could Google be fallible?? It's giving 502 Server Errors.

Alan wrote up the day here, he scored some excellent bits and pieces I should have been more alert.

Saturday, May 26, 2007

Built a 40m SSB transceiver kit: MMR-40

Since having a wisdom tooth out on Tuesday I've been laying low this week and took the opportunity to construct a kit.

Shown at right during construction, the MMR-40 from Hendricks QRP kits is a great little kit transceiver. Mine was missing a couple of diodes but was otherwise complete. I had a few problems getting the receiver going due to the fact that I hadn't read the errata and mistook the different zener diode for one of the missing diodes and experienced some very strange voltages that affected the transmit/receive switching circuit.

After a long night of hair pulling I joined the Yahoo MMR40 owners group and posted a question about my symptoms. Very quickly Tom replied from a Blackberry with a pointer to the problem. Great stuff.

I find building kits is a great way to get familiar with components and in particular diagnosing problems helps me greatly in understanding the circuit. I never dreamed that I could build an SSB transmitter. Still some work to do to get it all lined up but it seems to be putting out a few watts.

An interesting part of this design is the permeability tuned oscillator where part of the inductance is varied by screwing a brass bolt in and out of the coil. You can see it at the bottom right of the image above. Counter-intuitively, to me, is that frequency goes down as you wind the bolt in. The good thing is that you get slow change over turns of the knob and it seems remarkably unaffected by hand capacitance.

Update: After swapping out the mis-placed zener the receiver was still a little disappointing. Turned out that like others I had followed the layout diagram and installed a 22pF capacitor at C18 which caused T1 not to tune up. The only other oddity is that if I turn my variable supply up much above 12V the receiver mutes, not a big deal.

Anyhow, the receiver is working really nicely and is sensitive enough to hear all that bad band noise on 40m, which is all you need really. I'm not confident that my transmitted SSB is right yet, it puts out power when I talk but doesn't look like real SSB just yet.

A simple modification has been to install a stereo headphone jack that cuts off the speaker. Builders should note that the speaker really comes to life when you put it in the box and close it, very soft on the bench on its own.

I'm enjoying this but I think the kit errata needs an update. The design is very clever in that it re-uses lots of components for both receive and transmit but it lacks a block diagram so I've tried to create my own here.



(Click for a larger version). Please send me corrections!

Incidentally, wisdom tooth removal went very well - the wonders of modern dentistry.

Sunday, May 13, 2007

Built a roll-up 2m j-pole antenna

I saw Dom Bragge's posting about a 2m J-Pole antenna made out of 300 ohm TV ribbon and thought I'd give it a go.

Although the design specifies 51 inches in length, Dom notes that other builders have found this resonates too high in frequency and they suggest you start at 52 inches. I did that but found that the lowest SWR was at 148Mhz so even that's too short.

Perhaps 300 ohm twinlead material is different to the original designer.

I do have one contribution to make on this topic, it's really hard to strip the insulation from this twinlead. The insulation seems very strongly bonded to the conductors and they always rip out for me. The solution is to melt your way through with a soldering iron.

Some toxic vapour comes off but it seems pretty easy to tin the wires after the plastic melts away. Shown above is the bottom of the antenna where the co-ax connects and the shorting bar at the base. The melting works quite nicely as you can see.

Thanks to Dom for the pointer to this simple and highly portable VHF antenna design.

The Nature of Photographs - mini book review


Spotted this wonderful book this morning. "The Nature of Photographs" by Stephen Shore, subtitled "A Primer".

The reproductions of photographs is fantastic in this high quality publication from Phaidon. Works are by the author and many others including Robert Frank, Walker Evans, Cindy Sherman, Lee Friedlander, André Kertész, William Eggleston, Garry Winogrand, Bernice Abbott, Dorothea Lange, Alfred Stieglitz, Diane Arbus, Eugene Atget, and even the great John Szarkowski is in there.

Well structured and simply stated, this book has given me a good structure for appreciating photographs. Packed with insights that in retrospect seem obvious. For example, the artist starts with a blank page and must fill it, the photographer starts with the clutter of the world and must simplify it.

Progress on the 80m challenge transmitter

Finally making progress on the NSW Home Brew group's 80m challenge project to build a 20W 80m AM transmitter.

I'm a bit daunted as I have never made anything that puts out more than about 500mW and have very little RF experience, but progress is finally being made.

A design has been cobbled together based on the Hendricks QRP TwoFer design, built for 80m.

So far I have the oscillator and a buffer stage running nicely and I'm looking for an RF power transistor to get to 2W. I can't seem to source a 2N2553 or 2SC799 so I've ordered from the U.S. but disappointingly they say it won't ship for up to 3 weeks.

The smoke from an MPF102 was released along the way due to wiring it in reverse.

In other news, I picked up 20m of RG213U co-ax from the MWRS at a great price. I've run this through a hole, up between the double brick walls, through the ceiling and to my newly stretched out 40/80m dipole upstairs.

Reception is great but when I transmit all hell breaks loose from RF getting into audio amplifiers. Once again, my long wire antenna looks like being the most practical transmitting system here.

Thursday, May 10, 2007

MacMorseTutor version 0.00001

As part of my elaborate procrastination about learning morse code I've started writing my own tutor program for MacOS X. So far it sounds out the text you type in a field, displaying the character it just played after the audio.

It is available for your evaluation pleasure here.

This is just the start, planned features are:
  • Drill characters by playing and then displaying them.
  • Test by playing and then having me type the letter.
  • Give positive and negative feedback after typing the letter.
  • Controls for speed and spacing.
I know almost nothing of Cocoa programming but I find it a very easy environment to work in. Can't wait for WWDC.

Python decorators a simple example

Python decorators are a wonderful syntax for wrapping one function in another. I had a bit of trouble understanding the documentation, which often seems to involve talking about the history of how the syntax evolved rather than cutting to the chase and giving a simple example.

Specifically, I wanted to know how to get access to the arguments to the function I'm decorating in the decorator. Here's my example, at the top is the output:


"""
Example decorator that gets function arguments.

>>> decotest.py

>in mydecorator
>Function decorateme has been wrapped
> args = hello this is request
> kwargs = {}
>request = hello this is request
decorateme got request = hello this is request
>finished wrapped function
"""

def mydecorator(f):
print ">in mydecorator"
def wrapper(*args, **kwargs):
print ">Function %s has been wrapped" % f.__name__
print "> args = %s" % args
print "> kwargs = %s" % kwargs
request = args[0]
print ">request = %s" % request
f(*args, **kwargs)
print ">finished wrapped function"
return wrapper


def test():
request = "hello this is request"
decorateme(request)

@mydecorator
def decorateme(request):
print "decorateme got request = %s" % request

if __name__ == "__main__":
test()