Blogs

grep over ssh in emacs

M-x grep command is very useful in a number of situation, because, for example, it give you direct access to all matched file ...

But there is not so intuitive how to use grep when opening file via ssh, this is the trick:

First generate a key pair and upload public part to the remote server:
(suppose remote host/user is B/b)

ssh-keygen -t rsa
#...
ssh b@B mkdir -p .ssh
cat ~/.ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
ssh-add

be sure to use ssh-agent in order to use ssh-add

SiteMap php class

2 simple class for sitemap:

http://www.smartango.com/sites/default/files/sitemap.txt

simple use:

{syntaxhighlighter brush:php}
$root = $_SERVER['DOCUMENT_ROOT'];
$sm = new SiteMap($root,'sitemap-1.xml');
$sm->start();
$http = "http://www.example.com";
$sm->addUrl($http."/file.html");
$sm->end();
{/syntaxhighlighter}

...SiteMapIdx similar

move multiple option in select with jQuery

I look for this everywhere: how to move multiple option inside a select
function upfield() {
  var el = $('#selectedfield').children('[@selected]:first').prev();
  $("#selectedfield")
    .children('[@selected]')
    .each(function(){
	$(this).insertBefore(el);
      });

}

function downfield() {
  var el = $('#selectedfield').children('[@selected]:last').next();
  $("#selectedfield")
    .children('[@selected]')
    .each(function(){
	$(this).insertAfter(el);
	el = $(el).next();
      });
}