-
Posted: January 6th, 2009, 11:26pm CET
pI bought a pile of games through a href=http://store.steampowered.com/Steam/a a few weeks ago and as part of the deal I was given a guest pass for each of a href=http://www.counter-strike.net/Counter-Strike: Source/a and a href=http://www.teamfortress.com/Team Fortress 2/a. I don't need them but if I don't give them away soon they'll expire. If you haven't played one or both of these games and you'd like to give them a try, drop me an email and I'll send them your way./p
-
Posted: January 6th, 2009, 1:01pm CET
Like a screaming and kicking two year old being dragged through a shopping centre by the arm by a frustrated mother, the MPAA and RIAA appear that besides all the tantrums they have thrown over Internet users obtaining emtheir/em material; that the struggle is futile.br/br
br/br
Statistics have been released for both the Movie and Music industry for 2008. Remember, the year the bottom fell out financially in the 4th quarter (when you think people would be dropping entertainment products before anything else).br/br
br/br
The numbers are in... 2008 was the biggest year for both the a href=http://arstechnica.com/news.ars/post/20090102-music-sales-up-10-in-2008-thanks-to-downloads-and-vinyl.htmlMusic/a and a href=http://arstechnica.com/news.ars/post/20090105-what-piracy-movie-biz-sees-record-box-office-in-2008.htmlMovie/a industries. So much for Internet users destroying both industries as claimed by both bodies! img src=http://matt.bottrell.com.au/templates/default/img/emoticons/tongue.png alt=:-P style=display: inline; vertical-align: bottom; class=emoticon/imgbr/br
br/br
What the industry associations seem to slowly becoming aware of (and are appear quite scared of the consequences), is that former emucon/u/emsumers are turning into online emupro/u/emsumers.br/br
br/br
There is no need to run out and see that flashy new movie based on a slick TV advert. Most users wait for reviews, and even watch various trailers and snippets of the movies on a href=http://au.youtube.com/YouTube/a these days (before the MPAA jump up and down and it's pulled).br/br
br/br
Likewise people have woken up that by using online music stores they can buy just the individual 1-2 songs they want and not an entire album that is normally full of 8-9 tracks that are crap. img src=http://matt.bottrell.com.au/templates/default/img/emoticons/tongue.png alt=:-P style=display: inline; vertical-align: bottom; class=emoticon/img (This isn't always the case, and I often purchase full albums). As a result album sales are dramatically down and have continued the slide since 2006. (Can anyone say iTunes store?)br/br
br/br
With the issues of a href=http://en.wikipedia.org/wiki/Digital_rights_managementDRM/a media, you'll see more people demanding non-restricted medium. Particularly with issues moving that same purchase between different players (ie: Car CD player, MP3 player, desktop computer). Why should a user need to pay for multiple copies of the same item. With the physical medium this isn't required.br/br
br/br
It's great to see artists are jumpin onto digital downloads. (Examples that instantly spring to mind are a href=http://au.youtube.com/MontyPythonMonty Python with their own YouTube channel/a, and a href=http://www.radiohead.com/deadairspace/Radiohead/a releasing their a href=http://www.inrainbows.com/ target=_blank class=bb-url'In Rainbows'/a album direct to listeners over the Internet.) Hopefully the industry-execs realise it's a brave new world and that their fat-cat style lifestyles are over. Every other industry has been shaken up by both computing and the Internet, why not entertainment?br/br
br/br
The frivolous lawsuits these industries have waged over recent years against their actual emcustomers/em shows just how reluctant they are to move on. Is it a case they realise that the days of a big publishing house (Sony, EMI, Warner Bros, Universal, etc) are slowly eroding?br/br
br/br
Sure distribution to cinemas for movies is still probably required, but the days of customers buying media (CDs or DVDs) is quickly disappearing.br/br
For block-buster movies - I still love watching them on a big screen. But I would see probably 10% of movies these days in those red chairs and the remainder in the comfort and convenience of my home.br/br
br/br
With Nintendo jumping on board and a href=http://www.australianit.news.com.au/story/0,,24873755-15306,00.html target=_blank class=bb-urlannouncing a Wii entertainment channel (named Wiinomia)/a, on top of items like a href=http://www.tivo.com.au/Tivo/a - it's becoming common place. Users are already quite familiar with digital downloads for entertainment media (thanks largely to a href=http://www.apple.com/au/itunes/whatson/music.htmlApple's iTunes Store/a).br/br
br/br
So are you one that still buys CDs? Have you moved all your music across to digital libraries? (Personally I have bought music CDs, but very rarely play them, but use the ripped versions on my computer more than often. I often end up losing the CD and forgetting where I put them. They are emsomewhere/em in the house.. but loading my music player on my computer or grabbing my iPod is so much more convenient).br/br
br/br
Will we still see Music and DVD bricks and mortar stores in 10 years time?br/br
br/br
Online services like a href=http://www.last.fm/last.fm/a, a href=http://www.jamendo.com/en/Jamendo/a, a href=http://www.magnatune.com/ target=_blank class=bb-urlMagnaTune/a have helped many budding artists get global recognition that traditional distributors haven't been able to provide. Interestingly, I wonder if there is a service similar to these for budding movie creators (besides YouTube)?br/br
br/br
Hopefully more established artists currently under contract follow Radiohead's lead, and don't renew with their traditional labels and move to some of these new online distribution channels. It's a better solution for their fans, and likely to make them more revenues. (It's rumoured that Radiohead made $9mUSD from releasing his album directly to the public! - mostly by selling a limited edition of the album to fans). Quite clever! img src=http://matt.bottrell.com.au/templates/default/img/emoticons/cool.png alt=8-) style=display: inline; vertical-align: bottom; class=emoticon/imgbr/br
br/br
Where do you see the entertainment industry heading? Will the public get more direct access to artists and do away with record and movie companies? Will we see the work of these large companies restricted in future to just promoting cinema releases and rock band tours?br/br
br/br
Hold on to your hats, this game hasn't even started. What we've seen so far is only really like watching a New Zealand sporting team doing the a href=http://www.newzealand.com/travel/about-nz/features/haka-feature/haka.cfmHaka/a. The real game hasn't even commenced! Expect the industry to play dirty holding onto whatever emperceived/em advantage they believe they have.br/br
br/br
So far their a href=http://www.artistdirect.comArtists Direct/a website seems nothing more than a propaganda website, whilst appearing to be along the lines of Magnatune and Jamendo to confuse end-users. img src=http://matt.bottrell.com.au/templates/default/img/emoticons/normal.png alt=:-| style=display: inline; vertical-align: bottom; class=emoticon/img I guess the dirty tricks may have already started.
-
Posted: January 6th, 2009, 12:28pm CET
Version a href=http://kernelnewbies.org/Linux_2_6_282.6.28/a of the Linux kernel was released during Christmas, so I thought it'd be worthwhile waiting until after typical vacation days to post a summary of changes to the security subsystem. As always, thanks to the a href=http://kernelnewbies.org/Kernel Newbies/a folk who track major kernel changes.br/brulbr/brlibDummy SELinux policy support/bbr/brSerge Hallyn added a a href=http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=93c06cbbf9fea5d5be1778febb7fa9ab1a74e5f5dummy policy/a for SELinux to the kernel tree. This is useful for testing SELinux and a base for building minimal and experimental security policies.br/br/libr/brlibBouned per-thread security contexts for SELinux/bbr/brKaiGai Kohei submitted a href=http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=d9250dea3f89fe808a525f08888016b495240ed4a patch/a which allows different threads in a process to be labeled with distinct security contexts. Such threads are guaranteed to not exceed the security policy permissions of the parent process. This is part of his work in extending SELinux to the web application stack, and in this case, is aimed at constraining in-process web server scripts (e.g. mod_python applications)./libr/brlibLabeled networking updates/bbr/brPaul Moore provided a series of updates to the Labeled networking subsystem, which he promises to document on his a href=http://paulmoore.livejournal.com/blog/a./libr/brlibMAC policy for privilege in Smack/bbr/brCasey Schaufler a href=http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=15446235367fa4a621ff5abfa4b6ebbe25b33763extended Smack/a so that MAC policy may be used to limit the use of privilege. Previously, the Smack model maintained strict orthogonality between privilege and access control, where privileged processes were exempted from MAC policy enforcement. This feature allows for MAC policy enforcement of processes running with specific security label (as written to code/smack/onlycap/code), or for all processes if the codeonlycap/code label is specified as '*'./libr/brlibTPM updates/bbr/brRajiv Andrade provided a href=http://lkml.org/lkml/2008/9/23/261several updates/a for the a href=http://en.wikipedia.org/wiki/Trusted_Platform_ModuleTPM/a driver.br/br/li/ulbr/brThis was not a terribly exciting release for the security subsystem.br/brbr/brThus far for the 2.6.29 kernel, the main change is the massive credentials API change from David Howells. This has caused a couple of regressions, which were picked up by subsystem testing of Linus' tree. Fixes have been developed and are currently partially merged upstream. It seems we need to get more testing done in linux-next to avoid such breakage during future merge windows.br/brbr/brAlso noteworthy is the merge of the a href=http://marc.info/?l=git-commits-headamp;m=123077158301181amp;w=2pathname security/a hooks for LSM, which should pave the way for TOMOYO and AppArmor in 2.6.30, subject to the general patch submission review process. TOMOYO is only a couple of acks from approval, has been baking in -mm, and is pretty much self-contained. It may even appear in 2.6.29 if the merge window is open for features long enough.
-
Posted: January 6th, 2009, 12:12pm CET
pIt’s around 11 months since I started playing chess again so I thought I’d do a bit of a review and some goals for 2009./p
pI’ve found I enjoy playing quite a bit both at the club, tournaments and online as well as doing study both by myself and with others. So I’m definitely going to keep going this year./p
pIn the last rating list my rapid rating went from 1276 to 1314 but my normal rating only went from 1261 to 1274. The main reason for this is that I am still losing the odd game to very low ranked players though carelessness. My actual rating is probably closer to 1400 in both rapid and normal going against my results against players in the 1400-1500 level./p
pstrongGoals for 2009/strong
/pol
liGet my Rating to over 1700/li
liPlay in NZ champs in early 2010 and do well in under-2000 grade./li
/ol
strongProgramme to accomplish this/strong
ol
liKeep playing at the Club/li
liEnter as many tournaments as possible./li
liPlay in over-1400 grades when able/li
liTrain 10-20 hours per week/li
liKeep going to fortnightly coaching/li
/ol
strongWeekly training/strong
ol
li10-20 hours/li
li500 problems on tactics server ( 4 hours )/li
li20 Blitz games on FICS each week ( 4 hours )/li
li10 Standard games on FICS each week ( 4 hours )/li
liStudy Openings repertoire and practice it ( 4 hours )/li
liPlay though annotated games ( 4 hours )/li
/ol
Well that is the plan anyway. Certainly if I keep to it I’ve got a chance at reaching the goals. However keeping myself on track will be the hard bit.
pI’m using a little area in the spare room going as a study space. For a computer I’m just going to use my Eee ( with external keyboard, screen and mouse ) but keep it off the network most of the time to cut the urge to browse. But for now just a board and a few books but thats enough for a start./p
-
Posted: January 6th, 2009, 11:27am CET
pI thought I would have a crack at a href=http://photojojo.com/content/tutorials/project-365-take-a-photo-a-day/Project 365/a. You basically take a picture every day for a year - I know a few people doing it - so thought it would be fun joining in. Today was a a href=http://refactor.com.auRefactor/a lab day - so my picture for the day is fairly boring... my laptop keyboard which has been getting a pounding lately and is starting to look pretty grubby./p
pa href=http://www.flickr.com/photos/spidie/sets/72157612169404683 title=Project 365img src=http://farm4.static.flickr.com/3301/3172942398_9f973246fb_m.jpg title=Project 365 height=160 width=240 alt=Project 365 class= flickr-photoset-img/img/a/p
pAnyway - I'm not going to post every day's photo to the blog - I'll just put them in a flckr set and comment on them there. I need a very very simple way of doing it to make sure I do it every day and I procrastinate too much on the blog. If you click on the image above it takes you to the set./p
pAaron Spence from a href=http://panedia.comPanedia/a also took a rather nice picture of my a href=http://kahdo.com.auKahdo/a as he came over to drop some stuff off:/p
pa href=http://photos.panedia.com/p1013038409/h3a82fafc#h3a82fafc title=http://photos.panedia.com/p1013038409/h3a82fafc#h3a82fafchttp://photos.panedia.com/p1013038409/h3a82fafc#h3a82fafc/a/p
-
Posted: January 6th, 2009, 11:15am CET
pa href=http://code.kissu.org/Raj Kissu/a is in the papers today. He completed a Google Summer of Code 2008 project with MySQL, hacking on blob streaming for phpMyAdmin. In fact, his project was so good, he has commit access to the phpMyAdmin tree :-)/p
pToday, The Star had an article about him (and two other students), titled a href=http://star-techcentral.com/tech/story.asp?file=/2009/1/5/itfeature/20090105140811amp;sec=itfeatureFor the love of code/a. He said:/p
blockquotep
But Raj has already heard inquiries for his project. “A company that has developed a transactional engine using MySQL server have clients who want to test BlobStreaming,” he said.
/p/blockquote
pKudos Raj. I think we’ll see more great work from Paul McCullagh and Barry Leslie, as more happens with a href=http://www.blobstreaming.org/Scalable BLOB Streaming for MySQL/a happens. /p
pIn fact, Barry Leslie from PrimeBase will be speaking about blob streaming in his talk titled a href=http://en.oreilly.com/mysql2009/public/schedule/detail/6727BLOB Streaming: Efficient reliable BLOB handling for all storage engines/a, at the a href=http://en.oreilly.com/mysql2009MySQL Conference amp; Expo 2009/a. What are you waiting for - a href=https://en.oreilly.com/mysql2009/public/registerregister now and save!/a See you at CE2009!/p
-
Posted: January 6th, 2009, 11:15am CET
pSo, its a few hours before MacWorld 2009, and I’m contemplating getting an iPhone 3G. December 2008 has come and gone, and there is no sign of Apple partnering with any telco, or deciding to sell unlocked units in Malaysia, much to my annoyance. No, no, I love my Nokia E71, I’m just researching the iPhone 3G./p
pDavid runs MyMacBuzz, and has a useful resource available: a href=http://mymacbuzz.com/2008/07/05/where-to-get-a-legally-unlocked-iphone-3gWhere to get legally unlocked iPhone 3G (updated)/a. Many folk on Twitter also helped, and pointed me to a href=http://www.iworld.com.my/iWorld/a (horrible Flash based website)./p
piWorld sells the 16GB edition for RM3,099, and the 8GB one for RM2,899. Its all unlocked, and nice. I couldn’t help but mosey over and compare it though, with other countries (I’m told unlocked versions are sold in Singapore too, I just couldn’t find the price online, easily)./p
ul
li8GB: iWorld (RM2,899), NZ Vodafone (NZD$979 = RM2,005), HK Apple Store (HKD$5,400 = RM2,437)/li
li16GB: iWorld (RM3,099), NZ Vodafone (NSD$1,129 = RM2,308), HK Apple Store (HKD$6,200 = RM2,806)/li
/ul
p/pcentera href=http://www.flickr.com/photos/byte/3172799755/ title=iPhone 3G - Apple Store (HongKong) by byte, on Flickrimg src=http://farm2.static.flickr.com/1025/3172799755_80e2880f1e_o.jpg alt=iPhone 3G - Apple Store (HongKong) height=54 width=291/img/abr/brsmallThis is what I like to see - seen at the Apple Store Hong Kong/small/center
pApparently, Optus is selling the iPhone 3G 8GB for AUD$729 (which is only RM1,820), but to unlock it you’ve got to be on a contract (I wonder if my AUD$5 contract applies? Probably not)./p
piWorld apparently provides a warranty for seven days, but beyond that, you’re on your own - they’ll help you out if need be, but I guess if something goes wrong, you’re on your own./p
pI know there have been lots of MacWorld predictions and wishes, but my hope is that we’ll see iPhones available in more regions, unlocked, even./p
-
Posted: January 6th, 2009, 10:39am CET
a href=http://al3x.net/2008/12/29/journaling-vs-blogging.htmlAlex Payne/a writes of keeping a private journal, separate from his blogs.br/brbr/brblockquoteThe primary and obvious difference between journaling and blogging is that a journal is private. A journal exists only for the author’s personal consumption, or possibly as a posthumous record of a life. Without the modest audience my blog has accrued, I have no incentive to filter what I write for content or style. I can be as dry or as flowery as I like and nobody need suffer./blockquotebr/brbr/brI've been doing this too, and went through some kind of dry spell in blogging in the process of working it out.br/brbr/brIt seems like by blogging in 2009 you speak to a much larger audience, or a different kind of audience, to that you might have reached in say 2001. I remember one friend then writing very personal content in a blog, hidden in html comments. Was it to filter it to more technical readers, or to people looking closely rather than just skimming? Or was it, I speculate, a kind of desire to work out the boundary between the public and personal. br/brbr/brBeyond keeping a private diary, sometimes online and sometimes on paper, I've found it useful to keep special journals, append-only and dated, just in text files, on particular topics or projects. If I come back to a project after a gap of a few weeks or even a few minutes it reminds me where I was, and seems to help in reestablishing flow. And if it's the kind of issue that takes long-term contemplation it's quite enlightening to see what I thought of it six months ago. One can easily believe one always thought what one thinks now.
-
Posted: January 6th, 2009, 10:12am CET
I'm heading to South America later this month, which should be great. It's on my a href=http://www.dopplr.com/traveller/sourcefrogdopplr page/a, which looks like an interesting little service.
-
Posted: January 6th, 2009, 10:08am CET
pIf anybody is getting the codeVERR_SUPDRV_COMPONENT_NOT_FOUND/code error when trying to start a VM in VirtualBox when trying to set up Host Interface networking, the error is occurring because VirtualBox can’t communicate with the codevboxnetflt/code driver./p
pTo fix this, simply load the codevboxnetflt/code module:/p
blockquote
pre# modprobe vboxnetflt/pre
/blockquote
pThen, try starting the VM again. If it works, you know that the problem is that the codevboxnetflt/code module is not loading on startup./p
pOn most Linux systems, you can add an entry to code/etc/modprobe.conf/code to make the module load on startup. (On OpenRC-based Gentoo systems, you can add an entry to code/etc/conf.d/modules/code to do it the Gentoo Way™.)/p
-
Posted: January 6th, 2009, 9:38am CET
Someone directed me to this a href=http://newzleech.com/nfo.php?id=574722NFO entry/a.br/br
br/br
Can't say I've seen the movie (it's currently showing in cinemas across the country if you're interested).br/br
If the movie is anything like the NFO entry than it's bound to be awesome!
-
Posted: January 6th, 2009, 6:40am CET
pSo, having just last night been trying to convince myself that I could deal with the low-CPU and (more importantly) battery life of the a href=http://www.notebookreview.com/default.asp?newsID=4352HP Mini-Note 2133/a (a href=http://jon.oxer.com.au/blog/id/294Joxer seems happy/a with his) along comes CES and the announcement of the a href=http://www.engadget.com/2009/01/05/hps-new-mini-2140-stuffs-atom-larger-screen-into-original-form/HP Mini-Note 2140/a, with an Atom CPU, and reportedly a resolution of 1366 by 768./p
pstrongWant./strong/p
pAnyone reading know of any way to get one by/at linux.conf.au at the end of the month? Apple had a bunch of ibooks and powerbooks to loan out (and I think optionally purchase) at linux.conf.au 2004, maybe that’d be something that a certain a href=http://linux.conf.au/sponsors/sponsorsEmperor Penguin Sponsor/a would consider this year… hint hint! :)/p
psmalla href=http://www.erisian.com.au/wordpress/2009/01/06/netbook-blegPermalink/a |
a href=http://www.erisian.com.au/wordpress/2009/01/06/netbook-bleg#commentsNo comments/a
br/br
/small/p
-
Posted: January 6th, 2009, 5:28am CET
b19:30/b: Mikal shared: a href=http://www.abc.net.au/news/stories/2009/01/06/2459962.htmMan forced to cover Arabic T-shirt gets $US240k - ABC News (Australian Broadcasting Corporation)/abr/bruliI think this is a good outcome. If government officials can't be sensible with their powers, then perhaps the fear of a big payout will keep them and the airlines honest./i/ulbr/br
b19:30/b: Mikal shared: a href=http://www.rowetel.com/ucasterisk/ip04.htmlIP04 Four Port IP-PBX/abr/bruliThis thing looks really cool. If only I could work out what to do with a PBX in my house.../i/ulbr/br
br/brbr/briTags for this post: blather(a href=http://www.stillhq.com/blatherimg src=http://www.stillhq.com/tagicon.cgi?post=/blather/20090105amp;tag=blatheramp;format=.png alt=S border=0/img/a) /i
a href=http://www.stillhq.com/blather/20090105.commentform.htmlComment/a
a href=http://www.stillhq.com/index.noblather.rss20RSS with no blather/a
-
Posted: January 6th, 2009, 3:27am CET
I had planned to go paddling this morning. My road bike had a flat tyre with
a slow leak, so I did not want to take it to work. I hopped on my fixie at
7:40, planning to be on the water by 8am and off the water just before 9am and
at work by 9:20am. However as I crossed Northbourne avenue I remembered why I
had been avoiding riding the fixie, the quill and bolt in the stem had
stripped and I was unable to tighten the bars enough to stop them rotating
away from pointing straight ahead.
p
Paddling plans scuppered due to not thinking I would be safe riding that bike
(and I did not want to to ride a mountain bike over to the boat shed), I
headed home, fixed the flat tyre on the road bike, shaved, and headed over to
Maladjusted to get a new quill and bold for the Cinelli stem on the fixie
(Cinelli bars are not a standard road bar width, they are a bit smaller so
you need to use Cinelli stems with them, at least this is the case with the
old Cinelli stuff I am using on the fixie).
/pp
Got to work at 9am in the end anyway with the fixie back in working order (and
the tyre properly seated so not about to pop and go bang with the bead sitting
out as it had been. Last year one of the ARNuts Tuesday night runs we did when
it was hot was to run from Weston park to Black Mountain Peninsula, swim back
across to Weston park and have a bbq with any and all ARNuts who ran or just
rocked up.
/pp
I termed this a new and interesting variation on the classic triathlon, the
legs being Run/Swim/BBQ. We had a number of people who were specialists at the
BBQ leg rock up last year. Fun was had by all involved. Thus this arvo we are
trying it out again. Should be good to cool off swimming in the lake after a
run in this heat./p
-
Posted: January 6th, 2009, 2:28am CET
I needed to compare a host key from something other than a known_hosts file with what paramiko reports as part of the SSH connection today. If you must know, the host keys for these machines are retrieved a XMLRPC API... It turned out to be a lot easier than I thought. Here's how I produced the host key entry as it appears in that API (as well as in the known_hosts file):
br/brbr/br
ulpre#!/usr/bin/python
# A simple command example for Paramiko.
# Args:
# 1: hostname
import base64
import os
import paramiko
import socket
import sys
# Socket connection to remote host
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((sys.argv[1], 22))
# Build a SSH transport
t = paramiko.Transport(sock)
t.start_client()
key = t.get_remote_server_key()
print '%s %s' %(key.get_name(),
base64.encodestring(key.__str__()).replace('\n', ''))
t.close()
sock.close()
/pre/ul
br/brbr/br
Note that I could also have constructed a paramiko key object based on the output of the XMLRPC API and then compared those two objects, but I prefer the human readable strings.
br/brbr/briTags for this post: python(a href=http://www.stillhq.com/pythonimg src=http://www.stillhq.com/tagicon.cgi?post=/python/paramiko/000005amp;tag=pythonamp;format=.png alt=S border=0/img/a) paramiko(a href=http://www.stillhq.com/paramikoimg src=http://www.stillhq.com/tagicon.cgi?post=/python/paramiko/000005amp;tag=paramikoamp;format=.png alt=S border=0/img/a) /i
a href=http://www.stillhq.com/python/paramiko/000005.commentform.htmlComment/a
-
Posted: January 6th, 2009, 2:20am CET
pThe gio library provides both synchronous and asynchronous interfaces for performing IO. Unfortunately, the two APIs require quite different programming styles, making it difficult to convert code written to the simpler synchronous API to the asynchronous one./p
pFor C programs this is unavoidable, but for Python we should be able to do better. And if you’re doing asynchronous event driven code in Python, it makes sense to look at a href=http://twistedmatrix.com/Twisted/a. In particular, Twisted’s Deferred objects can be quite helpful./p
pstrongDeferred/strong/p
pThe a href=http://twistedmatrix.com/documents/8.2.0/api/twisted.internet.defer.Deferred.htmlTwisted documentation/a describes deferred objects as “a callback which will be put off until later”. The deferred will eventually be passed the result of some operation, or information about how it failed./p
pFrom the consumer side, you can register one or more callbacks that will be run:/p
blockquote
prestrongdef/strong callback(result):
# do stuff
strongreturn/strong result
deferred.addCallback(callback)/pre
/blockquote
pThe first callback will be called with the original result, while subsequent callbacks will be passed the return value of the previous callback (this is why the above example returns its argument). If the operation fails, one or more errbacks (error callbacks) will be called:/p
blockquote
prestrongdef/strong errback(failure):
# do stuff
strongreturn/strong failure
deferred.addErrback(errback)/pre
/blockquote
pIf the operation associated with the deferred has already been completed (or already failed) when the callback/errback is added, then it will be called immediately. So there is no need to check if the operation is complete before hand./p
pstrongUsing Deferred objects with gio/strong/p
pWe can easily use gio’s asynchronous API to implement a new API based on deferred objects. For example:/p
blockquote
prestrongimport/strong gio
strongfrom/strong twisted.internet strongimport/strong defer
strongdef/strong file_read_deferred(file, io_priority=0, cancellable=None):
d = defer.Deferred()
strongdef/strong callback(file, async_result):
strongtry/strong:
in_stream = file.read_finish(async_result)
strongexcept/strong gio.Error:
d.errback()
strongelse/strong:
d.callback(in_stream)
file.read_async(callback, io_priority, cancellable)
strongreturn/strong d
strongdef/strong input_stream_read_deferred(in_stream, count, io_priority=0,
cancellable=None):
d = defer.Deferred()
strongdef/strong callback(in_stream, async_result):
strongtry/strong:
bytes = in_stream.read_finish(async_result)
strongexcept/strong gio.Error:
d.errback()
strongelse/strong:
d.callback(bytes)
# the argument order seems a bit weird here ...
in_stream.read_async(count, callback, io_priority, cancellable)
strongreturn/strong d/pre
/blockquote
pThis is a fairly simple transformation, so you might ask what this buys us. We’ve gone from an interface where you pass a callback to the method to one where you pass a callback to the result of the method. The answer is in the tools that Twisted provides for working with deferred objects./p
pstrongThe inlineCallbacks decorator/strong/p
pYou’ve probably seen code examples that use Python’s generators to implement simple co-routines. Twisted’s ttinlineCallbacks/tt decorator basically implements this for generators that yield deferred objects. It uses the enhanced generators feature from Python 2.5 (a href=http://www.python.org/dev/peps/pep-0342/PEP 342/a) to pass the deferred result or failure back to the generator. Using it, we can write code like this:/p
blockquote
pre@defer.inlineCallbacks
strongdef/strong print_contents(file, cancellable=None):
in_stream = strongyield/strong file_read_deferred(file, cancellable=cancellable)
bytes = strongyield/strong input_stream_read_deferred(
in_stream, 4096, cancellable=cancellable)
strongwhile/strong bytes:
# Do something with the data. For this example, just print to stdout.
sys.stdout.write(bytes)
bytes = strongyield/strong input_stream_read_deferred(
in_stream, 4096, cancellable=cancellable)/pre
/blockquote
pOther than the use of the yield keyword, the above code looks quite similar to the equivalent synchronous implementation. The only thing that would improve matters would be if these were real methods rather than helper functions./p
pFurthermore, the ttinlineCallbacks/tt decorator causes the function to return a deferred that will fire when the function body finally completes or fails. This makes it possible to use the function from within other asynchronous code in a similar fashion. And once you’re using deferred results, you can mix in the gio calls with other Twisted asynchronous calls where it makes sense./p
-
Posted: January 6th, 2009, 1:26am CET
The 2009 a href=http://www.cc-asiapacific.net/Creative Commons Asia Pacific/a Conference will be hosted by the Arellano University School of Law, Manila, on the 5-6 February 2009.br/brbr/brVisit the a href=http://philippinecommons.org/Philippine Commons/a website for further information about the Conference, as well as other local CC developments and events.
-
Posted: January 5th, 2009, 11:57pm CET
pI’m not an expert on this subject matter, nor a Debian developer, but I do love Debian. I couldn’t help but be disheartened by the a href=http://www.debian.org/vote/2008/vote_003.en.html#outcomeresults of the vote on firmware in Lenny/a./p
blockquotepAssume blobs comply with the GPL unless proven otherwise./p/blockquote
pBAH! Seriously, what the hell are you guys thinking? If I wanted this sort of crap I’d use Ubuntu! Sure it’s just firmware, but why not distribute the NVIDIA driver too? Afterall it hasn’t be proven in court as to whether it complies with the GPL or not./p
pHow hard is it to just release Lenny with the current GPL-compliant open source firmware and let end users install other binary blobs at their own discretion? I just don’t understand how you can distribute that which you have no idea what it does. Maybe I’m missing something, but this just a href=http://www.debian.org/social_contract#guidelinesseems so wrong/a./p
-
Posted: January 5th, 2009, 3:34pm CET
pFor the UNIX users out there who use the a href=http://git.or.cz/git/a revision control system with the oldskool a href=http://www.greenwoodsoftware.com/less/less/a pager, try adding the following to your code~/.gitconfig/code file:/p
precode[core]
# search for core.pager in
# lt;http://www.kernel.org/pub/software/scm/git/docs/git-config.htmlgt;
# to see why we use this convoluted syntax
pager = less -$LESS -SFRX -SR +'/^---'
/code/pre
pThat’ll launch less with three options set:/p
ul
licode-S/code: chops long lines rather than folding them (personal preference),/li
licode-R/code: permits ANSI colour escape sequences so that emgit/em’s diff colouring still works, and/li
licode+'/^---'/code: sets the default search regex to code^---/code (find code---/code at the beginning of the line), so that you can easily skip to the next file in your pager with the coden/code key./li
/ul
pThe last one’s the handy tip. I browse commits using codegit diff/code before committing them, and like being able to jump quickly back and forth between files. Alas, since emless/em is a dumb pager and doesn’t understand the semantics of diff patches, we simply set the find regex to code^---/code, which does what we want./p
pOf course, feel free to change the options to your heart’s content. See the a href=x-man-page://1/lesscodeless(1)/code manpage/a for the gory details./p
pAs the comment in the configuration file says, you’ll need to use the convoluted codeless -$LESS -SFRX/code prefix due to a href=http://www.kernel.org/pub/software/scm/git/docs/git-config.htmlinteresting git behaviour/a with the codeLESS/code environment variable:/p
blockquote
pNote that git sets the LESS environment variable to codeFRSX/code if it is unset when it runs the pager. One can change these settings by setting the codeLESS/code variable to some other value. Alternately, these settings can be overridden on a project or global basis by setting the codecore.pager/code option. Setting codecore.pager/code has no affect on the codeLESS/code environment variable behaviour above, so if you want to override git’s default settings this way, you need to be explicit. For example, to disable the codeS/code option in a backward compatible manner, set codecore.pager/code to codeless -+$LESS -FRX/code. This will be passed to the shell by git, which will translate the final command to codeLESS=FRSX less -+FRSX -FRX/code./p
/blockquote
p(And sure, I could switch to using a different pager, but I’ve been using emless/em for more than a decade. Yep, I know all about Emacs amp; Vim’s diff-mode and a href=http://changesapp.com/Changes.app/a. It’s hard to break old habits.)/p
-
Posted: January 5th, 2009, 3:34pm CET
pQuite often, you may have simple setter methods that need to do a just a tiny bit of work before or after setting an instance variable. For example, maybe you need to redraw something after setting the property of an object. So, instead of writing this:/pcode font color=#990000[/fontself setBackgroundColorfont color=#990000:[/fontNSColor blueColorfont color=#990000]];/fontbr/br font color=#990000[/fontview setBackgroundColorfont color=#990000:[/fontNSColor blueColorfont color=#990000]];/fontbr/br/code
pYou’d probably want to move the relevant code to your code-setBackgroundColor:/code accessor instead:/pcode font color=#990000-/font font color=#990000(/fontfont color=#009900void/fontfont color=#990000)/fontsetBackgroundColorfont color=#990000:(/fontNSColorfont color=#990000*)/fontcolorbr/br font color=#FF0000{/fontbr/br ifont color=#9A1900// Assuming that _backgroundColor is the ivar you want to set/font/ibr/br bfont color=#0000FFif/font/bfont color=#990000(/font_backgroundColor font color=#990000!=/font colorfont color=#990000)/fontbr/br font color=#FF0000{/fontbr/br font color=#990000[/font_backgroundColor releasefont color=#990000];/fontbr/br _backgroundColor font color=#990000=/font font color=#990000[/fontcolor retainfont color=#990000];/fontbr/br br/br ifont color=#9A1900// Update the view's background color to reflect the change/font/ibr/br font color=#990000[/fontview setBackgroundColorfont color=#990000:/font_backgroundColorfont color=#990000];/fontbr/br font color=#FF0000}/fontbr/br font color=#FF0000}/fontbr/br/code
pThen you can simply call code-setBackgroundColor:/code and expect it all to work nicely:/pcode ifont color=#9A1900// -setBackgroundColor: updates the view's background color/font/ibr/br ifont color=#9A1900// automatically now/font/ibr/br font color=#990000[/fontself setBackgroundColorfont color=#990000:[/fontNSColor blueColorfont color=#990000]];/fontbr/br/code
p(You could use a href=http://developer.apple.com/documentation/Cocoa/Conceptual/KeyValueObserving/index.htmlKey-Value Observing/a to do this, but I generally avoid KVO for simple intra-class property dependencies like this. I don’t think the overhead of maintaining all the KVC dependencies and KVO-related methods is worth the cost.)/p
pOf course, the above method requires that you write all that stupid boilerplate memory management code in the accessor. Instead of doing that, I tend to declare a private code_backgroundColor/code property in the class, code@synthesize/code a method for the private property, and then use the private property’s generated accessors instead:/pcode @interface bfont color=#000000MyClass /font/bfont color=#990000()/fontbr/br br/br ifont color=#9A1900// Declare a _private_ _backgroundColor property (thus the underscore/font/ibr/br ifont color=#9A1900// in front, and why it's declared in a class continuation rather than/font/ibr/br ifont color=#9A1900// in the public header)/font/ibr/br @bfont color=#000000property /font/bfont color=#990000(/fontcopyfont color=#990000,/font setterfont color=#990000=/font_setBackgroundColorfont color=#990000:)/font NSColorfont color=#990000*/font _backgroundColorfont color=#990000;/fontbr/br br/br @endbr/br br/br ifont color=#9A1900///font/ibr/br br/br @implementation MyClassbr/br br/br @synthesize _backgroundColorfont color=#990000;/fontbr/br br/br font color=#990000-/font font color=#990000(/fontNSColorfont color=#990000*)/fontbackgroundColorbr/br font color=#FF0000{/fontbr/br bfont color=#0000FFreturn/font/b font color=#990000[/fontself _backgroundColorfont color=#990000];/fontbr/br font color=#FF0000}/fontbr/br br/br font color=#990000-/font font color=#990000(/fontfont color=#009900void/fontfont color=#990000)/fontsetBackgroundColorfont color=#990000:(/fontNSColorfont color=#990000*)/fontcolorbr/br font color=#FF0000{/fontbr/br ifont color=#9A1900// Use the private property to set the background colour, so it/font/ibr/br ifont color=#9A1900// handles the memory management bollocks/font/ibr/br font color=#990000[/fontself _setBackgroundColorfont color=#990000:/fontcolorfont color=#990000];/fontbr/br br/br font color=#990000[/fontview setBackgroundColorfont color=#990000:[/fontself _backgroundColorfont color=#990000]];/fontbr/br font color=#FF0000}/fontbr/br br/br font color=#990000.../fontbr/br br/br @endbr/br/code
pWith that technique, it’s possible to completely directly setting ivars, and thus avoid code-retain/code and code-release/code altogether. (You’ll still need to use code-autorelease/code at various times, of course, but that’s reasonably rare.) We have some source code files that are well over 2000 lines of code without a single explicit code[_ivar retain];/code or code[_ivar release];/code call thanks to this technique. (Yeah, 2000 lines is also large and the class needs refactoring, but that’s another story.)/p
pOf course, you could just a href=http://www.mac-developer-network.com/podcasts/lnc/lnc036/use garbage collection/a which avoids 99% of the need for this bollocks:/pcode font color=#990000-/font font color=#990000(/fontfont color=#009900void/fontfont color=#990000)/fontsetBackgroundColorfont color=#990000:(/fontNSColorfont color=#990000*)/fontcolorbr/br font color=#FF0000{/fontbr/br ifont color=#9A1900// Yay GC!/font/ibr/br selffont color=#990000-gt;/font_backgroundColor font color=#990000=/font colorfont color=#990000;/fontbr/br br/br font color=#990000[/fontview setBackgroundColorfont color=#990000:/fontselffont color=#990000-gt;/font_backgroundColorfont color=#990000];/fontbr/br font color=#FF0000}/fontbr/br/code
pBut plenty of us don’t have that luxury yet. (iPhone, ahem.)/p