Articles tagged: ggd

Frogspotter v4 and GGD Afternoon Hack

258 days ago

Today was the second GGD Afternoon Hack. We had six women show up for some Saturday arvo social hacking, with projects ranging from learning Rails, exploring Zend, trying out some Golog style Prolog…and I was working on my JavaScript for frogspotter, following on from the MelHack event last week.

Although frogspotter doesn’t look too different, I managed to get the check boxes and cluster markers working correctly, and do some nice Flickr images (see below). And now you don’t need to zoom in too far before it switches to individual markers.

One problem came from the fact that the library actually had a bug! I was starting to think I was going mad, so I was happy to find it actually was a problem with the library and not with me. The bug report says “fixed in dev” so I tried to find the dev branch so I could reference that file instead of 1.0. I was using http://gmaps-utility-library.googlecode.com/svn/trunk/markerclusterer/1.0/src/markerclusterer.js and from poking around here I just could not find the development code. After some more searching and clicking I realised they had moved their project and the development was now at http://gmaps-utility-library-dev.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js. Rather subtle.

Getting the Flickr images in the pop-ups was really a trial. Note: my approach here was purely naive, to see if I could make it work. I will likely rewrite it so that Python gets and stores the images, to save 30-odd calls to the Flickr API on every page load (!). Doing that will also be far simpler than that JavaScript approach below, so I only put this as a cautionary tale…!

Pop-ups themselves are simple:

var html = '<b>' + spotting.name + '</b><br/><a href="' + url + '">' + spotting.specy + "</a><br/>" ;
marker.openInfoWindowHtml(html);

Querying Flickr was quite easy, once I decided to start using jQuery.

   $.getJSON(
		"http://api.flickr.com/services/rest/?jsoncallback=?",
		{ method : "flickr.photos.search",
			api_key : flickr_key,
			format : "json",
			text : specy,
			sort : "relevance",
			per_page: 1
			},
		callbackwrapper(specy, id)
    );

(“Specy” is my backformed singular of “species”.) So as you can see I just get the first most relevant image from Flickr by giving it the species name to search on. The “$” means the results get stored in some magical jQuery place. NO REALLY.

The problem is…the HTML in the pop-ups is not, AFAIK, a normal part of the page that jQuery might know about. And jQuery really likes to hang off existing stuff in the page rather than just return a string of HTML. So there didn’t seem to be any way I could get a plain old return value back from that json query.

After a bit of thought, I decided that I would put the image HTML in some hidden divs on the page, which the pop-ups could then display. That was it was easy for jQuery to store and also accessible for the pop-up.

So now I have this:

function getFlickrImage(specy) {
    var id = specyToID(specy);
    var html = '<div id="' + id + '"></div>';  //holder for flickr image;
    $("#speciesimages").append(html);
    $("#" + id).hide();
    $.getJSON(
		"http://api.flickr.com/services/rest/?jsoncallback=?",
		{ method : "flickr.photos.search",
			api_key :  flickr_key,
			format : "json",
			text : specy,
			sort : "relevance",
			per_page: 1
			},
		callbackwrapper(specy, id)
    );
}

$(”#foo”) is a cool jQuery short-hand for “find the element with the id foo.” So in my HTML page, I simply added <div id="speciesimages"></div> and with this call, I put one div per species inside it.

specyToID is also very simple:

function specyToID(specy) {
    return specy.replace(" ","-").replace(".","");
}

I spent waaaaaay too long trying to figure out why nothing was happening, not realising that spaces and full stops are not valid in CSS identifiers. Bah! JavaScript accepts whatever you throw at it, why not CSS?! ;)

Now the only mystery left is callbackwrapper(specy, id).

function callbackwrapper(specy, id) {
 return function( data, status) {
    var small_url = "";
    var photo_url = "";
    $.each(data.photos.photo, function(photoIdx, photo) {
	    // Build the thumbnail url
	    small_url = ["http://farm", photo.farm, ".static.flickr.com/", 
			photo.server, "/", photo.id, "_", photo.secret, "_s.jpg"].join("");
	    // Build the photo url
	    photo_url = ["http://www.flickr.com/photos/", 
			photo.owner, "/", photo.id].join("");
	});
    imagehtml = '<a href="' + photo_url + '" target="_blank"><img src="' + small_url + '" width=75 height=75 border=0 /></a>'; 
    $('#' + id).append(imagehtml);
  }
}

(Hm, and I can see now that I don’t even need to pass in specy!)

The each bit above is pretty hacky, because I know I’m only going to get one result. jQuery also really likes those “each” pseudo loop constructions… it was easier to use that than figure out a more accurate syntax.

getJSON is one of jQuery’s AJAX functions. It was a hard lesson for me (and lots of other newbies, from the looks of Google) to remember that the first A in AJAX is asynchronous. So when you call getJSON, you actually call it with three bits: a URL, a set of parameters and values for the URL, and a “callback” function. It seems the callback function will be executed at some time of jQuery’s choosing (hence asynchronous).

The main difficulty with the callback function is that it’s not very straightforward to pass extra data items to it. See the “data” and “status” arguments? I don’t really know how JavaScript or jQuery knows what their values are, but somehow it does. data is what comes back from the getJSON query. But how do I find what my original search term was when it comes time for this function to be executed? Because in my case I want to add a div with an identifier for that.

So there’s this wrapper thing. All I really know is, doing it this way WORKS. Don’t touch the second line. You will regret it.

It seems so simple in the retelling. But figuring this much out was painful. :) You can read all the JavaScript together on Launchpad.

tags: , ,

Comment

---

GGD Afternoon Hack II - Saturday November 14th (date change!)

278 days ago

This much cool, but lots more social.

So a few of months ago Duana and I arranged the first GGD Afternoon Hack. It was lots of fun if not overcrowded, so we want to have another one.

It will run from 1-5pm, at ThoughtWorks, Level 15, 303 Collins St, on Saturday the 7th14th November. We need RSVPs at Facebook or my email.

GGD = Girl Geek Dinner. Since this is in the afternoon there is no dinner, but the gist is, it’s a women focused event. Men can come as the guest of female attendee if they like.

So it’s just BYO laptop, and some project that you’re working on or interested in. Very simple. In case you need ideas, you could poke around the Mashup Australia site and see if you can come up with anything interesting….that competition closes a week after that, but you could go even better… mashup in an afternoon? Why not?!

tags: ,

Comment

---

GGD Afternoon Hack - Sunday 9th August

362 days ago

Did you know that there are LinuxChix meetups prior to the monthly LUV meetings?

Well, now you do.

Next Sunday will be Melbourne’s first GGD Afternoon Hack. If you know any girl geeks who don’t know about Girl Geek Dinners Melbourne, point them this way. (Although I make no promise of dinner with this particular event.)

And before then I’m allegedly going to Canberra and moderating a big chunky sessions at GLAM-WIKI, a Wikimedia Australia event aiming to improve dialogue between the Wikimedia movement and the GLAM sector (galleries, libraries, archives, museums). Gosh.

Oh and I’m still on the look-out for Software Freedom Day speakers!

tags:

Comment

---

MXUG-style GGD recap

373 days ago

So last night we had the first MXUG-style Girl Geek Dinner. (“MXUG-style” = 15 minute talks on a variety of topics. Kind of like a compressed BarCamp.) It was really fun! We had about 11 or 12 women attend, and while I was stressing that people would be no-shows, that was actually a really good size. Big enough not to be awkward but small enough we could still talk as a single group. There was lots of great discussion.

We had three talks – Duana on distributed version control, using Mercurial as an example, me on “the right level of detail” (see slides below), and Jessica with “what has #AmazonFAIL taught us?”. (AmazonFAIL seems a topic that is due a good retrospective – see Metafilter, Neil Gaiman and Clay Shirky for some perspectives. She also mentioned the recent Amazon Kindle/1984 item, which is kind of sequel to the original AmazonFAIL, at least on a PR front.) And Andrea also did a lightning talk on how cool the Acer Linux netbook is. :)

You can find the code for the two things I mention – they are both on Launchpad. mwfeeds (demo at mwfeeds.modernthings.org) and the embryonic beginnings of what will eventually become something called mwsummary, if I get around to it.

Thanks to Duana my co-organiser, and thanks to everyone who showed up. :) We kicked around some ideas about future events, and it looks like we will have one on Sunday 9th August.

tags: ,

Comment

---

MXUG-style Girl Geek Dinner, Melbourne

385 days ago

On Tuesday 21st we are going to hold a MXUG-style” Girl Geek Dinner (GGD) at ThoughtWorks. If you know any girl geeks in Melbourne please pass this invitation on!

  • Date: Tuesday, July 21, 2009
  • Time: 6:00pm – 8:00pm
  • Location: ThoughtWorks, Level 15, 303 Collins St

If you’re on Facebook you can RSVP there, otherwise it would be nice if you comment/email to let me know to expect you.

This is the brainchild of Duana & I. We have both been attending MXUG for the last few months and really like the format. MXUG stands for Melbourne ‘X’ User Group, where the ‘X’ stands for anything — usually some technology that you have recently got into and would like to share your enthusiasm for. (Not that X, although I suppose in theory it could be.) The talks are just 15 minutes, so you can’t get too bored by any one topic, and you generally get to feel extremely bleeding edge. It’s good for the terminally curious. And as a speaker you get to enthuse about something shiny, without having to be an expert on it.

But… not very many women attend. The first MXUG event had two. (Of maybe forty.) The second had one. Recent meetings have been a bit better, and I have suggested it to most of the techie women I know at least once.

So my hope with this event is that more women will get to enjoy the fun that is MXUG, and ultimately that more women feel encouraged to attend MXUG the original.

(I also hope that with a smaller group, it might be possible to discuss a bit more the background of some talks. I cringe whenever I hear a speaker ask, “OK, so does everyone know what X is? No wait, put your hand up if you don’t know what X is.” And then proceed to give a brief explanation of it anyway. Tip: Don’t ask the audience to volunteer their ignorance, the vast majority of people are not that brave. And even if people think they know what X is, often they’ll have a different understanding to you the expert, so just give the brief explanation to put everyone on the same footing and suppress the ritual audience quizzing.)

So! That’s it. Our venue and dinner (!) is kindly sponsored by ThoughtWorks. The usual rule of GGD events is that men may attend as the guest of a woman attendee, and I hope that men will keep in mind what I have said above in choosing whether or not to attend.

We also need a couple more speakers! Please come and share the shiny. We will probably also do some lightning talks (organised on the night), so please drop me a line (comment/email – brianna at modernthings dot org) if you are interested in either of those.

tags: , ,

Comment [2]

---