Posts Tagged howto

a vi trick

Vim loves to auto indent. This can present a challenge when pasting text. Auto indent can distort the formatting. The trick documented here is very helpful. Instead of using F3 key stated in the document. I used underscore. It worked beautifully!

set pastetoggle=_

Leave a Comment

Building a Hello World portlet with Liferay

Today I tried to build a simple Hello World portlet with Liferay Portal. I am a little disappointed that the documentation isn’t as straight forward as I expected. I had to read through several documents and was confused by outdated/conflicting information. So, I am sharing my setup notes for people who might be interested to give it a try.

  1. Download Liferay binary here. I downloaded the Tomcat bundle for ease of configuration. YMMV with other bundles.
  2. Follow the quick installation here. I didn’t have any issue starting Tomcat with Liferay. It brings up the default portal page automatically. Do not close this page. We will revisit this page in a later step.
  3. Download SDK from here. Look for a download link that starts with “Liferay Plugins SDK”.
  4. If you don’t have Ant setup in your environment, follow the instructions in page 6 of the development documentation here. My environment is already setup with ant, so I just skipped this step.
  5. Customize your own build.${username}.properties. I made copy of ${sdk_directory}/build.properties and created my own file in the same directory using the build.${username}.properties convention documented in page 7 of the development guide. Within this file, I updated app.server.dir property with the path to Tomcat’s directory in my local environment. The document has a typo about the other property: java.compiler. Reading the build.property file suggested to me that the property name should be javac.compiler. Since I only wanted the default configuration, which is modern, I didn’t change this second property.
  6. Create a portlet using ant: I followed the instruction on page 8 in the development guide. It is very straight forward. Make sure you run the create command in the portlets directory in the sdk directory.
    cd ${sdk_directory}/portlets
    ant -Dportlet.name=hello -Dportlet.display.name="hello world title" create
    
  7. After created the portlet, you should see a new directory that looks like hello-portlet. You can go into that directory and make changes to your liking. Since my goal was just to get a simple portlet running, I just added “Hello World” to hello-portlet/docroot/view.jsp file.
  8. Deploy the portlet: Within the hello-portlet, I ran the following command to deploy the portlet:
    ant deploy
    
  9. After I deployed the portlet, I did a quick check in the log file (catelina.out) to see if the portlet is available. I did notice that the message is slightly different from what development guide stated.
  10. Add the portlet to the portal page: I returned to the default portal page on my browser. On the default portal page, there is a menu that has the label “welcome” on the to right corner. Liferay documentation called this “Dock”. If you mouse over this, you will see login option. To login, enter “bruno@7cogs.com” for email address and “bruno” for password. This information comes from the quick installation guide. All other documentation that I read all refers to “test@liferay.com” and “test”, which are wrong for the release that I downloaded. Once log-in, You can mouse over to the Dock and choose “Add Application”. Enter the name of your portlet in the search textfield, the list should automatically updated. If you can identify your portlet, click the “Add” link next to it. You should see the portlet showing on the portal page.

That should get your development setup for further portlet development. Have fun coding!

Update: If you want to use Glassfish, see Ari’s blog on this topic.

Comments (13)

change hd in MacBook Pro

Thanks to Ari for the link to this blog post, which led me to this blog post and this video. I was able to upgrade the hd smoothly.

Comments (1)

Setting up printer sharing using Samba

I followed the instructions on this page to share a printer on my local network. The part that was not clear to me initially was “what is the shared printer name?”.

Then I found out that the shared printer name was the same as the local printer name configured in CUPS. This probably caused by load printers = yes option in smb.conf file. After I set the shared printer name on the client side, printing across the local network works!

Leave a Comment

Localization with Ext JS

This thread helped to get a jump start to localize with Ext JS. I am thrilled that it is as simple as including an extra javascript file. Now, I just need to figure out how to identify what locale/language the browser is configured and dynamically load the appropriate locale JavaScript file. If anyone know a working example/howto, let me know. Thanks in advance.

Leave a Comment

A workaround for using Ext.ux.CardPanel

I ran into a bug in Ext.ux.CardPanel today. Within a CardPanel object, I included a GridPanel. I could not set the title of GridPanel no matter what I tried. I used the title configuration option and called setTitle public method. The title would not show up.

To work around this issue, I had to enclose the GridPanel within a Panel object. Here is an example:

var tempPanel = new Ext.Panel({ items:[myGridPanelObject]});
var myCardPanel = new Ext.ux.CardPanel({
  activecard: 0,
  items:[tempPanel, otherPanel]
});

Leave a Comment

First impression with ocropus

OCRopus is an OCR system. I initially wanted to see how it can handle handwriting. So, I gave it a try by installing it on Ubuntu 8.04. To get started, I used Synaptic to install the following required software:

  • jam
  • libpng12-dev
  • libjpeg-dev
  • libtiff-dev

I installed one of the optional packages, libaspell-dev. Beyond that, I also installed build-essentials for the compilers needed to build from source.

Next, I checked out tesseract-ocr from Google.

svn co http://tesseract-ocr.googlecode.com/svn/trunk/ tesseract-ocr

I had to use the patch from this forum thread. To install the patch, I used this command:

patch java/makefile < java

Note that java is the patch file and java/makefile is the make file in tesseract-ocr/java directory. After I applied the patch, I continued building tesseract-ocr

./configure
make
sudo make install

Now I have all the required software, now I am ready to install ocropus:

svn co http://ocropus.googlecode.com/svn/trunk/
cd trunk
./configure
jam
sudo jam install

By this step, the basic ocropus is installed.

One thing I noticed after the initial install, I needed to create /usr/local/ocroscript directory and create the following two soft links within the newly created directory.:

ocroscript -> ../bin/ocroscript
scripts -> ../share/ocropus/script

To test the software, I used the sample image came with the software:

/usr/local/bin/ocrocmd /data/pages/alice_1.png |less

The default test case above worked for me. Next, I took out my camera and took a picture of my handwriting. Upload the image and ran it through the OCR software. I was disappointed to find that ocropus couldn’t recognize my handwriting very well. Is there something that can do better?

Comments (2)

Error 51

This post helped me to get back online with Cisco VPN software.

Leave a Comment

Remove white space in JavaScript

This code snippet shows one way to remove white space in JavaScript.

Comments (1)

A subversion command

A co-worker shared the following tip with me: How do I check out a specific revision of a file? Here is the command:

svn update -r 1234 myfile.txt

-r option specify the revision number.

Leave a Comment