Shortcut | Command | Description |
Ctrl+/ | Toggle Comment | Add/remove line comments (//…) from the current line. The position of the cursor can beanywhere on the line. Works with multiple selected lines as well. |
Ctrl+Shift+/ | Add Block Comment | Wrap the selected lines in a block comment (/*… */). |
Ctrl+Shift+\ | Remove Block Comment | Remove a block comment (/*… */) surrounding the selected lines. |
Alt+Shift+J | Add Javadoc Comment | Add a Javadoc comment to the active field/method/class. See the notes below for more details on where to position the cursor. |
Tuesday, May 31, 2011
eclipse comments short cut
Friday, May 27, 2011
Cool stuff in .NET 4.0: System.Threading.Tasks.TaskScheduler
private void Save()
{
System.Threading.Tasks.TaskScheduler uiScheduler = System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext();
System.Threading.Tasks.Task<ErrorEnum>.Factory.StartNew(() =>
{
ErrorEnum callResult = ErrorEnum.OK;
try
{
IsIdle = false;
callResult = (ErrorEnum)DataContext.DomainRepository.SaveDomain(_domain);
if (callResult != ErrorEnum.OK)
{
// If remote saving fails, rollback all the changes
Rollback();
}
else
{
// If remote saving succeeds, save changes to local db
SaveChangesToLocalDB();
}
return callResult;
}
catch (Exception ex)
{
LogManager.AddCMEventLog("DomainSettingsViewModel.Save", ex);
// If anything goes wrong, rollback all the changes
return ErrorEnum.LocalFatalAnonymousError;
}
finally
{
IsIdle = true;
}
}).ContinueWith(task => ShowResult(task.Result), uiScheduler);
}
This running tasks in background thread, then call UI thread to execute the ShowResult() function, Just like UIDispatcher
This running tasks in background thread, then call UI thread to execute the ShowResult() function, Just like UIDispatcher
Tuesday, May 24, 2011
Monday, May 23, 2011
perl send email cgi
Lots of tutorials about sending email with perl depend on some uncommon libs.
There is a common way to do so:
use Net::SMTP::SSL;
sub send_mail {
my $to = $_[0];
my $subject = $_[1];
my $body = $_[2];
There is a common way to do so:
use Net::SMTP::SSL;
sub send_mail {
my $to = $_[0];
my $subject = $_[1];
my $body = $_[2];
perl session cgi
http://search.cpan.org/dist/ CGI-Session/lib/CGI/Session/ Tutorial.pm
$session = CGI::Session->load() or die CGI::Session->errstr;
if ( $session->is_expired ) {
die "Your session expired. Please refresh your browser to re-start your session";
}
if ( $session->is_empty ) {
$session = $session->new();
}
$session = CGI::Session->load() or die CGI::Session->errstr;
if ( $session->is_expired ) {
die "Your session expired. Please refresh your browser to re-start your session";
}
if ( $session->is_empty ) {
$session = $session->new();
}
print $session->header();
#save into session
$session->param('username',$username);
#read from session
$variable = $session->param('username');
Saturday, May 14, 2011
Dig into VIM
Input :h! in vim , what u find!?
Then :h 42 ....
quick command : http://jrmiii.com/attachments/Vim.pdf
vim cookbook: http://vim.runpaint.org/
U can also use vim in eclipse http://eclim.org/
Make vim easier to use: http://vim-taglist.sourceforge.net/installation.html (CTAGS needed)
Split screen :http://coolshell.cn/articles/1679.html
Make vim for perl : http://www.thegeekstuff.com/2009/01/make-vim-as-your-perl-ide-using-perl-supportvim-plugin/
Hot Keys : http://lug.fh-swf.de/vim/vim-perl/perl-hot-keys.pdf
#perltidy is a powerful tool to auto format the code, the hot key is \ry
Scripts : http://www.vim.org/scripts/script_search_results.php?order_by=rating
A modern vim for new guys: http://cream.sourceforge.net/index.html
Then :h 42 ....
quick command : http://jrmiii.com/attachments/Vim.pdf
vim cookbook: http://vim.runpaint.org/
U can also use vim in eclipse http://eclim.org/
Make vim easier to use: http://vim-taglist.sourceforge.net/installation.html (CTAGS needed)
Split screen :http://coolshell.cn/articles/1679.html
Make vim for perl : http://www.thegeekstuff.com/2009/01/make-vim-as-your-perl-ide-using-perl-supportvim-plugin/
Hot Keys : http://lug.fh-swf.de/vim/vim-perl/perl-hot-keys.pdf
#perltidy is a powerful tool to auto format the code, the hot key is \ry
Scripts : http://www.vim.org/scripts/script_search_results.php?order_by=rating
A modern vim for new guys: http://cream.sourceforge.net/index.html
Tuesday, May 10, 2011
Java sort list -- Collections.sort sample
public static void Sort(List<Movies> items) {
Collections.sort(items, SENIORITY_ORDER);
}
static final Comparator<Movies> SENIORITY_ORDER =
new Comparator<Movies>() {
public int compare(Movies e1, Movies e2) {
if (e1.getReleaseDate().after(e2.getReleaseDate()))
return 1;
else
return -1;
}
};
Subscribe to:
Posts (Atom)