Sunday, June 26, 2011

BYBS: Cheeseburger

Image from TheCulinaryGeek Flickr
In keeping with a simple "things in life" theme (read, out of ideas), this posting is about the joy of eating Gelato while watching the river.  Hmmm.  OK, so I don't read my own titles.  This post is actually about the joy of eating a cheeseburger while looking at the river.

Image by Angela de Março
Well, I really did have some Gelato (strawberry, and yes I realize that this is not straberry) while watching a river, but I also had a cheeseburger before that.  So the cheeseburger comes first.  Before desert.  Because I have to finish my dinner before I can have desert.

Yes, no high moral ideas or secret messages in this posting.  Unless you count the gnome that's hiding behind the gelato...

Sunday, June 19, 2011

BYBS: Cat Rambo/Fantasy Magazine

Image from Fantasy Magazine

This week's BYBS goes to (wait for it!) Fantasy Magazine and in particular a short story called the "Immortality Game" by Cat Rambo.  Yes, that's the name that she apparently goes by.  No, don't ask me.  What does someone who calls themselves "Cat Rambo" look like, you ask?  Well, here is a pic from her site:

Image from Cat Rambo's site.

Hair color aside, I am a fan of Cat Rambo's work. "The Immortality Game" is about a group of sorta-immortals who...well, I don't want to ruin it for you.  Rest assured that the story is worth listening to.  And contains a really cool idea.  Which I thought of first.  Well, actually I didn't, but if I had the powers that the characters in the story did, then I could actually go back in time and come up with the idea first.  But now I'm giving too much of the story away.

Cat (do you mind if I call you "Cat?") manages to write about topics that are anti-PC and yet remain interesting.  Another example of her work includes "I'll Gnaw Your Bones, the Manticore Said" (and no, I'm not sure where to put the quotes for a quote withing a title).

Fantasy Magazine is another podcast I listen to - specializing in (you guess it!) the fantasy genre.  "The Devil in Gaylord's Creek" was the month before and was also a good story.  So check em out.

Sunday, June 12, 2011

BYBS: SMOSH

They make such a cute couple (image from Smosh.com)

Smosh, specifically smosh.com, is a couple of guys who make hilarious videos such as "Vader and Me."  The first video of theirs that I saw was "Mortal Kombat," a strange and yet silly spoof of an old video game.  My all time favorite is probably their "Pokemon" video which spoofs (you guessed it) Pokemon.

But their skill does not end there - they also do just plain silly videos.  For example: "That Damn Yard Sale."  To top things off they also have a funny and yet strange commentary on the rest of site "Smosh Pit Weekly" featuring "Mari Atari."

Mari Atari pic from her Twitter feed.
A Yoda hat?!  Be still my beating heart!

The humor is a bit on the crude side, but for me that's a bonus.  Check it out.

Sunday, June 05, 2011

BYBS: Stupid JavaScript Tricks

This week I learned something about working with JavaScript that made me happy enough that I'm going to blog about it.

Rather than trying to explain this in some way that makes sense, I'm going to use the short version.  This will not confuse any readers because a) I don't have any and b) anyone who stumbles upon this blog must already be a JavaScript gawd.

OK, so suppose you are using Ajax to grab a list of people and you want to shove them in a table, along with a button that initiates some action that annoys said person.  Well, one way that might seem plausible is to use the following:

var button = document.createElement("input");
button.type = "button";
button.value="Annoy";
button.onclick = "annoyPerson(person.id)";

Unfortunately, this does not work, since JavaScript really wants to get a function for Christmas when you pass it the value for onclick.  OK, how about this:

button.onclick = function (id) {
    annoyPerson(id);
};

This doesn't work either because onclick will not pass any parameters to the function it calls.  So how about:

button.onclick = function() {
    annoyPerson(person.id);
};

This sort of works, in that it will call annoyPerson with an ID that is taken from the list that you are iterating over, but it will be the same value for all the buttons.  This means that you might click the button to annoy Fred only to annoy Mary instead.  Very embarrassing.

OK, so how do you pass in the correct ID?  There are two ways that I found out about.  Probably the preferred way is to use the following:

button.setAttribute("data-person-id", person.id);
button.onclick = function() {
    annoyPerson(this.getAttribute("data-person-id"));
};

The way that I thought was especially kewl, however, was the following:

button.onclick = function(id) {
    return function() {
        annoyPerson(id);
    }
}(person.id);

This wonky mess of JavaScript defines an "anonymous" function that returns another function.  The outer anonymous function is then immediately called (via the (person.id) bit at the end).  This binds the current value for person.id to the id parameter, ensuring that the inner anonymous function gets a different value for each iteration of the loop, rather than the last value the iterator held.

If this seems long-winded and impossible to follow, it's because it is actually long-winded and impossible to follow.  JavaScript is a strange and annoying language in my not-so humble opinion, and it often times feels like voodoo when you get something to actually work.

Nevertheless, getting this to work was a nice point in my week.  Which just gives people another indication of how pathetic my life is.