Wednesday, 24 March 2010

Kathy Sierra: creating a passionate developer


To mark Ada Lovelace Day, I'd like to 'give props' to Kathy Sierra, a woman whose approach to technology, learning and creativity has been a big part of my journey from historian to web developer.  As a younger woman I pursued an academic career in British gender and social history.  While I attained a PhD and was awarded a post-doctoral fellowship, job opportunities were very thin on the ground, not to mention located distressingly far from my partner.  So, in 2004 I determined that a new direction was called for, and decided to embark on a career in programming.  I should note that my partner, also from a humanities background, moved from linguistics to Java programming during the Dot Com Boom and his example was an important role model for me. 

My MSc in Information Techonology was an extremely challenging year, made worse by the fact that my instructors and fellow students understood the language of numbers and took a corresponding approach to programming.  I, on the other hand, had a good grasp of logic and of natural language and the writing process, but a shockingly poor conceptualisation of numbers, symbols which continue to 'short circuit' my brain.  Happily, I discovered Kathy's Head First series of Java learning guides.  The wit and humour of Head First helped me to excel in learning Java and Java for web applications; these books spoke to me in a way my instructors could not, and their innovative approach gave me an 'in' to the world of Java.  Kathy's passion for best practices and technology were inspiring and key to my ability to develop the initial skill set to pass my MSc with distinction, go out into the world as a Java developer and to then strike out on my own as an Internet entrepreneur working mainly in Python.

My metamorphoses from an historian to technologist was a painful one, but Kathy's fresh and unconventional approach to learning and her insights into Creating Passionate Users demonstrated to me in a very powerful way both that women 'belonged' in tech just as much as men and that working in technology was full of potential for fun and satisfying challenge.

Wednesday, 13 January 2010

Mac OSX application window won't maximize

I had an absolute nightmare with my Eclipse on Mac OSX 10.5.8, this morning, when, all of a sudden, the opened application window appeared as above.  As you can see the '+' button was obfuscated and there was no means of dragging open or expanding the window.  The main Mac header was available and I could, for instance, open an Eclipse search box, but could in no way expand the main window.

The problem: Mac doesn't support 'maximize'.  Using Google-fu, I sought keyboard shortcuts for 'maximize'.  This revealed to me that Mac does not support an equivalent 'maximize' functionality, as on Windows (I became a Mac user in Sept '09, so still finding my feet), and so keyboard shortcuts for 'maximize' are problematic and app-dependent.

The solution: Right Zoom from Blazing Tools. This sweet little piece of freeware installs quickly and allows you to Cmd + Option (alt) + E to 'maximize' the current application's window.  Saved my bacon and stopped me having to reinstall my whole development environment. Whoop!

Wednesday, 30 December 2009

Google App Engine: paging with inequality filters

I recently implemented paging for my Google App Engine app, Braineos, ordering results using a unique inequality filter. My implementation is based on Joe Gregorio's Paging through large datasets tutorial, but tweaked in order to overcome apparent flaws in Gregorio's implementation and to meet the search result ordering requirements of my application.

Paginating results has important performance implications. While GAE limits results sets to 1000 and it's unlikely that a user will ever require more than a 1000 results, fetching up to the maximum number of results is less optimal that fetching a smaller defined limit with each query: pagination is included in Google's Best practices for writing scalable applications.

Gregorio describes several means of ordering paginated results, and the paging on a unique property approach was most appropriate for the needs of my application: I wished to order user generated content first by the number of positive 'votes' the content received and second by the most recently created content.  This approach uses shard counters to enable the creation of a unique key as well as quick updates to the datastore. Gregorio's Contributor class and unique 'when' property creation were added to my code base (the when property added to the model object representing the user generated content)[1]:

class Contributor (db.Model):
count = db.IntegerProperty(default=0)

def _unique_user(user):
email = user.email()

def txn():
contributor = Contributor.get_by_key_name(email)
if contributor == None:
contributor = Contributor(key_name=email) 
contributor.count += 1
contributor.put()
return contributor.count

count = db.run_in_transaction(txn)

return hashlib.md5(email + '|' + str(count)).hexdigest()

def whenfromcreated(created):
return created.isoformat()[0:19] + '|' + _unique_user(users.get_current_user())

My search module then used the 'when' property when ordering results sets:

def find(self, searchTerm, pagesize=configuration.Configuration.PAGESIZE):
searchTerm = searchTerm.split(',')
searchTerm = [term.strip().lower() for term in searchTerm]       
query = UGC.all()
for term in searchTerm:
query.filter('searchTerms =', term)
ugcs = query.order('-when').fetch(pagesize + 1)
  return ugcs

def findNext(self, searchTerm, next, pagesize=configuration.Configuration.PAGESIZE):
searchTerm = searchTerm.split(',')
searchTerm = [term.strip().lower() for term in searchTerm]    
query = UGC.all()
for term in searchTerm:
query.filter('searchTerms =', term)
query.filter('when <= ', next).order('-when')
ugcs = query.fetch(pagesize + 1)
return ugcs

This implementation fitted with the app's existing shard counting implementation and provided an excellent starting point. I came up against two issues. First, appending the count to the user's email before digesting with MD5 resulted in unreliable desc ordering. Second, because the 'when' property is used as an inequality filter, ordering must first be on that property (so I couldn't first order my results on 'votes' and then 'when').

I worked around the first issue by appending the count value after the user's email was digested:

return hashlib.md5(email).hexdigest() + '|' + str(count)


I worked around the second issue by prepending the number of votes to the 'when' property:

def whenfromcreated(created, votes=0):
return votes + '|' + created.isoformat()[0:19] + '|' + _unique_user(users.get_current_user())

This approach appeared to behave as expected, however my initial unit test used a sample of less than 10 UGC objects and it became apparent that once a user's contributions exceeded nine, desc ordering would be inaccurate: a unique user string ending in '|9' is deemed greater than a string ending in '|10'. Happily a fellow GAE app developer encountered a similar problem when attempting to use int values in a str comparison and suggested converting the int values to hex to allow alphabetical comparison.[2] I altered the code to wrap votes and count in the hex() factory function and my unit test, which seeks to order 10 items into two pages, is now passing.

There is significant discussion around pagination in GAE and while my implementation seems to stick pretty close to Google's reference implementation, if others have devised more elegant solutions, I'd be interested to know more - comment below!

[1] Gregorio's full code sample is available here.
[2] See Paging - ordered by a signed integer

Sunday, 4 October 2009

FOWA 2009: warrior principles of start-ups

Life is fighting. I have stronger belief in this maxim everyday of life's journey. I am a 'fighter' of sorts, having worked in a few BJJ competitions between knee injuries, and certainly martial arts, since I started training in '98 and increasingly over the past 4 to 5 years especially the art of Brazilian Jiu Jitsu, has been the prism through which I understand the world. 'Fighting' is, as I've touched on previously, a many splintered thing and the principles I understand as fundamental for tearing it up on the mats, for me, underpinned FOWA's second day of talks.

It is difficult to separate out three distinct principles, as in practice, they are organic to one another and represent articulations of different means of overcoming the limitations of ego. With that in mind, I propose three Warrior Principles for Start-ups/Cheerleaders/Zoo Keepers and Your Mom, because really they are grand notions that run through everything. Remember, life *is* fighting.

1 Be in the now

2 Be fearless

3 Be committed

I'll take the third principle first. Be committed. In tech community parlance this translates as 'passion'. This really came through for me during Alex Hunter's discussion of brand savvy. His message in a nutshell: there's no room to half-ass it, believe everyday that your project is awesome and let that standard of excellence and personal investment drive your business activities. Or, as Coach says, 'if you believe in your sweep, more than he believes in his base, you'll get it'. This isn't some sort of Jedi mind trick that magically teleports you to the top of Google's page rankings or mashes your opponent's side into the mats, rather absolute trust in your technique allows you to deliver it with powerful conviction and if your competitor is that much less confident, well then, you just might take their back and sink in an RNC (oh the joy!). Total commitment could be considered an expression of an unselfconscious state of being, where fears of failure or timidity associated with looking like a douche don't come into play. This state can best be achieved when fearlessly existing in 'the now'. Only with girded loins and a solid heart can we move forward to embrace change with positivity.

Lynne D Johnson's consideration of the 'future of print' and Gary Vaynerchuck's thoughts on, well, 'crushing it', for me, particularly stressed the importance of adapting to change and rolling with the punches. What does this mean, in practice? I turn to the rubric of BJJ for understanding. When starting my BJJ journey, I, like white belts the world over, found safety and comfort in holding on to positions that were long past their expiry. This is a manifestation of fear and the misguided desire to impose our will on a fluid situation rather than grappling with the opportunities as they are, there and then: see Gary's advice to 'stop your cryin' and exploit the opportunities that *are* there, rather than fixating on those that aren't. As I've metamorphosed into blue belt over the past year, fear remains an issue for my game, but chasing long dead positions is far less prominent in my rolling than in the early days. Fear of change leads to an inability to adapt and, well, you adapt or die. The more I am fully invested in the now, and the more I capitalise on immediate opportunities the more I am able to fight well and this allows me to win. Winning isn't just tapping someone out, though sometimes that is an effect, but it is coming away from the experience with the most personal growth. Okay, a bit 'new age' perhaps, but as Vaynerchuck noted he is, 'always about the process not the results'. It is the means, not the ends, that make us stronger and impart the confidence and skills to deal with change as it presents itself.

So, how did I enact these Warrior Principles at FOWA? I reverse stage-dived the 'Kevin and Gary Show' (a Q&A session with Kevin Rose and Gary Vaynerchuck). Gary asked for a show of hands, 'who has a start-up', and then invited us on stage, or at least the first one that could get there. I looked to my left and apart from my business partner there was one dude at the end, but I was calculating this as I jumped the dude's legs and laptop bag. I'm turning and running at a good clip towards the stage and glimpse movement out of the corner of my eye and only then realised; the steps are to the left, there's someone headed for them and stairs are for chumps. I'm taking the most direct route. A parallel process, also spawned, is determining if there are stairs at the front of the stage, without my glasses I can only make out what appear to be tiers, no, not tiers just detailing; gonna have to vault. My bod picks up pace and I'm putting my hands above me onto the stage and jumping to get my hips over, *knowing* that if I get my hips over the ledge I'm in. Swing my leg up and over, and boom, first on stage. Recognise!

Yes, I flashed my ass to the audience as my dress was not built for scaling stages. Yes, I was totally unprepared to pitch Braineos. Yes, my domain wasn't even configured properly and we're still frantically trying to tighten up our core features and implement our beautiful Safetygoat design in order to push to private alpha in 6 to 8 weeks. But, 'big whoop', these things meant nothing; I was completely committed, I was in the now and fearless. I saw the position and I went for it without *thinking* without the limitations of ego, just was and did in unison. This is what it is all about. Man oh man, I rejoice that I am a grappling-geek.

See ya next year!

Friday, 2 October 2009

Sausage Fest, strike that, FOWA 2009

The 'future of the web' a grand vision that is being considered and debated at this week's FOWA. You could be forgiven for assuming the 'future of the web' is both white and male – the demography of Internet engineers/web developers/IT professionals remains resilient to change. Wider, unchallenged social gender biases were especially prominent in Osama Bedler's (PayPal) presentation. While Bedler's talk on embracing change and moving forward with positivity into a cashless future was well delivered, inspired and fun, the promotional clip from PayPal depicted an intransigent world where women retained greatest responsibility for getting the shopping in and 'mom still made all the meals'. Yeah, way to challenge 'the now' and envision a liberated future. Yet, the conference has included some exciting technology announcements in a convivial atmosphere in West London.

Day 1 included some fantastic talks. Highlights for me? I took a lot from Mike McDermot's (FreshBooks) perspective on priority marketing systems required for even the most scope-trimmed start-ups; this is not my area of expertise and conferences, especially Think Visibility, have been a great source of Internet-focused marketing information. Bruce Lawson's (Opera) discussion and demonstration of HTML5 was thrilling and has me itching to implement new rules in my app's mark-up. Chris Thorpe's (The Guardian) talk on how The Guardian is seeking to adapt to a changing world through 'mutualisation' included a lot of lessons for industries/organisations clinging to outmoded business models and pointed to the prudence of embracing change and innovation in telecommunications. Aza Raskin (Mozilla) finished the evening with pizazz, with a thrilling discussion and demonstration of the future of browsers as Mozilla understands. Mozilla, again, is pushing a sound agenda of personal ownership and individual liberty by innovating a 'you-centric' browser. Inspiring, cogent stuff; not to mention the semi-gratuitous bondage pic included in the presentation appealed to my sense of fun.

With highlights come lowlights. FOWA has many corporate sponsers – a pro and a con – and the panel talk on experiments with building in ASP dot net MVC left me cold; while the tech sounded decent, though the panel's developer (Matt Lee, Redgate) noted it represented more of a 'catching up', it all seemed a bit staged and infomercial. Similarly, the breathless, chirpy presentation for Facebook (Cat Lee) regarding FB Connect was not up to par. The rep delivered what seemed in many ways to be a 'canned talk'; the announcement of a Connect API was exciting and the tech looks interesting, but the delivery did not seem at all appropriate to the audience. While I absolutely agree with Addison Berry's (Lullabot) message that employers benefit from facilitating passion through transparent communication, I was a bit disappointed by her talk which vaguely alluded to all the 'cool shit' and 'crazy shit' she was able to do working in Open Source. What is this 'amazing shit' – no idea – specific anecdotes/examples would have left me with less of an impression that she was 'talkin' shit'.

Day 2 is off with a bang! Britt Selvitelle (Twitter) threw out two points of note: 1) an upcoming release of Twitter Labs (currently in development); 2) the notion of whacking in an API with start-up alpha releases (we're on the same page, dude!). Simon Wardley's talk on cloud computing was hilarious - yes, really - informative, radicalised and astute. Following Wardley's discussion of uBuntu's drive for standardisation in provision of clouds (to drive innovation and retain Internet freedoms, versus constraint through lack of interoperability or a vendor's ownership of a reference model), Joel Moss (Codaset) and Sanj Matharu (Vodafone) demonstrated the ease of mobile widget (mobile apps to you and me) creation using Vodafone's API; these babies are made in HTML, CSS and JavaScript. There's a one million Euro prize fund for great apps, so get on it.

My morning break is coming to a close. All I can say is am looking forward to Vaynerchuck this evening – fuck yeah!

Wednesday, 17 June 2009

Pretty URLs: Routes in Google App Engine

Pretty URLs are an essential element of web applications. Pretty URLs are helpful to users, influential for SEO and implementations may enhance the beauty (and so the extensibility and maintainability) of a code base. This is superbly achieved in Google App Engine using Rodrigo Moraes' App Engine recipe for URL mapping using Routes.

I discussed in a previous post how I used a basic implementation of GAE's WSGIApplication for Pretty URL mapping. While this approach served my initial needs, it required a lot of extra logic to read params from incoming URLs and did not elegantly handle URLs invoked in an AJAX call (i.e. logic was need in the handler to interpret the URL and delegate to the appropriate action). My goal was to implement a Pretty URL mapping scheme that allowed me to:

-configure URL mappings in one place only
-gracefully pass params on URLs
-invoke actions contained in my handlers

Happily, I stumbled upon Moraes' recipe; it was a snap to follow the very clear directions to import Routes and override the WSGIApplication. Further support from the Routes documentation allowed me to quickly and easily meet all my Pretty URL goals.

All URL mappings are configured in routing.py. Params passed on URLs are discretely mapped and retrieved. For instance this mapping accepts a param named 'id' and hits a handler in views.py called 'MyHandler':

map.connect('handler/:id', controller = 'views:MyHandler')

In views.py, 'id' is picked up as an argument of the get() method:


class MyHandler(ParentHandler):
def get(self, id): ...


How cool is that?! Crisp and clean and no caffeine. It gets better.

I can also map to a handler and an action. This is particularly handy for my api.py, which accepts AJAX requests. With this mapping the correct handler's action is invoked without any messy delegation at the top of my api.py:

map.connect('api/handler/action', controller = 'api:MyHandler', action = 'action')

How great is this? Pretty URLs and cleaner code. Yes, I've added the Routes resources and Moraes' overridden WSGIApplication, but the separation of mapping logic from other aspects of the application pleases me and I believe makes for a more robust code base. Not to mention, I learned a new thing! Thanks Mr Moraes, my URLs got pulchriTUDE!

Tuesday, 24 March 2009

Ada Lovelace Day: my tech heroines

My own career in technology has been inspired by several women in technology and engineering; my tech heroines include my mother, Linda Ziegler, my mother-in-law, Julia Russell, and two former work colleagues, the designer Kat Neville and the Java developer Magz McCarthy.

In some key ways, my own career path reflects my mother's. Linda started her undergraduate degree with the aim of becoming an historian, but as the limited opportunities in this area became more apparent to her, she determined to train as a chemist and worked as a manufacturing chemist in the plating industry. Similarly, I attained a PhD in British History and Economic and Social History and pursued an academic career for some years; at the end of my ESRC Post-Doctoral Fellowship, at which stage I hadn't successfully interviewed for one of the three positions in the nation in my field, I determined that I had to make a change and decided to do a 'conversion course', or a one year Masters in Information Technology. My mother's personal history of moving between a humanities and science discipline has always been part of my understanding of her, and was an important part of my inspiration to 'do what I had to do' in terms of getting the sort of training that would give me access to decent labour opportunities. I should, however, note here that my partner's example - he has a Bachelors in English Language Linguistics and a Masters in Cognitive Science and learned Java 'on the job' during the turn of the century Dot Com Boom - as well as his practical assistance as tutor was further integral to my attaining my MSc in IT with Distinction from Queen Mary, University of London.

Upon completing my MSc, I worked firstly as a Research Assistant in the Computer Science Department of Queen Mary and then as a Java web application developer at Xbridge/Simply Business and then its child company, BView, but it is only over the last year, working for myself building my own application that I've started to feel confident and passionate about working in Internet tech. It had been a difficult transition from a career path I had invested in so heavily and had been deeply passionate for to one I'd entered out of pragmatism.

My flourishing passion and joy for my work has been encouraged in no small way by Julia, Kat and Magz. Jules has a great love of gadgetry and Internet technology and stands out as a 'woman of a certain age' with such an appetite and ability to learn to use the latest tools and gizmos. She's been building web sites since the early days of the web and has recently been recognised as setting a gold standard of best practice for school websites (she works part time at her local primary school). Jules used Google Sites to create a user-friendly and professional site to communicate the school's happenings to the community. Indeed, Jules represents a quirky blend of 'good life hippy' and technologist and her home, nestled in the Scottish Highlands, is aptly called 'the electronic cottage'; much of her work is home-based and includes web administration for an international development organisation and desk top publishing for local authors. Her willingness to investigate new technologies and to understand and advocate the appropriate uses of different Internet medium such as the different uses of blogs versus forums for the benefit of less informed colleagues, is impressive and unique even without considering her demographic. The tenacity and fearlessness with which Julia approaches technology is entirely admirable and never ceases to amaze (and sometimes to shame) me.

At a different end of the women in IT spectrum are Kat and Magz, both of whom are in their twenties and so are my 'juniors'. Working with Kat and Magz helped to push me out of my 'funk'. I'd been indulging, without being fully aware of it, in a rather self-pitying attitude towards working as a technologist after splitting from my first love, history. These two women were full of fire, creativity, enthusiasm and tremendous smarts and helped me wake up to the fact that I was working in an exciting field, full of imaginative, clever and fun people. Kat's amazing adaptability - she was hired as a pure designer but has since developed an impressive set of UI coding skillz to complement her artistry - inspired and impressed the whole development team and taught me to enjoy the challenges of problem-solving, rather than getting so easily down and frustrated. My first memory of Magz was a story of a previous job where she'd worked some impressive Tomcat-clustering magic. I was immensely impressed by this tale and by the confidence, competency and intensity with which she approached every day programming problems. These two women were my first female-developer role models; while I was notoriously 'the first female developer' hired at Xbridge (this is how the CEO once introduced me to a potential hire, much to my horror) and though I worked with an absolutely fantastic group of guys, I was a bit alone in the wilderness until Kat and Magz arrived; they taught me to revel in my work and that, actually, Internet tech is a pretty kick ass place to be!