Thursday, February 26, 2009

Google's Native Client Security Contest and Is this Google's verison of the Java browser plugin ?

So I was skimming thru my reading list today when I came across this blog post from the Google Code Update blog. It looks like Google is running a contest to find bugs, exploits and vulnerabilities on the Native Client.

The first thing I asked myself was, what's the Native Client ?

The google code page for the native client project looked straightforward but the possibilities of something like this is astounding.

Running Quake on your browser ? Are you kidding ? Get Outta here !!!

If you can run Quake on your browser, imagine being able to run other MMORPG's (World of Warcraft anyone ?) on the browser !

Monday, February 23, 2009

If I were going to build a new PC

Someone asked me, if I were going to build a high-end PC today, what parts would go into it and how much would it cost.

The first thing I asked was, what's it for ? He says it's going to be a windows box for graphics and multimedia with a little gaming on the side.

Here's my answer ....

------------------------------------------
14,000 : Core i7 920
16,500 : Msi Eclipse X58 SLI 1366
29,000 : Corsair 6gb (TR3X6G1333C9) XMS3 X 2 = 12GB
3.750 : Palit ATI HD 3850 Super 512mb (256bit) ddr3
13,000 : 1tb Caviar Black (WD1001FALS) 32mb dual processor X 2 = 2TB
7,800 : Cooler Master (RC-932) HAF 932 atx w/o psu black
7.000 : Cooler Master UCP 700W Ultimate 80PLUS Silver Certified
18,000 : 2693hm SAMSUNG 26"
------------------------------------------
P109,050
------------------------------------------

Prices are from TipidPC.com.

So what do you think ? A little overkill for graphics and multimedia or should I have gone dual SLI or even a 4870 X2 graphics card ?

Facebook HowTo : Protect Your Privacy on Facebook

I found this rather informative video from CnetTV on how to protect your privacy on Facebook using the groups list feature. I've been spending so much time on Facebook accumulating friends that I think I'm going to need to do this soon :-)

Monday, February 16, 2009

An ingenious solution for handling Javascript popups in Watir

So I've been struggling to figure out how to elegantly and properly handle popups on Watir. I've read and tried all five solutions listed on http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups but still couldn't find one that works well for the version of Ruby/Watir I am using.

I'm using Ruby 1.8.6 and Watir 1.6.2, BTW.

Then I came across a blog post that proposes to override the javascript alert and confirm functions. Read the whole thread from google groups here.

I was stoked !!! Even more so that it worked beautifully.

What I did was to encapsulate it into a def which accepts the IE instance created by watir.


def replace_js_popups(ie)
ie.document.parentWindow.execScript("window.confirm=function(){return true}");
ie.document.parentWindow.execScript("window.alert=function(){return true}");
end


Now, right after going to a page, I would call on "replace_js_popups" to override both confirm and alert, like so.


ie = Watir::IE.new
ie.goto(url_with_popup_here)
replace_js_popup


Of course, this is not a fool proof solution. By replacing the alert and confirm functions with a function that always returns true, you will need to always expect the popups to return a value of true in your automated tests.

Sunday, February 08, 2009

ExtJS Tip : Sortable Grid Rows via Drag and Drop

One particular challenge on a recent project is to have the ability to sort grid rows using drag and drop. With lots of help from the ExtJS forums, here's how I ended up doing it.

The code snippet below shows an Ext gridpanel with the added ability to allow users to sort rows using drag and drop. This is acheived by (1) setting the enableDragDrop configuration to true to allow dragging and dropping of rows and (2) creating a drop target that handles the drop event when a row is dropped.

Update 031609 : An anonymous comment mentioned having problems with sorting multiple rows. This tip only works with single select rows. I have added the code change below that forces the grid to use a single select row selection model.



var grid = new Ext.grid.GridPanel({
id: 'mygrid',
title: 'My Grid',
store: store, // define the data store in a separate variable
loadMask: true,
ddGroup:'mygridDD',
enableDragDrop: true, // enable drag and drop of grid rows
viewConfig: {
emptyText: 'No pages found',
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
forceFit: true
}, columns: gridcolumns, // define grid columns in a separate variable
listeners: {
"render": {
scope: this,
fn: function(grid) {

// Enable sorting Rows via Drag & Drop
// this drop target listens for a row drop
// and handles rearranging the rows

var ddrow = new Ext.dd.DropTarget(grid.container, {
ddGroup : 'mygridDD',
copy:false,
notifyDrop : function(dd, e, data){

var ds = grid.store;

// NOTE:
// you may need to make an ajax call here
// to send the new order
// and then reload the store



// alternatively, you can handle the changes
// in the order of the row as demonstrated below

// ***************************************

var sm = grid.getSelectionModel();
var rows = sm.getSelections();
if(dd.getDragData(e)) {
var cindex=dd.getDragData(e).rowIndex;
if(typeof(cindex) != "undefined") {
for(i = 0; i < rows.length; i++) {
ds.remove(ds.getById(rows[i].id));

}
ds.insert(cindex,data.selections);
sm.clearSelections();
}
}

// ************************************
}
})

// load the grid store
// after the grid has been rendered
store.load();
}

}
}
})

Sunday, February 01, 2009

How to live your life

I subscribe to Salve Duplito's blog over at Inquirer.net Blogs for the personal finance articles.

Today, I got a special treat because today's blog post was definitely more than personal finance, it was about living.

Prof. Randy Pausch passed away last year of pancreatic cancer but not before speaking to about an audience of 400 at Carnegie Mellon University for the "Last Lecture" series. While watching the video I am always reminded that the speaker was going to die and that made it all the more powerful, I almost shed a tear too when he mentioned for whom his lecture was really for at the end.

Sad and inspiring at the same time.