Also make sure that you have appropriate environment variables set up:
JAVA_HOME
JAVA_JDK
CATALINA_HOME
CATALINA_BASE
TOMCAT_HOME
APP_TOMCAT_HOME
ANT_HOME
JBOSS_HOME
Make sure that you allocate enough memory otherwise it will not run or you get various errors like ‘OutOfMemory: PermGen’. The setup certainly works with the following parameters.
Import projects into Ecplise
In order to add alfresco projects into Eclipse import ‘root/projects’ directory that you checked out from svn.alfresco.com. In Eclipse select: File -> Import -> Existing Projects into Workspace
You should be able to see the window presented below. Select all the projects. You do not have to copy them into the work space.
If you are successful you should be able to see the projects in your package explorer as pictured below.
Now you should be able to track the changes that you do in your code using Subversive Ecplipse plugin which is very handy.
Do Alfresco build
Go to ‘root/projects’ directory and run:
When you are successful you should be able to locate alfresco.war (alfresco repository) and share.war (Slingshot web interface) files in the following locations:
root/projects/web-client/build/dist/alfresco.war
root/projects/slingshot/build/dist/share.war
Create web projects in Eclipse
To deploy alfresco.war and share.war files separate web projects should be created. I am going to describe only share.war installation. alfresco.war installation should be done analogically.
Select:
File -> New -> Dynamic Web Project
Enter war name as project name (in our case ‘share’). The project will be deployed under project name URL. If necessary it can be changed in ‘Properties’ of the project – Web Project Settings – Content root. Select Tomcat 7 ‘Target runtime’ or choose ‘New runtime…’ if you do not have Tomcat 7 added in your server list. This will enable the addition of Tomcat 7 runtime environment.
This should create Dynamic Web Project with the following structure.
Unpack your share.war file and copy its content to WebContent folder of ‘share’ project. Refresh project in Eclipse. All Alfresco jar files you will find in the following path:
WebContent/WEB-INF/lib/alfresco-*.jar
Instead of having static alfresco jar files we can generate them automatically from our projects in Eclipse. In that way when we change some code we can check the outcome in convenient way by automatic deployment of new jar files. Let’s say that we want to change some code in ‘Core’ project, which corresponds to ‘alfresco-core-x.jar’. In order to do so we remove alfresco-core-x.jar from WebContent/WEB-INF/lib, so old version will not be used. Following that we edit Properties of the project and change:
‘Project references’ to include Core project:
‘Deployment assembly’ to include source code from ‘Core’ project. Click ‘Add…’, select Project and ‘Core’ project. Node that Core.jar will be created and this jar will be added to your deployment.
‘Java build path’ to include source code from ‘Core’ project. Click ‘Add…’ and select ‘Core’ project. It might also be necessary to change order of exported libraries in some projects, e.g., Repository project, in case of compilation errors. Put system libraries first.
Run project on Tomcat
Once the project (share) is set up not we can add it to Tomcat server and run it. In order to do so go to ‘Servers’ view (Window -> Show view -> Servers). Right mouse click on Tomcat 7 server and select ‘Add and Remove…’. Add share project to be run on Tomcat. Publish data and start server.
If everything is successful you should be able to access your application via web browser: localhost:8080/share.
If you want to see all the files that were actually deployed you can find them in the following path: ‘workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/share’
You can change Tomcat configuration, e.g., increase memory by double clicking on appropriate server in ‘Servers’ view. Select ‘Open launch configuration’.
If there is no Tomcat 7 server you can add it by right mouse click and selecting ‘New -> Server’.
I find this one very useful, when you press just CTRL-G in vim you will get some basic file information:
When you use put count (a number) 1 before that command, the path will get expanded to full path (but shortened with ~ for the home directory). So when pressed:
I wanted to iterate over set of directories and calculate total number of files inside each of them (recursively). xargs & find would do it just fine but you can not easily escape pipe inside xargs command. Here is the solution:
I usually set my postfix to relay via gmail SMTP to allow me for reliable external email delivery from my gmail address, with the convenience of the command-line. To send an email using mail utility I can simply use:
This will generate an email with default X-Mailer tag, like:
X-Mailer: mail (GNU Mailutils 2.2)
To disable it, create a .mailrc configuration file in your home directory and unset xmailer option:
I have a collection of 160 photos that I would like to montage into a movie. Each photo was done on a different day and the brightness of each photo varies. This will definitely not look good on the photo, so I’ve decided to “normalize” the brightness across the images. That is:
Find a value for average brightness of my images.
Brighten those too dark, and darken those that are too bright. Contrast should also be adjusted.
Calculate average image brightness
I have used utility called identify from ImageMagick package
-format option allows for specifying what kind of information about the image we want to output. In this case I went for average brightness – %[mean] and filename – %f, see the full documentation if you’re interested in other possibilities.
The difference between top and bottom photos is quite big: 21256.8 for 2011.06.06.JPG and 44153.8 for 2011.06.22.JPG – see the photos below.
Now let’s calculate the average value of brightness – awk to the rescue!
Equalize the brightness
So I need to bring all the photos to the mean brightness of about 29481.9. The best option I’ve found to do that is to use -sigmoidal-contrast from ImageMagick. I don’t know what values for -sigmoidal-contrast I need to use, to get from one brightness to another, so I wrote a simple script that will try to do that using binary search algorithm. It’s really very quick & dirty script but it does the job. The main loop is as follows:
adjust function basically calls external convert utility to perform the adjustment:
and then checks and returns the brightness after conversion. I use -sigmoidal-contrast option to increase brightness and +sigmoidal-contrast to decrease. Now, that’s much better:
Recently I had to locate the widest image in the set of photos in a directory. Here is how you can easily do it with identify command, from ImageMagick suit:
You can see in the output that the widest image is 563 pixels wide and the filename is 2010.12.30.JPG.