Παρασκευή 16 Δεκεμβρίου 2011

Lubuntu autologin

/etc/lxdm/default.conf

just uncomment to activate it & put your name.

Startup Script for Glassfish


Write a script. put it in the /etc/init.d/ directory.
Lets say you called it FOO. You then run
% update-rc.d FOO defaults
chmod +x FOO
THE SCRIPT FOLLOWS:
export AS_JAVA=/usr/lib/jvm/java-6-sun

GLASSFISHPATH=/home/optitrans-server-testing/Programs/glassfish3/bin

case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
$GLASSFISHPATH/asadmin start-domain domain1
#we need to use this later when we enable https
#sudo -u glassfish $GLASSFISHPATH/asadmin --secure start-domain domain1
;;
restart)
0€ stop
0€ start
;;
stop)
echo "stopping glassfish from $GLASSFISHPATH"
$GLASSFISHPATH/asadmin stop-domain domain1
#we need to use this later when we enable https
#sudo -u glassfish $GLASSFISHPATH/asadmin --secure stop-domain domain1
;;
*)
echo $"usage: 0€ {start|stop|restart}"
exit 3
;;
esac
:

Παρασκευή 25 Νοεμβρίου 2011

How to change the MySQL data default directory

Taken from http://www.ubuntugeek.com/how-to-change-the-mysql-data-default-directory.html

sudo /etc/init.d/mysql stop
sudo cp -R -p /var/lib/mysql /path/to/new/datadir
gksu gedit /etc/mysql/my.cnf
 change the entry with datadir
sudo gedit /etc/apparmor.d/usr.sbin.mysqld
 Copy the lines beginning with “/var/lib/mysql”, comment out the originals with hash marks (“#”), and paste the lines below the originals.
sudo /etc/init.d/apparmor reload
sudo /etc/init.d/mysql restart


Παρασκευή 21 Οκτωβρίου 2011

Object to byte array and byte array to Object in Java

Taken from http://scr4tchp4d.blogspot.com/2008/07/object-to-byte-array-and-byte-array-to.html

public byte[] toByteArray (Object obj)
{
byte[] bytes = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(obj);
oos.flush();
oos.close();
bos.close();
bytes = bos.toByteArray ();
}
catch (IOException ex) {
//TODO: Handle the exception
}
return bytes;
}

public Object toObject (byte[] bytes)
{
Object obj = null;
try {
ByteArrayInputStream bis = new ByteArrayInputStream (bytes);
ObjectInputStream ois = new ObjectInputStream (bis);
obj = ois.readObject();
}
catch (IOException ex) {
//TODO: Handle the exception
}
catch (ClassNotFoundException ex) {
//TODO: Handle the exception
}
return obj;
}

Τρίτη 19 Ιουλίου 2011

SSH without password

Taken from http://linuxproblem.org/art_9.html

Your aim

login from host A / user a to Host B / user b.
call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa):
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):

a@A:~> ssh b@B mkdir -p .ssh
b@B's password:
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password:
From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B hostname
B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:

Put the public key in .ssh/authorized_keys2
Change the permissions of .ssh to 700
Change the permissions of .ssh/authorized_keys2 to 640

Τρίτη 23 Νοεμβρίου 2010

CLAPACK Installation in Netbeans,LINUX

Just to save a couple of hours of sleep for some people like me.

1)Download clapack.tgz from http://www.netlib.org/clapack/

2)Extract and call "make" inside the main directory

3)Call the following in terminal:

cp lapack_LINUX.a liblapack_LINUX.a

cp blas_LINUX.a libblas_LINUX.a

ranlib libblas_LINUX.a

ranlib liblapack_LINUX.a

cd F2CLIBS/

cp libf2c.a liblibf2c.a

ranlib liblibf2c.a

cp liblibf2c.a ../

4)Create new C Project in Netbeans

5)Change the makefile to contain only this:

CC = gcc

ROOTPATH = /path/to/clapack

main:main.o

$(CC) -o ./dist/Debug/GNU-Linux-x86/NAME_OF_PROJECT/main.c -I$(ROOTPATH)/INCLUDE -L$(ROOTPATH) -llapack_LINUX -lblas_LINUX -llibf2c -lm

Very helpful topic:

http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=2020

Τετάρτη 1 Σεπτεμβρίου 2010

Lyx : LaTeX Frontend

GUI for writing in LaTeX

1) sudo apt-get install lyx

2) If you want to see your math symbols instead of red text, also install the latex-xft-fonts package.

3) latex2html allows lyx to produce html output.

4) foiltex is useful for making presentations.

5) After installing such packages you should reconfigure ( goto Edit -> Reconfigure) and then restart LyX.

For Greek support:

6) Install packages texlive-lang-greek,texlive-fonts-extra,texlive-latex-extra