Search This Blog

Sunday, July 15, 2012

Midnight Commander how to compress a file/directory; Make a tar archive with midnight commander

To compress a file in Midnight Commader (e.g. to make a tar.gz archive) navigate to the directory you want to pack and press 'F2'. This will bring up the 'User menu'. Choose the option 'Compress the current subdirectory'. This will compress the WHOLE directory you're currently in - not the highlighted directory.


Tuesday, July 10, 2012

Silverlight set cell focus in DataGrid; Silverlight DataGrid set cell focus

This can be done by adding a behaviour to DataGrid like so:

<sdk:DataGrid>
   <i:InteractionBehaviors>
<Behaviors:BrowserSelectedDataGridRowSelectsCellInSpecificRow ColumnNumber="1"/>
   </i:Interaction.Behaviors>
<sdk:DataGrid>

where ColumnNumber specifies the column number to focus.

void DataGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (AssociatedObject.SelectedItem == null)
return;
AssociatedObject.UpdateLayout();
//AssociatedObject.ScrollIntoView(item, (DataGridColumn)Target.Columns[ColumnIndexForEdit]);
AssociatedObject.Focus();
AssociatedObject.CurrentColumn = AssociatedObject.Columns[ColumnNumber];
AssociatedObject.BeginEdit();
}
source

Monday, July 9, 2012

Install Drupal 7.14 on Ubuntu 12.04


Download drupal archive from the site and copy it to the root of your www directory
(on Ubuntu that is: /var/www  for apache2).

Unpack the drupal archive:
tar -zxvf drupal-7.14.tar.gz

Change the name to drupal (or any other):
mv drupal-7.14 drupal

Make sure ALL the files are owned by the www-data user (Apache2 user):
chown -R www-data:www-data ./drupal

Make sure you have the following packages installed:
php5-gd, libapache2-mod-php5, php5-pgsql (if you use postresql with drupal)

apt-get install php5-gd
(use apt-get, because aptitude uninstalls libapache2-mod-php5)
aptitude install libapache2-mod-php5
apt-get install php5-pgsql

Open the page (installation script from the browser):

www.yourdomain.com/drupal

That's about it.

Sunday, July 8, 2012

Configure Apache to host Tomcat 7 on Ubuntu

If you don't have tomcat7 installed run:
aptitude install tomcat7

Configure Tomcat
------------------

Edit /var/lib/tomcat7/conf/server.xml
Uncomment the line:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
to tell Tomcat to use connector protocol on port 8009 for connection with Apache.

Restart tomcat:
/etc/init.d/tomcat7 restart

Check whether the connector is working with:
netstat -ln | grep :8009


Configure Apache
------------------

Install module for apache which will be used to connect to Tomcat:
apt-get install libapache2-mod-jk

Edit /etc/apache2/sites-available/default
and add JkMountCopy On in the <VirtualHost *:80> section

...
DocumentRoot  /var/www
JkMountCopy   On
...

Edit /etc/apache2/mods-enabled/jk.conf

<IfModule jk_module>
    JkWorkersFile /etc/libapache2-mod-jk/workers.properties
    JkLogFile /var/log/apache2/mod_jk.log
    JkLogLevel info
    JkShmFile /var/log/apache2/jk-runtime-status
    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
    JkMount /YouApplicationName/* ajp13_worker
    JkMount /YouApplicationName ajp13_worker
</IfModule>


Note:
---------
the path should be accessible from Tomcat7 under the same application name as well. i.e:
localhost:8080/YourApplicationName

This is because Apache hosts your tomcat7's specific path.

Host jsp application from Eclipse on Tomcat 7 server

We want to host an application developed in Eclipse with the use of jsp under tomcat7 server in Ubuntu.
Let's suppose you have already installed tomcat7 on Ubuntu 12.04. Then you'll have tomcat root directory under:

/var/lib/tomcat7/webapps/

Create you own application directory:

/var/lib/tomcat7/webapps/YourApplication

We'll assuse this directory path to be $APP_ROOT. You need to have the following directory structure:

$APP_ROOT/META-INF/MANIFEST.MF
$APP_ROOT/WEB-INF/classes    -  this is where your *.class files need to be stored.
$APP_ROOT/WEB-INF/lib -  this is where you *.jar need to be stored.
$APP_ROOT/WEB-INF/web.xml
(class files need to be stored in folders which correspond to their package names)


Create a Web application (Servlet context)
----------------------------------------------
edit the file /etc/tomcat7/server.xml
and create a line:


<Engine [...]>
  <Host [...]>
    <Valve [...] />
    <Context path="/YourApplication" docBase="YourApplication" debug="0" reloadable="true" />
  </Host>
</Engine>


and restart the tomcat server.
Your application should be server under:
127.0.0.1/YourApplication

Tip:
---------
You can redirect to your application from the root domain by editing the index.html under:

/var/lib/tomcat7/webapps/ROOT/index.html

<html>
<head>
<title>Your Page Title</title>
<meta http-equiv="REFRESH" content="0;url=http://yourdomain.com/YourApplication"></HEAD>
<BODY> Optional page text here.</BODY>
</HTML>


Edit your /var/www/index.html  page as well.

Sunday, July 1, 2012

Postgresql 9.1 set default password on Ubuntu 12.04

Set default password for Postgresql 9.1 on Ubuntu 12.04:

Open a terminal

sudo -u postgres psql postgres
(run psql client as a linux user postgres and connect to postgres database)

ALTER USER postgres WITH PASSWORD '<newpassword>';
(change password for user postgres to <newpassword>)