Thursday, May 24, 2007

Facebook opens the gates! And they're off!

Well, about an hour ago, Facebook just announced their new Platform integration API. And we had an announcement ourself.

We've been having a TON of fun as a launch developer, seeing what's possible with their api. We've learned a lot of tricks along the way, specifically about integrating securely with a third party in a stateless REST environment. And all that we've learned should be released soon. We're developing an ActionScript 3 API for Platform, which we will be releasing soon.

Right now Jason is over in San Francisco taking part in a hack-a-thon with the Facebook guys. I knew I shouldn't have let him have all the fun. *sigh*

Why I like Facebook is the sort of 'extroverted internet' approach they've taken. I'm not a big MySpace fan, and a marginal extrovert myself. But I can understand what makes Facebook a great social application.

Facebook understands the concept of signal-to-noise ratio better than any existing social networking site. If you have to surf through tons of crap to find what you want, it makes it less accessible, and less valuable. Google understands this. Getting the user from point A to point B quickly is paramount to user experience. What about in the sphere of social networking? In terms of relationships, Facebook is speed dating, and MySpace is a noisy, loud night club.

Of course there is a place and time for both. Facebook has used discretion in allowing access to its users. It doesn't want to lose its integrity, and the high signal-to-noise ratio. But it has to be competitive on features, without opening the flood gates to the noobs. And so the new 'Applications' features have been developed.

Applications are Facebook's equivalent to MySpace codes. But unlike MySpace codes, which is basically just html, Facebook uses FBML to include html in its pages. Applications must also be registered with Facebook, requiring a certain level of proficiency, and removing anonymity from the application developer. That's important when you've got 27 million+ users to keep secure.

Overall I'm really happy to see a social networking platform rolled out that has this kind of smarts. We'll see where it goes from here!

Centering in Safari and IE off by one pixel

If the size of the browser window is an odd number, you'll run into problems with the centering not matching the centering of your html. A friend of mine needed this fixed, as his page elements could not match up with the background. This fix here suggests resizing the browser window to fix the problem. Well, while that is feasible workaround, I'm not sure how usable it is for a user to have their browser modified like this.

And so I cobbled together some javascript for him that basically overrides the background positioning and centers it manually via javascript. Like so:


function positionBackground(){
//set this to the width of your background image
var backgroundImageWidth = 760;

var size = getPageSize();
var body = document.body;
if( navigator.userAgent.indexOf('Safari') != -1 || navigator.appVersion.indexOf("MSIE") != -1)
{
if(size.width % 2 == 1){
size.width -= 1;
}
}

body.style.backgroundPosition = size.width/2 - (backgroundImageWidth / 2);
}

function getPageSize() {
var myWidth = 0, myHeight = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
return {width:myWidth,height:myHeight};
}

window.onresize = positionBackground;
window.onload = positionBackground;


Unfortunately you're required to input the background image's width by hand, but since this is usually consistent I think its acceptable.

Alas, I'm really unsure that this is a better way of thinking about how to fix things. It really bothers me that the current mentality for rigorous CSS and tableless layouts requires such elaborate javascript fixes to get them to work. But that is a topic for another rant. :)

Tuesday, May 22, 2007

Cool trick: Re-instating deleted files in subversion.

One of the problems with version control in general is dealing with large amounts of binary data. If you add a large chunk of data, say an image sequence, its in there...for good*. If you delete it, and you want it back, well, is it possible to get it back without having to put it back in, increasing the size of the repository? With Subversion you can.

Earlier today we had a subcontractor who's new to using Subversion make the classic subversion mistake: copying a directory using Windows Explorer's copy and paste, instead of using Tortoise. So he copied his files to a new location, then used TortoiseSVN->Delete to remove the files from the repo, and supposedly committed his updates (which didn't move any files like he thought). When we asked him where the files went he was like 'i can see them'. So I went ahead and im'ed back 'i'll fix it'.

I reverted just the deleted branch to before he deleted the files. Then I moved them to where I wanted them to be in the current branch using the proper right-click and drag method with Tortoise.

The 'cool' part of this is that I'm actually moving files that aren't part of the current revision, and don't even exist in the current revision, from a previous revision. Remember that in Subversion all file revisions are really just links with data attached. All I'm doing is telling Subversion to link the data from a previous version to the latest revision, and Subversion just does what its told. Awesome!

* It is possible to use stream editing to remove files from SVN repositories, if you are braver than me.