Πέμπτη 29 Δεκεμβρίου 2011

Lubuntu suggested installs

I like LXDE, but there are some things in Gnome that I just can't live without.
So the proposed installs are:

sudo apt-get install gnome-terminal
sudo apt-get install alacarte (for the menu editor)

Τρίτη 20 Δεκεμβρίου 2011

Lubuntu Custom Application Launcher

Taken from http://linux.koolsolutions.com/2009/09/11/howto-place-programs-on-lxde-desktop/


Step 1: Create a text file
# nano README.TXT
Contents:
Hello, How are you today?
Save and exit.
Step 2: Create a corresponding .desktop file
Now we will create a corresponding .desktop file for the text file that we created in Step 1. Note that all the .desktop file will reside in the /usr/share/applications folder.
# cd /usr/share/applications/
# nano README.desktop
and type the following contents:
[Desktop Entry]
Encoding=UTF-8
Name= README
Comment= My README file
Exec=lxterminal --command "less /root/README.TXT"
Icon=/usr/share/pixmaps/readme.xpm
MimeType=text/plain
Terminal=false
Type=Application
MimeType=text/plain
Categories=Utility
Save and exit.
Let’s take a moment and understand what is going on in the above file:
Name - Give any name you want 
Comment – Your own comment
Exec – Basically we are telling which program to use to open our text file. In this case we are opening the text file with “less” command in the lxterminal window. You could have also given the following:
Exec=leafpad /root/README.TXT
Icon – I copied my own icon, readme.xpm, in the “/usr/share/pixmaps” directory. You can do the same or just use the default icons that are available in that directory.
Rest all the fields should generally remain the same.
Step 3: Create a “Desktop” directory
Now we will create a directory called “Desktop” in the user’s home directory. So for example, if the user is “root”, then we will create the directory as follow:
# cd;
# mkdir Desktop
If your user is at “/home/kushalk”, then you would create the directory as follow:
# mkdir /home/kushalk/Desktop
Step 4: Link the .desktop file with Desktop folder
This is the last piece of puzzle which will bring everything together. Now all we need to do is to link the “.desktop” file created in Step 2 inside the “Desktop” directory created in Step 3.
# cd;
# cd Desktop
# ln -s /usr/share/applications/README.desktop .
That’s it. As soon as you give the above coomand, an icon should appear on your Desktop. In case if the icon still does not appear, simply logout from LXDE and log back in.
Happy LXDE’ing!

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

Lubuntu change keyboard layout

sudo nano /etc/xdg/lxsession/Lubuntu/autostart

@setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,gr

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;
}