8/16/2012

Accessing Gmail Accounts through Mail

Today when I was trying to add my nyu account to mail it always showed the same error message: server rejected your username and password.
 Some people mentioned cleaning the Captcha but it didn't work for my case. So I explored google support and I got the way to figure it out.

First go to account:

Then click on security:

And turn the 2-step verification on (It might require you to login again). After turning it on you will be able Generate new application-specific password by edit Authorizing application and sites.

Each application will need a new password but you will need to enter it once then it's all set.

I still have a lot problems switching from my pc to mac, such as shortcut keys issue and personal settings. And now I should say Mac is a good system, much better than windows in a lot of aspects.

8/05/2012

jQuery plugIn: Fixed header table for IE

For the purpose of building a spreadsheet-like table, I will have to make the table header fixed while the body is scrollable. While in Chrome and Firefox you can accomplish this simply set the css of the table body: scrollable. This does not work for IE. After searching I used one plugin on the internet called http://www.farinspace.com/jquery-scrollable-table-plugin/.
And modified it into my own edition.  To use it, simply type:

$("#"+TABLEID).createScrollableTable();

Code is as below:



(function($) {
$.fn.createScrollableTable = function(options) {
var defaults = {
width: '1160',
height: '600'
};
var options = $.extend(defaults, options);


return this.each(function() {
var table = $(this);
prepareTable(table);
});


function prepareTable(table) {

var tableId = table.attr('id');
var tb = $('#'+tableId);
var wholeWidth = $("#"+tableId).width() > options.width ? $("#"+tableId).width() : options.width;
// wrap the current table (will end up being just body table)
var minheight = 580;
var css;
if (minheight > $("#"+tableId).height()) {
css = {
'width': options.width,
'height': $("#"+tableId).height()+20,
'overflow': 'auto'
};
}else {
css = {
'width': options.width,
'height': options.height,
'overflow': 'auto'
};
}
var bodyWrap = table.wrap('<div></div>')
.parent()
.attr('id', tableId + '_body_wrap')
.css(css);

var thead_tr_first = $('thead tr:nth-child(1)',tb);
var tbody_tr_first = $('tbody tr:first',tb);
var col_width = [];
var w = 0;
var cells_head = thead_tr_first.find('th');
var cells_body = tbody_tr_first.find('td');
if (cells_body.length == 1) {
for (var i = 0; i < cells_head.length; ++i) {
col_width[i] = $(cells_head[i]).width();
}
}
else if (cells_head.length == 0) {
for (var i = 0; i < cells_body.length; ++i) {
col_width[i] = $(cells_body[i]).width();
}
}
else {
for (var i = 0; i < cells_body.length; ++i) {
col_width[i] = $(cells_head[i]).width() > $(cells_body[i]).width() ? $(cells_head[i]).width() : $(cells_body[i]).width();
}
col_width[0] = col_width[0] < 0 ? 20 : col_width[0];
}

var thead_cols = $('thead tr:nth-child(1)',tb).find('td, th');
var tbody_cols = tbody_tr_first.find('td');

var tbh = $('<table class="tablesorter" cellspacing="0"></table>').insertBefore(bodyWrap).prepend($('thead',tb));
tbh.css('width', options.width);
var css_head = {
'width': options.width,
'overflow': 'hidden'
};
var headWrap = tbh.wrap('<div></div>').parent().attr('id', tableId + '_head_wrap').css(css_head);

$.each($('.tablesorter'), function(i, elem) {
$(elem).css('width', wholeWidth);
$(elem).css('table-layout', 'fixed');
});

$.each (thead_cols, function (i, elem) {
$(elem).width(col_width[i]);
// $(elem).css('width', col_width[i]);
});
$.each (tbody_cols, function (i, elem) {
$(elem).width(col_width[i]);
// $(elem).css('width', col_width[i]);
});

bodyWrap.scroll(function () {
headWrap.scrollLeft($(this).scrollLeft());
});
}


function getWidth(td) {
if ($.browser.msie) { return $(td).outerWidth() - 1; }
if ($.browser.mozilla) { return $(td).width(); }
if ($.browser.safari) { return $(td).outerWidth(); }
return $(td).outerWidth();
};


};
})(jQuery);