Infinity Pool Alpha

Posted in Projects, Ruby on April 29th, 2009 by Alan Hietala – 1 Comment

If you play the table top game infinity and want to help me with some feedback on the army builder I am creating please shoot me an email (alan -dot- hietala -at- gmail.com). The version that is running now is as bare bones as it gets right now but it support army validation, a single view that contains all the important information about your army.

I hope to add in a print view either tomorrow or the day after. I only have a small bit of test data loaded into the system right now so you will only be able to add 2 ariadna units to your lists. I will get the rest of the data loaded in the next day or so.

Feel free to send feedback to my email or leave a note on the blog post. Thanks for the help!

check it out at http://infinitypool.failedsave.com.

create an account to get started. These will be wiped periodically since it is still under heavy development.

Known bugs. Removing an item from the list does not work. will fix tonight
you can add 11 units to a combat group. it should be 10.

New PlanetEye Features

Posted in Javascript, PlanetEye on April 2nd, 2009 by Alan Hietala – Be the first to comment

We’ve been hard at work at PlanetEye. I’m really excited about the new embedable travelpack maps. The speed that I was able to get this up and running in Google Maps really speaks to the flexibility of their API.

We’ve got out technology working in Google maps now too so we can be entirely map platform independent. Over the next iteration of the map we want to integrate the notes feature from our standard travelpacks to give some descriptive context to each item.

There is a lot of potential for embedable maps especially those that handle grouping of items as elegantly as PlanetEye does.

If you want to get your own map simply create a travelpack and hit the embed button and copy the code into your website or blog.

Canada Bans British MP

Posted in Uncategorized on March 20th, 2009 by Alan Hietala – 1 Comment

Canada has banned a British MP from entering the country due to his anti-war stance. Sure his opinions may be unsavory to some but the last I heard this wasn’t a ban-hammerable offense.

Get it together Canada, we used to be a nation of peace keepers, now we bar our allies MP’s from entering our own country due to their political convictions? This was a decision passed down by our Minister of Citizenship and Immigration, Jason Kenney. Feel free to let him know what you think.

Destruction of Urban Farm in LA

Posted in Uncategorized on March 17th, 2009 by Alan Hietala – Be the first to comment

In 2006 the city of LA destroyed a community farm on land that was donated to the community after the Rodney King riots. Now this land has been sold to developers and over 350 gardens were destroyed that helped feed some extremely poor people. These gardens also provided an outlet for youth, something to believe in, and now there is nothing, a barren wasteland.

No one in the community was consulted and no alternatives proposed. Since these people were extremely poor, they just didn’t matter. What a sad reflection of the society we live in today.

Thru-You

Posted in music on March 11th, 2009 by Alan Hietala – 1 Comment

Ran across this today while browsing reddit waiting for our new branch to check out. Was totally blown away by it. Thru-you is a full album created entirely from cut up youtube videos. What an inspiring piece of work.
here’s just one of the tracks from the project. To fully appreciate it you need to visit the site though.

Send Direct Message – Twitter4r

Posted in Ruby, Twitter, Uncategorized on February 12th, 2009 by Alan Hietala – Be the first to comment

I’ve been getting a lot of incoming search traffic looking for how to send a direct message using Twitter4r. Firstly RTFM if you can’t do that…

require('rubygems')
gem('twitter4r', '0.3.0')
require('twitter')
require('time')
 
login = "xxxxxx";
password = "xxxxxx";
 
#make the connection
 
twitter = Twitter::Client.new(:login =>; login, :password =>; password);
 
status = Twitter::Message.create(
   :text => 'I can\'t read RDOC',
   :receipient => 'anotherlogin',
   :client => twitter)

Hope that helps.

Writing Mantainable AJAX Javascript

Posted in Javascript on February 11th, 2009 by Alan Hietala – Be the first to comment

Whether you are using the regular xmlhttprequest method or a library like jQuery for ajax, you are going to want to keep those calls as generic as possible. Chances are you’ll end up using them somewhere else in your code. By creating all of your ajax calls generically, you are able to create a concise library that is easily used throughout your site.

Lets look at how this can be achieved. Typically any ajax request no matter what library you use has the connection information, a success handler and a failure handler passed in somehow. Lets look at the following (not so great) code as it demonstrates the bare minimum need to implement an ajax call.

function getDataById(id){
     //spawn the ajax call in library of your choice
     doAjax(connectionInfo,getDataByIdSuccess,getDataByIdFailure);
}
/**
 * Success handler function
*/
function getDataByIdSuccess(result){
  //do something specific with the result
 
}
/**
 * Failure handler function
*/
function getDataByIdFailure(result){
   //handle the failure case
}

In this code our ajax function getDataById has its success and failure blocks hardcoded into it. An improvement would be to pass those in as parameters to the now more generic ajax call.

//call the ajax call
getDataById(1,getDataByIdSuccess,getDataByIdFailure);
 
function getDataById(id,success,failure){
     //spawn the ajax call in library of your choice
     doAjax(connectionInfo,success,failure);
}
/**
 * Success handler function
*/
function getDataByIdSuccess(result){
  //do something specific with the result
 
}
/**
 * Failure handler function
*/
function getDataByIdFailure(result){
   //handle the failure case
}

This goes a long way towards making the success method generic. For many applications this is enough but this solution lacks the ability to pass additional parameters to the success/failure function. Sure we could use global variable to do this, but since this is asynchronous, unless we implement some sort of locking mechanism, we can’t guarantee the values will still be the same when we go to read them. To get around this we have our handler functions accept an args object. Obviously your success function needs to produce different results depending on the arguments, otherwise it is fine to hard code those args into the success function itself.

//call the ajax call
argObject = new Object();
argObject.containerDiv = "foo";
argObject.linkDiv ="bar";
getDataById(1,getDataByIdSuccess,getDataByIdFailure,argObject);
 
function getDataById(id,success,failure,argObject){
     //spawn the ajax call in library of your choice
     doAjax(connectionInfo,function(result){
 
                                           success(result,argObject);
                                        }
                                        ,function(result){
 
                                           failure(result,argObject);
                                        });
              success,failure);
}
/**
 * Success handler function
*/
function getDataByIdSuccess(result,args){
  //do something specific with the result and use the passed arguments
 var container =  args.containerDiv;
 var link = args.linkDiv;
document.getElementById(container).innerHTML = "
	<li>"+result.title+"</li>
";
 
}
/**
 * Failure handler function
*/
function getDataByIdFailure(result,args){
   //handle the failure case
}

Using this method you can maintain a single generic ajax call that takes in the handler functions and additional parameters to pass along without having to resort to a global variable and the problems this introduces.

This method makes it very easy for you to separate your presentation code from your data code which will make your system easier to maintain.

Backwards or Forwards?

Posted in Uncategorized on February 7th, 2009 by Alan Hietala – Be the first to comment

clashI was listening to the radio today and was reminded of one of my favourite clash songs. White riot has this fantastic lyric in it that says:

Are you taking over
or are you taking orders?
Are you going backwards
Or are you going forward

Tom Morello from Rage Against the Machine told a story about how he stuck those lyrics on his fridge in college and asked himself those questions every day when he looked at it. I don’t think I ever found my lyrics to stick to the fridge, but Tom, I think I might borrow yours.

JQuery Annoyances – Overriding “this”

Posted in Javascript on January 27th, 2009 by Alan Hietala – Be the first to comment

I’ve been working on a simple javascript MVC pattern that uses jQuery in the view code and have come across an interesting side effect of using jQuery and javascript objects.

MyView(clickCallback){
    this.clickCallback = clickCallback; //callback function in the controller
    this.renderView = function(){
         $("#somedivid").click(function(){
            //do something
            this.clickCallback(); // unfortunately jQuery overrides this
                                           //so this doesn't work
        });
    }
}

In order to work around this problem we have to assign the callback method to a local variable that is accessible from within the jQuery block.

MyView(clickCallback){
    this.clickCallback = clickCallback; //callback function in the controller
    this.renderView = function(){
        var clCallback = this.clickCallback;
         //start the jquery section
         $("#somedivid").click(function(){
            //do something
            clCallback(); // this will now call the appropriate callback
        });
    }
}

Since the local variable contains the callback we can now work around the problem of jQuery overriding the meaning of “this”. Most of the time when you are doing simple things the overridden “this” is very useful. Unfortunately when you want to access an instance variable from within a block of jQuery, you have to resort to a hacky work around.

IPhone Development

Posted in Mobile on January 21st, 2009 by Alan Hietala – Be the first to comment

iphoneSo I’ve taken the plunge into iPhone development. Picked up the book Beginning iPhone Development which was recently reviewed on Slashdot. Yeah I still read slashdot, so sue me.

I’ve been learning the syntax of objective C and finding that its a bit of a learning curve to get used to reading it with ease. I’m sure that with some more time it will become second nature. Not having done smallTalk I don’t instinctively see [variable method:param:param].

I figured this would be a good time to learn the basics of game development too so the the first app I am going to write is Tetris. There are lots of great pointers over at GameDev.net so it shouldn’t be too large for a first project. Stay tuned for my progress on this.