Thursday, 28 February 2013

automatically or manually?

do things automatically if you know what will happen under the hood and you are willing to depend on the tool, otherwise you may encounter some surprises or feel completely powerless if you lose the tool.

Monday, 5 November 2012

How to use VBoxManage ?

Here is some examples (assuming the GuestAdditions has already been installed):
---------------------------------------
VBoxManage import Win7Ent32.ova
VBoxManage list vms
VBoxManage showvminfo "Win7Ent32"
VBoxManage startvm "Win7Ent32" --type headless
VBoxManage controlvm "Win7Ent32" poweroff

VBoxManage modifyvm Win7Ent32 --vrde on
VBoxManage modifyvm Win7Ent32 --vrdeport 3389

VBoxManage sharedfolder add "Win7Ent32" --name vboxshared --hostpath /tmp --transient
VBoxManage sharedfolder remove "Win7Ent32" --name vboxshared --transient
VBoxManage export "Win7Ent32" -o Win7Ent32.ova
VBoxManage unregistervm "Win7Ent32" --delete


How to use screen command?


screen is a useful command that allows a process keeping running after you exit/detach from ssh prompt, e.g.
-------------------------
create/enter a new screen: screen
start a process in the screen: lftp -u 'username,password' -e 'set ftp:ssl-force true;set ftp:ssl-protect-data true;get filename;bye' server_ip
detach from the screen: Ctrl-A, d
list current screens: screen -ls
attach to screen 8584.pts-2.dmzsrv: screen -r 8584.pts-2.dmzsrv

Wednesday, 3 October 2012

Thursday, 3 May 2012

How to change keyboard layout for login windows?

on Windows
-------------------------
set HKEY_USERS\.DEFAULT\Keyboard Layout\Preload to
409: US
809: UK

on RHEL
-------------------------
run setup to make the change
then reboot the machine

Wednesday, 11 April 2012

How to install OWB on Win7 (64bit)?

<1> download OWB2.0 from http://www.itdesign.de/en/support-downloads/downloads.html

<2> install JRE1.6 (32bit)

<3> install OWB2.0 using above JRE (Note: it doesn't work with 64bit JRE.)

Saturday, 17 March 2012

How to send scheduled JavaMail from EJB3?

Assuming GlassFish3.1.2 is your server.

<1> add a JavaMail session in the Admin Console with following settings:

JNDI Name: myJavaMailSession
Mail Host: 127.0.0.1
Default User: me
Default Sender Address: me@any.net

<2> create a timer bean with following content:

@Stateless
public class MyBean {

    @Resource(mappedName = "myJavaMailSession")
    private javax.mail.Session session;

    @Schedule(minute = "*", second = "*/10", hour = "*", persistent = false)
    public void myTimer() {
        email("she@any.net", "mySubject", "myText");
    }

    private void email(String recipient, String subject, String text) throws MessagingException {
        MimeMessage message = new MimeMessage(session);
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(recipient));
        message.setSubject(subject);
        message.setText(text);
        Transport.send(message);
    }
}

<3> allow outbound mails as following if you use iptables:

-A OUTPUT -p tcp --dport 25 -j ACCEPT
-A INPUT -p tcp --sport 25 -m state --state ESTABLISHED,RELATED -j ACCEPT