Monday, June 14, 2010

Fedora 13: Playing MP3 Files

To play MP3 files on Fedora 13, execute the following commands on a terminal as root
rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
yum install gstreamer-plugins-bad gstreamer-ffmpeg gstreamer-plugins-ugly -y

Taken from http://www.linuxreaders.com/2010/05/28/play-divx-mp3-on-fedora-13

Monday, January 18, 2010

Free Boracay Package

Win a Free Boracay Vacation Package by WOW Philippines Travel Agency

WOW Philippines Travel Agency, Inc. is celebrating it's 5th year in business during July of 2010, and we would like you to have a chance to celebrate with us, so we have decided to give-away a FREE Boracay Package complete with 5 Star accommodations at the luxurious Le Soleil de Boracay Hotel on Boracay Island. The lucky winner will win the following Boracay vacation package.

Vacation Package Inclusions:
- 5 Days / 4 Nights Luxury 5 Star Accommodations at the Le Soleil de Boracay  Hotel
- Flights to Boracay from Manila to Caticlan Airport on Philippine Airlines
- Island Transfers - Door-to-Door from Manila to the resort and back to Manila
- Three (3) Meals each day, Breakfast, Lunch & Dinner
- Boracay Activities - Horseback Riding, Island Hopping, Glass Bottom Boat
- PLUS - 5,000 peso Spending Cash

Read More Information: http://www.boracay-packages.com

Friday, November 20, 2009

My Pirate Name a.k.a Something less serious

My pirate name is:
Dirty Jack Kidd

You're the pirate everyone else wants to throw in the ocean -- not to get rid of you, you understand; just to get rid of the smell. Even though you're not always the traditional swaggering gallant, your steadiness and planning make you a fine, reliable pirate. Arr!
Get your own pirate name from piratequiz.com.
part of the fidius.org network

Thursday, November 5, 2009

Preventing ConcurrentModificationExceptions!

I have encountered several times now, and its very annoying since the error happens randomly. After a bit of googling, I found out that using unsynchronized JAVA collections yields unpredictable results. I am hoping that synchronizing my JAVA collections manually could solve this problem. To do this, I will have to use the ready made JAVA Collections synchronize wrapper:

For example if I use the List interface like this before:

List list = new ArrayList();

I will have to wrap the ArrayList implementation using the Collections synchronize method:

List list = Collections.sychronizedList(new ArrayList);

OR

List list = new ArrayList();
list = Collections.sychronizedList(list);

I hope this works. I will refactor my code now and will update this post once I find out what happens.

EDIT: It works! You just have to synchronize the list before iterating through them :)

Wednesday, October 21, 2009

Set Character Encoding to log4j's File Log

Working with east asian characters? Do you want log4j to print out utf-8 characters on your log file? Here is how:

When you're using a log4j.properties file:


log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.encoding=UTF-8

When youre using a log4j.xml file:

<appender name="R"
              class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="info-log.log"/>
        <param name="Encoding" value="UTF-8"/>
        ...
        ...
</appender>
Enjoy!

Wednesday, October 7, 2009

Loading a file from classpath

There are instances that you want to load a certain file from your classpath, the following code does that:

private InputStream getFileFromClassPath(String fileName) throws IOException {

        ClassLoader cl = ClassLoader.getSystemClassLoader();
        URL url = cl.getResource(fileName);
        if (url == null) {
            throw new NullPointerException("File with filename " + fileName + " not found on classpath");
        } else {
            return url.openStream();
        }
       
 }

Tuesday, October 6, 2009

How to define multiple PropertyPlaceholderConfigurer beans

I came across a problem today regarding the app that I am working on wherein I have to define a different PropertyPlaceholderConfigurer bean for each of my context xml files. (Each context xml file is imported in another xml file so it became a little bit tricky).

What I did was, I defined a PropertyPlaceholderConfigurer bean on the first context xml file and I defined another one on the second, so that each context xml can have it's own distinct PropertyPlaceholderConfigurer bean. But upon doing so, I got the following error

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'myClass' defined in class path resource [spring-config.xml]: Could not resolve placeholder 'props.value.2'

After google-ing a bit I found the answer to my problem on an entry on Parth Barot's blog. Please take a look!