Friday, July 23, 2010

RegLex.js

0 comments
I've released a Regular Expressions based Lexer for JavaScript at github.  The script is extremely easy to use and requires absolutely no dependencies.  To give it a spin one must simply download the code.

To get started define your tokens:
var tokens = {
    Name: {
        name: "NAME",
        expression: /[A-Za-z][A-Za-z0-9]*/
    },
    String: {
        name: "STRING",
        expression: /\"[^\"]*\"/
    },
    Number: {
        name: "NUMBER",
        expression: /0|[1-9][0-9]*/
    },
    Equals: {
        name: "EQUALS",
        expression: /=/
    },
    WhiteSpace: {
        name: "WHITESPACE",
        expression: /\s/
    }
};
Create the grammar:
var grammar = $g(tokens);
Perform the lexical analysis on a string (this will throw an error if the string violates the lexicon):
var lts = $lex('test = 0', $g(tokens)); //NAME WS EQUALS WS NUMBER
Confirm your suspicions:
for (var i = 0; i < lts.length; i++) {
    alert('Token: ' + lts[i].token + ', Value: ' + lts[i].value);
}

Lexical analysis is your oyster! Go forth, and please make sure to mention any issues you might find at github.

Thursday, July 22, 2010

Wow.js

0 comments
I recently completed a preliminary JavaScript version of a World of Warcraft Armory client. The project is currently being hosted at github and is therefore completely open source.  To get started one needs only to download the client script, and its dependency jQuery. It really is simple...

To create a client object:
var client = new Wow.Armory.Client();
To retrieve the character sheet:
client.getCharacterSheet({
  character: 'Wetall',
  realm: 'Dunemaul',
  success: function(character, s, xhr) {
    /* do something with the JSON version of the character sheet here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
To retrieve item information:
client.getItemInfo({
  itemId: 22630,
  success: function(item, s, xhr) {
    /* do something with the JSON version of the item here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
To do a general search query:
client.search({
  searchType: Wow.Armory.SearchType.Characters, /* as well as All, Items, and Guilds */
  searchQuery: 'Calox', /* this parameter is optional! */
  success: function(results, s, xhr) {
    /* do something with the JSON results here */
  },
  failure: function(xhr, s, e) {
    /* we failed somewhere along the line with the request */
  }
});
This is merely scratching the surface! With serious usage the mileage may vary, but should any serious problems arise please report them at github so that I can do my best to rectify the situation.

Thursday, June 10, 2010

Media Melodrama

0 comments
It is strange that when things go wrong in an environment or situation fraught with potentiality for disaster, people suddenly take heed, or they make the poor transgressor the conduit of unfettered disgust and outrage. Two particular cases demonstrating both sides of this issue have occurred recently: the unilateral backlash against British Petroleum (BP) for the Deepwater Horizon spill, and the consternation of the public and media at large that something can go horribly wrong at sea, and a 16 year old American girl can be swallowed whole in the Indian Ocean.

What makes BP unique from any other oil company in the history of humanity? Society has implicitly condoned the behavior of petroleum companies for years, and it is hypocritical and fragrantly disingenuous to suddenly be surprised by this kind of disaster, and the peripheral managerial atrocities that have been revealed as a result of the crisis. This is not the exception, this is the rule, and we all knew that. To pretend otherwise is a disgusting mockery, and an insult to intelligence.

The second case is a bit different. A 16 year old is determined to circumnavigate the world nonstop by herself, and in so doing become the youngest person to make the journey. She ends up going missing somewhere in the Indian Ocean. A frantic search begins. There is but one question: what did you expect? To embark on a contest against the forces of nature is to knowingly wager one’s life. It seems that there is a common psychological defense mechanism that functions as a risk panacea for all parties involved. Nobody wants to believe that when they (or their loved one) are going to climb a mountain, or sail around the world by themselves, that they could die; instead, they trick themselves with a nourishing illusion conjured by selfish stupidity (ambition). Sometimes they go missing: it is the price they pay.

As a society we need to stop playing dumb. Turning people and businesses into melodramatic heroes and villains is juvenile. Is America, and the world at large, that thirsty for drama? Do we need an elaborate staging of things that aren't surprising in the slightest? Probably not.

Monday, April 05, 2010

Void

0 comments
What can be said about believing in nothing?  It is not so much believing in nothing at all, as it is believing in the absence of any cosmic order or underlying meaning.  To fully accept that there is no larger system, no divinity, no galactic safety net, is perhaps the most difficult thing of all.

Man has set out to know everything, and not just to know everything, but to understand why everything, because to understand why is to construct a sense of order from nothing.  Determinations and classification become the only way in which we, as a species, can hope to find evidence towards some universal thread of truth, some nourishing example from which to draw the "Big Picture".  We have presumed, from quite early on that there has to be some reason that we are here; some reason that we are careening in the vast vacuum of space.  Perhaps all for not.

To believe in discord, or the indeterministic cosmic throwing of dice, is no easy feat simply because it is unpalatable to the intellect.  Accepting a world, let alone an entire universe, of chaos is to disavow nearly everything that makes us human.  Or so we thought.  Without meaning beyond mere existence there is no common tie between strangers, except the larger, subconscious and singular goal to reign supreme above all order of beast, big or small.  Yet, to even consider such a thing, causes serious trepidation, and an overwhelming sense of moral panic.  It is this sense of dread that we have sought to mitigate in idiom, and through religion, in philosophy, and art; but we can't ever succeed.

Change is the only thing certain in this world.  Humanity can continue to try and construct some meaning from the creatures and events that abound, but what can we ever really know?  How can we ever get beyond random chance?  How will we ever find more than nothing?  How can we expect to escape the fate of all those before us who fell unto time?

We can't.

Tuesday, February 16, 2010

Economic Equivocation

0 comments
There needs to be a sea change in the way that the American media discusses current economic issues. The propensity towards equivocation is apparently too great to resist for most journalists and commentators, as they show no issue or qualm with their current coverage and behavior. This attitude and brand of reporting is pernicious in that it oversimplifies the complexity of American macroeconomics, and it asserts a semantic equalization of all historical economic issues with those current, without giving credence to the environment and context that precipitated the past events.

The concrete example which started this trivial line of thought was the cursory way in which Joel Kotkin, a guest today on KUOWs “The Conversation,” dismissed the reality of the recent housing market collapse, and the pecuniary issues that followed in its wake. Kotkin implies rather magically, and this is paraphrasing, that America “overcomes”, when he says
“[America] experienced a lull in the 70s, but we came back in the 80s, and we experienced more economic hardship in the 90s, but we rebounded from that as well.”
The problem, however, is that in providing no context for the economic conditions he is setting them all equal, which has significant implications to understanding the events for any interested party. Additionally, the use of vague terms—like “came back” and “bad”, which would be better served in sports commentary—underscores the innate and bizarre need to oversimplify problems of this magnitude.

The bottom line is that without acknowledging the reality of an economic crisis you work to poison the national debate with the underdeveloped arguments spewing from your pen and mouth. The term “caveat emptor” seems finally adequate to be extended to intellectual discourse in this most contentious time.

Monday, December 21, 2009

Ramifications of Technology on Plot

0 comments
While watching this film, in the wake of the release of this montage—which satirizes the lazy horror writer’s plot device—there was one question that was begging to be asked. What happens to common plot devices and narratives when communication technology becomes sufficiently advanced and ubiquitous? How does a writer navigate the reality of an increasingly connected world, when trying to spring the perfect trap for an unwitting victim of their own creation?

The truth of the matter is that this singularity has likely already arrived. At this moment, there are myriad devices that fit in merely a pocket that would manage to quickly thwart any burgeoning horror writer’s attempt at killing off their adolescent cast. The only way out of this little plot problem is the introduction of technological failure (that is, some magic force that prevents communication from functioning correctly for the sake of story, effectively creating an artistic sandbox). This is becoming harder and harder to reconcile as an audience.

How can any member of the modernized world take these threats seriously? There are so many platforms for instant communication, and so many devices that provide near perfect geo-location, that the pill becomes too unbearable (and honestly, offensive) to swallow. From this point forward, freedom is just a tweet away, whether writers are willing to accept it or not.

UPDATE (2/15/2010): A tangential mention of the ramification of technology on plot (different from the examples above, as it points out the lazy application of technology as conduit to magic plot advancement, instead of reinforcement).
"We seek on the Internet because that’s where we find. In the tween movie Twilight, heroine Bella discovers that her boyfriend Edward is a vampire by consulting a website with a convenient link to supernatural occurrences in her very own tiny town. The Internet is here collectively written, but perfectly tailored to exactly her individual needs. It is not the wizened woman in the house down the road that holds the truth to Edward’s identity, but an anonymous and multiply sourced repository of lore. A silent film would have cut to an intertitle to explain a secret; a Thirties noir would have spun newspaper headlines in circles to leap forward in time; a Seventies sci-fi flick would have introduced a wacky professor or scientist to deliver a piece of arcana. Today a quick cut to Google delivers the missing link. It advances the plot." Christine Smallwood at The Baffler
Is this the role technology should play in narrative?

Thursday, December 10, 2009

On The Conclusions of Objectivity

0 comments
After searching long and hard for the most egregious distortion of facts on Conservapedia—the last refuge for those unhappy with the academic version of history, and whom search only for “truth”—there seemed to be one article that stood above the rest as a monument to human misunderstanding, and a paragon of desperation. That article was on the subject of evolution.

One might think that given the nature of the site (an encyclopedia purportedly documenting reality), long winded diatribes, and counter arguments would be deemed inappropriate and unacceptable—as they obviously work towards undermining the perception of a topic, and not towards creating the definition. This type of dialogue does not convey anything but bias by virtue of its nature! And this is the type of dialogue that one can expect from any politically charged topic (see abortion, once we are finished here) on the web site.

In addition to the false premise of Conservapedia (that all articles share), the fundamental problem with the article associated with evolution, is that it functions solely to progress the agenda of the Intelligent Design movement in convincing people that Creationism, and tangential disciplines, are science. Science is the antithesis of religion: it is not dogmatic and it is not sacrosanct. Theories can be changed. Scripture cannot (unless the religion is still breathing).

How is Intelligent Design scrutable? It isn't, and that is why it is not science, and why it should never be muttered in the same breath as Darwin’s theory (do you hear that Ben Stein?). Nobody said Darwin has it perfectly correct, we just said he has the best supported argument in the confines of the Scientific Method at this time. And even still, the theory does not preclude the existence of a God (yes, that is true, and they can and should coexist)!

Have your cake and eat it too, or just stop masquerading as science and truth!