Jun 15, 2012

Create a HTML e-mail using Python

This is a Python script that I used to generate a HTML e-mail. Script is configured to use gmail as the senders mail host with SSL support. Change the mail server if you want to use some other mail server. If you enable the 2-way authentication on google account, that will be another problem.

Note : There are some problems with attachments. Some mail clients (yahoo) don't show the attachment.


Loading ...
https://gist.github.com/thilinapiy/2937681#file-my_send_mail-py

May 19, 2012

Create a maven distribution package including a jar with dependencies

In this post I will show how to create a distribution package (zip/tar.gz) using maven. Package will contain the executable jar and other relevant file such as README, License etc.

First I will create the jar including all the dependencies. To do that I add following code to my pom.xml
<project>
 ...
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>jar-with-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <archive>
                                <manifest>
                                    <addClasspath>true</addClasspath>
                                    <mainClass>HelloWorld.App</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>
                    <execution>
                        <id>dist</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/dist.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

In this pom.xml, it reffers to another xml file call dist.xml. This xml file contains all the details about the distribution package we are going to generate.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 
   http://maven.apache.org/xsd/assembly-1.1.2.xsd">
 <id>dist</id>
 <formats>
  <format>zip</format>
  <format>tar.gz</format>
 </formats>
 <files>
  <file>
   <source>pom.xml</source>
   <outputDirectory>/source</outputDirectory>
  </file>
  <file>
   <source>target/${project.artifactId}-${project.version}-jar-with-dependencies.jar</source>
   <outputDirectory>/</outputDirectory>
  </file>
 </files>
 <fileSets>
  <fileSet>
   <directory>/src</directory>
   <outputDirectory>source/src</outputDirectory>
  </fileSet>
 </fileSets>
</assembly>

You should note following thing on pom.xml and dist.xml.

In pom.xml

  • Replace this " <mainclass<HelloWorld.App</mainclass> " with your main class.
  • Replace this " <descriptor>src/main/dist.xml</descriptor> " with your dist.xml file path.

In dist.xml

  • Use <files> to add files.
  • Use <fileSets> to add directories.
  • Use <outputDirectory> to specify the destination of each file/directory.

For more details : Maven assembly plugin examples

Apr 22, 2012

xhost error in Oracle 11g on CentOS

I try to install Oracle 11g database on CentOS 5.

There was an error saying
" Checking monitor: must be configured to display at least 256 colors
>>>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<< "

I try all the xhost configurations and those things work fine. Then I restart my computer.

After I restart the computer I logedin as "Oracle" user. Then I re-try the ./runInstaller.sh. Finally it works.

Initially I login to the system as some one else and use "su - oracle" to change the user on the terminal.

As the solution,
First you should check the login user name. It should "oracle".
If it is oracle user, then try other things like xhost configurations.