Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Wednesday, September 8, 2010

How to install python PIL

Installing PIL library using easy_install is easy as always. But it has some dependencies, that are not so obvious at first. In order to have support for JPEG, PNG and Freetype we need to install those development libraries as well.
So the whole command list is as following:

> apt-get install zlib1g-dev libfreetype6-dev libjpeg-dev
> easy_install pil

After PIL installation script is finished you should check for the following lines:
*** TKINTER support not available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available

as you can see JPEG, ZLIB and FREETYPE support is available now.

Friday, April 16, 2010

How To: Tomcat 6, BlazeDS 3.2, Hibernate 3.5 (JPA 2), Spring 3, Maven 2 – Part 1

In the following series of articles I want to explore how to set up a RIA project based on the latest stable Java and Flex stack using Maven and Eclipse. One would expect it to be easy enough and it is, but as always evil is in the details.

Prerequisites: recent version of Eclipse(3.4, 3.5) and m2eclipse plugin from SonaType.

Creating Web Project in Eclipse with Maven Dependency Management

In one of my previous posts I have tried to express my love for Maven. Using it from command prompt is a pleasure: quickly generating projects from templates(archetypes), building, running test, packaging and deploying, all is good. These are repetitive steps that need to be automated and maven handles that quite good. But we also need our old good IDEs with all the features we are used to have and got addicted to. So we need to look at our project from several different perspectives. To do that we need to set our project so that Maven and Eclipse understand the format/structure.

There are two ways to go: create Dynamic Web Project in Eclipse and enable Maven Dependency Management in it or create new Maven Project and enable Dynamic Web Module Facet in it.

First approach is more appropriate when you have some project in progress and want to start managing its dependencies with Maven. You can accomplish this from Project context menu/Maven/Enable Dependency Management. But it is not enough, you will have to modify folder structure according to established Maven project structure standards. Your sources should be in src/main/java and web content should be in src/main/webapp. Then you will have to edit some configuration files. For example you need to edit wb-resource parameters in org.eclipse.wst.common.component file located in .settings folder, and some more.

It looks like too much manual modification of Eclipse managed and hidden(by default) settings files and that is why I prefer the second way (with some maven plug-in help of course). Here is a step by step explanation:

1. Create new Maven Project. Check “Create a simple maven project(skip archetype selection)” option and set packaging to WAR. You have a working maven project structure. No we would like to work with the project as if it is native eclipse dynamic web project.

2. But first you should modify your pom.xml file to enable Java version 1.5 (or 1.6, what ever you need). It is necessary,  because  by default Maven compiles java code as Java 1.4. We also need this configuration for the next step. Just add the following xml in you pom.xml file:

<build> 
<plugins> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-compiler-plugin</artifactId> 
<configuration> 
<source>1.5</source> 
<target>1.5</target> 
</configuration> 
</plugin> 
</plugins> 
</build>

It may look like too much custom xml, but after you work with maven for some time those plugin/dependency/groupId/artifactId elements just become part of your programming lexicon and m2eclipse plug-in with its code completion really helps here.

3. Now from Project context menu select Run As/Maven build… with the following options:

Goals = eclipse:eclipse

Parameter Name = wtpversion, Parameter Value = 2.0

After you run this maven build you get standard Eclipse Dynamic Web Project with Java Facet and Dynamic Web Module Facet enabled. Check it out from Project Properties / Project Facets section. Now you can configure Targeted Runtime (Tomcat 6 in our case) and other possible configurations you need just the same way you did it before maven era.

In Part2 we will explore how to further edit pom.xml file and add BlazeDS support using excellent Spring framework.

Sunday, November 29, 2009

How to host your Blogger theme images

I was thinking on the topic for my first blog post. Suddenly, I realized that there is one little problem I just solved and probably should share with others.

I was searching for a good simple theme for my new software development oriented blog. There are some nice free themes to start with on the net. I picked one, customized a little bit (few css and image tweaks), and just before saving it in Blogger Settings Layout panel, my brain threw an exception, saying: “Man, you need some place to host your theme image files!”. Fortunately, I managed to catch that and after some stack trace investigation came up with a few possible recovery solutions:
  • Find similar images (mostly background) on the net and use that
  • Host images on some free/paid hosting site
  • Host images on Blogger itself
Well, the first one is not reliable, at least, and although images in my theme are very simple I would have to find similar ones. Second one is not logical, if I need some place to host something related to my blog on Blogger, than why do I need Blogger at all? The last one seems to be the most reliable and elegant solution. And actually simple one.

All you need is to create a new post, insert all the images used in your theme and publish it (or save as a draft if you do not want everyone to see some strange post with a list of 1px wide images). That’s it. If you see your images in your browser than Blogger hosts them, right? Then there is some URL, right? Absolutely. Now you need to update your theme with URLs of the images from your post hosted on Blogger.

Well, in fact, this post is exactly that post which contains those 2 images used in my theme. You can see them below.




Ok, this is my first post on this blog and I hope it will be useful to someone. If it is, please drop some note below. It is really nice to hear that these few bytes of information help someone.