Guild Wars Community Event: Maragon

March 6th, 2010

Last week the KISS alliance hosted its annual Maragon on Guild Wars. Basically it’s a massive riddle-solving and running event spanning over two long days.

I haven’t even been on Guild Wars for a significant period of time since last year, so this was kind of interesting. In the beginning I thought I’d be at a severe disadvantage due to the time lapse; at least I’d have Dacelo et. al. backing me up though. ;)

In hindsight I didn’t have much to worry about. The group riddles weren’t all that hard – although there were a few “wtf” moments. I mean, how did we manage to derive Sifhalla as the endpoint three times consecutively? :P Some of the runs were definitely crazy though: the two runs in the Realm of Torment and the HM run from Arbor Bay to Gadd’s Encampment.

Good thing as a “PUG” I had the advantage of running in full armour. :P The change to Shadow Form last Thursday and its subsequent unbanment (I officially declare unbanment to be a real word) from the event was a godsend as well. I don’t know if it’d be possible to solo run half of those routes otherwise.

Anyway, some pictures:

Maragon - Deldrimor War Camp

Taking a nice long break after the crazy run from Beacon's Perch to Deldrimor War Camp

Starting the solo riddle for Prophecies.

Crowding around the leader of KISS - James - before the start of the final solo riddle of the event.

All in all it was good fun. I definitely got a lot of running practice over that weekend. :P Now if only I remembered to record one of the more challenging runs on video… And congratulations to Dacelo for winning first prize (Obsidian Armour set) in the Nightfall portion of the event. It was totally worth participating just to hear Tessa’s expression. ;)

I think my brain has fully recovered now.

Random Thought of the Day

February 8th, 2010

Ever had this crazy awesome vision in your head but just can’t get it down into a physical format? It could be an idea for a project, a solution to an issue, whatever. Well, that’s basically the sort of problem I’ve been dealing with for the past few weeks or so.

The problem: create a design for the front page of my site (and perhaps this blog too, in time). The vision: a dark theme, using fantasy and sci-fi material as inspiration (planets, stars, floating islands…). The solution: uhh…?

I call it “creative paralysis”. It’s something similar to writer’s block (which, incidentally, I happen to encounter constantly when I’m writing academic papers and such). I suppose it’s different in that the idea is already at hand; the issue is figuring out what to do with it.

For me, I’m thinking that my lack of experience in Photoshop (and artistic skills in general) is holding me back. I’ll probably end up messing around randomly and hope things work out. Who knows, I might actually learn something in the process…

I probably have a few hundred or so images in my head that I’d love to get on paper. Hell, my lucid dreams can probably form the basis of several short stories. Now, if only the details were a bit clearer… :P

Seriously, if there was a machine that could materialize thoughts into physical matter, I’d venture to say that we’d be living in a rather interesting world. ;) In the meantime, I’d be happy if virtual/augmented reality stuff went mainstream.

Bleach (Episode 256)

February 8th, 2010

…and so the filler continues. I’m not entirely sure I like where this is heading; personally, I thought the last episode would have ended this arc rather nicely. However, I’m willing to give the writers the benefit of the doubt. They did manage to get a pretty intriguing storyline going after all… I’m just hoping that it doesn’t end on a sour note. ;)

You can watch the episode here.

The Hype Surrounding Apple’s iPad

January 28th, 2010

Geez, Apple’s hype machine is ridiculous. Pretty much every other news story and tweet I’ve been reading had some sort of reference to the iPad. Just take a look at TechCrunch and Techmeme over the last day and a bit – I’m hoping no company was stupid enough to release anything that day. :P

Building a Web Scraper Using JavaScript and jQuery

January 25th, 2010

When building web applications, sometimes there’s a need to fetch data from other sources. Perhaps you’re building a custom RSS feed of news items based on your interests or you want to aggregate data from several sites. In any case, it’s not always possible to do this elegantly; you may not have direct access to the raw data and an existing API may not exist. For these situations there’s one general (albeit fragile) solution: manually parse the end result when a page is loaded in a browser.

There are many different ways to build a web scraper. A server-side language such as PHP will have a much easier time as there are less limitations and existing libraries (such as cURL) to accomplish the task. I’ll be using JavaScript (with the jQuery library), however, as I want a standalone client independent of server technology.

Let’s start with a random snippet of code:

1
2
3
4
5
6
7
8
9
10
11
12
function fetchPage(url) {
    $.ajax({
        type: "GET",
        url: url,
        error: function(request, status) {
            alert('Error fetching ' + url);
        },
        success: function(data) {
            parse(data.responseText);
        }
    });
}

The above function attempts to make an AJAX call to a specified web page, fetch the HTML of said page and pass it to a parsing function. Simple enough, right?

Unfortunately there’s a little problem with this. Client-side programming languages have to deal with something called the same origin policy which basically restricts scripts from accessing external domains. From a security standpoint this is obviously a good thing; however it can be a headache for web app. developers (indeed, there are ideas such as the origin HTTP header to solve this). (The following bit can be ignored if the scraper is on the same domain as the data source – but in such a case why is said scraper even necessary?)

In this case, there are a couple of solutions (that I can think of). Both of them take advantage of the fact that JavaScript can read JSON even if it is located on a different domain.

  • The first one is writing a complementary server-side script that takes a few arguments (such as the target URL), makes the call, parses the result into JSON format and passes it back to the calling function. It’s a simple idea, but I never really liked it because it introduced a major dependency (which, in my case, can be a pain to deal with). However, it’s definitely a viable solution which works extremely well.
  • The second is using an existing system such as Yahoo’s YQL to fetch the required data and return it in a structured form. This is the method that I’ll be using.

YQL is an interesting little beast. From their site:

The Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL, apps run faster with fewer lines of code and a smaller network footprint.

I haven’t had too much time to look into it so I do what all programmers do: Google the living crap out of a problem to find a solution. :P In this case, Chris Heilmann has a great post on how to load external content via. various methods including YQL. To simplify things, James Padolsey wrote a plugin that detects an external AJAX call and passes it to YQL automatically.

Anyway, that solves the problem of fetching data from an external source. All that’s left is extracting the relevant pieces for whatever application is being built. Consider the following example:

1
2
3
function parse(data) {
    alert($(data).find("h1").text());
}

The parse() function takes the responseText data from the earlier fetchPage() function and then proceeds to pick at it slowly and painfully. What’s really cool about it is that pretty much all of jQuery’s selectors can be used to select relevant data. In the above case, I’m trying to extract text inside the first <h1> tag found on a page and outputting it as an alert to the browser. Obviously there are more complex uses for this but they are outside the scope of this post. :P

And…that’s it! :D Those two code blocks combined pretty much handles all of the grunt-work in extracting data from external sources. Again, this is a rather fragile solution – it can break if the target page’s HTML changes (one possible solution is to pick unique identifiers or classes). In addition, some sites may have restrictions on their data – but I’m sure everyone reads those long-winded documents. ;)

“What’s Your Fastest Text Input Tool?”

January 24th, 2010

Here’s an interesting post on Lifehacker: What’s Your Fastest Text Input Tool?.

I’ve been using full-sized keyboards for a *very* long time now so that blows everything else out of the water for me. When I’m motivated I can type at speeds exceeding 100 words per minute, although that’s typically not necessary with the stuff I do.

I’d rank pen and paper as second. It’s pretty much a necessity in university when you’re taking down notes and whatnot. Although some people can get away with using laptops in class, I find that it’s extremely hard to copy out diagrams and mathematical equations. Perhaps this is some indication that I should learn LaTeX or something? :P

Next up would probably be a close race between my Wacom tablet (using Window’s handwriting recognition software) and my iPod Touch. I’m still rather slow at both, although that might just be because of a lack of practice.

In last place is a standard phone with a three-letters-per-number keypad. Yeah. I don’t use my phone very often and I text even less. :P

Fairy Tail (Chapter 167)

January 19th, 2010

Looks like the latest chapter of Fairy Tail came out a day or so ago (geez, MangaStream is ridiculously fast when it comes to releasing stuff – it didn’t appear on One Manga until much later).

Links:

Anyway, I really like how Gajeel is desperately looking for a cat. He must have gotten pwned pretty badly with all those scratches on his face. ;) Something tells me there’s more to them than meets the eye; the conversation between Charle and Happy raises a few bells.

We see Mystogan reveal some of his history with Wendy as well. I’m pretty sure this is the first time he’s done so in the series. :P It kind of reduces the impact of Gildarts’ arrival in the previous chapter though.

Speaking of Gildarts, I find it interesting to see that he has Ivan Deyar listed under “dislikes” on his guild card at the beginning of the chapter. There must have been some interesting things going on between them during their time together at Fairy Tail.

It looks like we’re in for a new plot arc as well, although it seems kind of sudden. What’s with this “Anima” that Mystogan was talking about and how can it destroy Magnolia before everyone can escape? Eh, we’ll see…

The “A” in “AJAX”

January 16th, 2010

Consider the following code snippet using JavaScript (with the jQuery library):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
function blah() {
    var pagedata;
    $.ajax({
        type: "GET",
        url: "test.php",
        error: function(request, error) {
            alert("Error: " + error);
        },
        success: function(data) {
            pagedata = data;
        }
    });
    return pagedata;
}

Looks reasonable enough. The purpose of the function is to make a GET request to some page (“test.php” in this case), store the result in a temporary variable and return said variable (of type string).

However, it turns out that this doesn’t work too well. When the function is called, chances are pretty good that the returned string is empty. Why? At first I thought it was because of some weird variable scoping rules in JavaScript, but that didn’t really make too much sense.

It turns out that I forgot about the “A” in “AJAX” (i.e. Asynchronous JavaScript and XML). The function above doesn’t execute in a top-bottom manner; the $.ajax() call is made in parallel with the rest of the script. Generally this isn’t too much of a problem (indeed, it’s a valued property by those making web applications) but in this case it isn’t what I want.

Anyway, there’s a simple solution to this. What I want to do is make the call synchronous with the rest of the script. Fortunately, jQuery makes this extremely easy in the $.ajax() method by providing an option (async: false) to turn this off. Thus:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
function blah() {
    var pagedata;
    $.ajax({
        async: false,
        type: "GET",
        url: "test.php",
        error: function(request, error) {
            alert("Error: " + error);
        },
        success: function(data) {
            pagedata = data;
        }
    });
    return pagedata;
}

This locks up the browser while the call is being made so it’s probably not the best solution. It shouldn’t matter too much with small requests though (or requests made with the user’s consent via. the UI or something).

Avatar

January 11th, 2010

Throughout the last month or so, I’ve been hearing a lot about James Cameron’s Avatar (words such as “revolutionizing”, “awesomesauce”, “epic”, etc. come to mind). So I finally got to see it last Friday at West Edmonton Mall’s Scotiabank Theatre. I’d say the movie lives up to its hype. :P

The first thing I found out was that the entire movie is in 3-D. I was never a big fan of wearing those funky glasses (and indeed, they’re pretty annoying for anyone wearing actual glasses) but it’s a minor issue for me. Perhaps one day we’ll have true 3-D in the theatres (think holo-projectors). I can dream, right?

Anyway, the movie starts off with Jake Sully – a paraplegic (former) marine – joining the avatar program on Pandora, an Earth-like moon with its own unique environment. The goal of the program is to improve relations with Pandora’s natives so that a human mining operation can continue in peace. Throughout the movie we see Jake slowly preferring his avatar’s lifestyle to his own (Jake’s avatar is a biologically-engineered version of one of the natives, the Na’vi). One major recurring theme is how damaging human tendencies can be on an environment (in this case, making war on the natural inhabitants all in the name of profit); in this aspect I was drawing comparisons between Avatar and Princess Mononoke.

The visuals and animation were mind-blowing. I expected nothing less from a movie whose official budget of $237M makes it one of the most expensive ever made. The 3-D aspect was interesting and really brought out Pandora’s natural beauty; throughout the movie the atmosphere seemed realistic, the native species lifelike. I’d say Avatar is one of the few movies that can truly be comparable to a high fantasy novel. It definitely had an impact on my imagination in any case. ;)

Most of the major characters were well-developed. They each had their own beliefs and act accordingly no matter the consequences.  Trudy – a fighter pilot – best summarizes this when she abandons the first human-Na’vi conflict with a “fuck this” and subsequently aids Jake and the rest of the avatar team in the second. It was very possible to relate to them (which adds to the emotional factor when some of them die).

All in all, I’d say Avatar is one of those movies that everyone should watch. Heck, I wouldn’t mind watching it a second time if I can find an IMAX theatre near me. ;)

A New Moon in 2012

December 31st, 2009

I had the (dubious?) pleasure of watching New Moon and 2012 over the last week at West Edmonton Mall’s Scotiabank Theatre. Here are my thoughts on those two movies… :P

Let’s start with New Moon. First of all, I haven’t read Meyer’s books so I can’t really do a fair comparison between the two. In general I much prefer doing the readings since a lot of details tend to get lost in translation – there’s only so much that can fit in a 2-3 hour movie! I did attend an early screening of Twilight last year however (in which my enjoyment of the movie was negatively impacted by rabid fans screaming in my ears).

Bella (as a character) is uninspiring. To be honest, I still don’t have a clue on how she became the love interest of two other characters. She has next-to-zero hobbies, is consistently gloomy and is melodramatic. For someone nearing adulthood, she’s emotionally weak (well past dangerous territory). It reminds me of those classical fairy tales in which we have a damsel-in-distress rescued by some random knight-in-shining-armour. Haven’t we gotten past those stereotypical views already?

Similar to Twilight, most of the supporting characters contributed little to the plot. They could pretty much be pulled out of the movie without seriously affecting the outcome of the story. That’s kind of disappointing since it really makes them seem two-dimensional. Of course, this is probably an artifact of the movie translation; it’s probably a lot better in the books (someone please tell me that it is). :P Some mini-arcs seem kind of redundant as well. For example, what purpose did sending Charlie et al. wolf hunting serve? I was hoping for a twist – that a heavily guarded secret would be leaked to the public. Unfortunately, nope. :(

As a whole, I thought New Moon was relatively predictable and slow. In fact, I made it almost like a game, guessing the chain of events as they unfolded (and then there were some – like Jacob being a werewolf – that were too ridiculously obvious to not get at first sight). Perhaps it’s just the fact that I have no real interest in the romantic genre, but there’s a problem when my sister (who is clearly in the crosshairs of the series’ target audience) picks up on some of these issues. :P I did enjoy the action and computer animated scenes though, few and far between as they were; Jacob in wolf form is cool. ;)

Moving on. 2012 is one  of those oh-my-gawd-the-end-is-near-please-help-ahhh apocalyptic movies in which the world order collapses and is reborn in a new light. The basis of  the movie is the 2012 phenomenon which is essentially a conglomerate of beliefs that cataclysmic events will happen throughout that year (more details can be found on Wikipedia). Though the general theme has been recycled millions of times, the movie still provides ample entertainment and even *gasp* some things think about.

I thought the beginning was rather fragmented and confusing especially since it glossed over three years. It did provide a quick introduction to all the main characters though (as well as why humanity was screwed) so I’m willing to let that slide. We have Jackson (a writer-turned-driver) as the unlikely protagonist of the story along with his children (Noah and Lilly) and his divorced wife Kate. Gordon – Kate’s current boyfriend – joins the ride as the five dodge calamity after calamity. Geologist Adrian Helmsley becomes the focal character in providing a lot of background information on the impending event.

The action in the movie was as expected: pure awesome. The computer animation might have been overdone but it was still exciting to watch – especially if you just want to switch off your brain and see stuff explode. :P Speaking of which, I still haven’t watched the latest Transformers movie…

Scientific explanations were reasonably adequate for those with a very basic education in geology and astronomy (i.e. knowledge of fault lines, magnetic fields, solar flares). I suspect those true geologists and astronomists would object however. :P It’s about as close as one can get when dealing with a topic with few, if any, factual basis.

Character development was alright for a movie in this genre. I liked how Noah – initially portrayed as a stubborn, pessimistic kid – gradually accepted Jackson as the movie progressed. Many of the more selfish and arrogant characters like Yuri and Tamara displayed compassion in strenuous situations. It’s surprising how much people can change in a short period of time…

In a nutshell, the movie attempts to show collective human behaviour in the face of impending danger. I think the other message it was trying to convey is how woefully unprepared we are should we face disaster. Given, for example, how Hurricane Katrina was handled in the U.S.,  that wouldn’t be too much of a stretch. Overall, I thought 2012 was decent entertainment (me being the ooh-stuff-is-blowing-up type). :D