Install and Config MPlayer on Ubuntu

I tried to install realplayer on Ubuntu 7.0.4, no luck, even if I fixed the RealPlayer and SCIM conflict. Suggested by Yi, I decided to install MPlayer.

Follow the instruction on: http://ubuntuguide.org/wiki/Ubuntu:Feisty#How_to_install_MPlayer_Multimedia_Player, to install MPlayer.

There was some extra steps to get MPlayer to play a rmvb file on my Vostro 200 box with Intel GMA 3100(G33) graphics card and DELL E207WFP wide screen LCD.

Error code: error opening/initializing the selected video_out (-vo)device
Solution: Open a mplayer, select configure (right click mouse --> Preferences) select Video section and after select xv or x11

Error code: cannot find the codec matching -vo and video format 0x30345652
Solution: install codec available in aptitude using the command:

sudo aptitude install gstreamer0.10-pitfdll gstreamer0.10-ffmpeg gstreamer0.10-gl gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-ugly gstreamer0.10-plugins-ugly-multiverse libxine-extracodecs w32codecs

Error: The video does not zoom correctly
Solution: sudo gedit /etc/mplayer/mpalyer.conf
and uncomment the following setup:
monitoraspect=16:9
zoom=true

Now I could play the rmvb video files without any problems. Next time, I'll get audio fine tuned.

Google Pinyin only supports Windows OS

I can't imagine that Google Pinyin does not support Linux/Unix OS.

系统要求
Microsoft Windows 2000 SP4 / XP / Vista
Internet Explorer 6.0+

How to beautify Chinese characters using Windows fonts in Ubuntu

如何使用xp带的字体来进行Ubuntu中文美化

The font comes with Ubuntu looks really ugly. Here is a way to beautify Chinese Characters using Windows fonts like SimSun.

Copy simsun.ttc, tahoma.ttf from windows/fonts directory to /usr/share/fonts/zh_CN/TrueType,then update Ubuntu fonts list using the following command:

sudo mkdir -p /usr/share/fonts/zh_CN/TrueType
sudo cp simsun.ttc /usr/share/fonts/zh_CN/TrueType/
sudo cp tahoma.ttf /usr/share/fonts/zh_CN/TrueType/
sudo chmod 644 /usr/share/fonts/zh_CN/TrueType/*
cd /usr/share/fonts/zh_CN/TrueType/
sudo mkfontscale
sudo mkfontdir
sudo fc-cache /usr/share/fonts/zh_CN/TrueType/

Install and config Ubuntu on Vostro 200

Last week, I bought a new Vostro 200 from Dell with $4xx. Since I started working, I have not really worked on Linux environment at any client site. I feel that I'm disconnected from Linux, and it's the time to pick it up.

After I consulted several folks, I decided to go with the latest Ubuntu Desktop(7.04). Installation is straight forward. Downloading image, create installation CD, install it like Windows...After two hours, I had Ubuntu desktop running on my machine.

Oh, yeah!... But, wait...it's not done yet...and the pain starts...It took me quite a bit of time to have everything configured correctly. I would like to share my experience with other folks.

Firstly, I could not connect to network It looks like Ubuntu did not have the right Ethernet driver. The network card comes with the mother board, and it's supposed to use Intel(R) PRO/10/100/1000/10GbE Drivers. Here is what I did:

  • tar xfvz e1000-7.6.5.tar.gz
  • cd e1000-7.6.5/src
  • sudo make install
  • sudo modprobe e1000
Now you should see a wired connection available.

The next big problem was graphics card and monitor. The machine came with Intel GMA 3100(G33), but the driver comes with Ubuntu is out of date. Ubuntu only showed resolution up to 1280x1024, and it tried to stretch Dell E207WFP LCD to use this resolution. To fix the graphics card driver issue, I downloaded xserver-xorg-video-intel_2.1.0-1ubuntu1_i386.deb from http://ubuntuforums.org/attachment.php?attachmentid=37549&d=1183829057, you need have an account to download this file, double click the file and follow the prompt to install the driver. Instructed by an Ubuntu forum post, I modifed /etc/X11/xorg.conf to use the latest driver: In "Device" section, change Driver from "vesa" to "intel".

Restarted the computer, I see graphics card driver recognized. But after I logged into my account, the monitor went black and the following appeared in bright yellow in the middle of the window:

1: Analog Input
Cannot Display The Video Mode
Optimum Resolution 1680x1050 60 Hz


To solve this issue, I had to modify xorg.conf again, and put my monitor HorizSync/VertRefresh frequency in the "Monitor" section, as well as add wide screen resolution "1680x1050" into "Screen"-->"Display"-->"Modes" section.

This is a sample xorg.conf file with my changes highlighted(just find your own monitor specs and make corresponding changes, don't copy it to your configuration):

Section "InputDevice"
Driver "wacom"
Identifier "cursor"
Option "Device" "/dev/input/wacom"
Option "Type" "cursor"
Option "ForceDevice" "ISDV4" # Tablet PC ONLY
EndSection

Section "Device"
Identifier "Generic Video Card"
Driver "intel"
BusID "PCI:0:2:0"
EndSection

Section "Monitor"
Identifier "DELL E207WFP"
Option "DPMS"
HorizSync 30-83
VertRefresh 56-75
EndSection

Section "Screen"
Identifier "Default Screen"
# Device "Intel"
Device "Generic Video Card"
Monitor "DELL E207WFP"
DefaultDepth 24
SubSection "Display"
Depth 1
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
SubSection "Display"
Depth 4
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
SubSection "Display"
Depth 8
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
SubSection "Display"
Depth 15
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
SubSection "Display"
Depth 16
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
SubSection "Display"
Depth 24
Modes "1680x1050" "1280x1024" "1152x864" "1024x768" "800x600" "720x400" "640x480"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "stylus" "SendCoreEvents"
InputDevice "cursor" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"
EndSection

Section "DRI"
Mode 0666
EndSection


Hope my experience will help.

"Skipped" Unit Tests

Tests run: 11, Failures: 0, Errors: 0, Skipped: 5

This is a test report from a client CruiseControl site. What's the point to write unit tests and have them "skipped"?

FitNesse and Perforce

Perforce is a pessimistic locking version control system(all checked-in files are read only). FitNesse requires the files are open for edit while you make changes. It's a pain when you see "no permission" error until you save you changes, especially for QA folks who just transferred from manual testing to automated testing.

To solve this issue, we added a link in the FitNesse website, which allows them to make all the FitNesse "open for edit":

1. Implement Responder class(let's name it P4EditResponder) in FitNesse, and include it in Fitnesse classpath. And the code can be as simple as one line:
Runtime.exec("p4 edit //FITNESSE_ROOT/...");

2. Add plugins.properties in the FitNesse working directory, including the following item:
Responders=p4edit:P4EditResponder

3. Now you can use it in your FitNesse page:
[[Open For Edit][?responder=p4edit]]

4. Done! It's simple like that.

Check out http://fitnesse.org/FitNesse.PluginUsage if you still have issue.

I still have some issues with FitNesse and Perforce, any help is appreciated:

1. How to add a directory recursively into Perforce using windows command line? I would like to add another link on FitNesse page to allow QA folks to add new files into Perforce and checkin all the changes.

2. How does Perforce ignore works? I would like to ignore FitNesse version control and not checking in the zip files generated by FitNesse version control. Or just disable version control when FitNesse generates a new page.

Google was caught by stealing Sohu Pinyin dictionary

Several days ago, I talked about the new Google Pinyin. Unfortunately, the latest news says that Google stole Sohu's Chinese dictionary: http://www.chinadaily.com.cn/bizchina/2007-04/11/content_847897.htm

Google just released Pinyin Input method

Google just released its Chinese input method: http://tools.google.com/pinyin. It works very similar to Ziguang input(紫光). As always, you will not be disappointed by Google. As a big google fan, I'll say bye-bye to 紫光.

个人感觉Google还能火很长一段时间。昨天刚刚发布的Google Pinyin,今天在mitbbs上就已经被炒得十分火爆了。 Google就靠这些简单实用的小软件培养了一批铁杆的Google迷,想想它的市场会有多大。

Hibernate Exception - Simultaneously Fetch Multiple Bags

Today I bumped into the following Hibernate exception:


javax.persistence.PersistenceException: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
........
What's the problem? Because I have multiple one-to-many mappings in my hibernate object, and all of them require EAGER loading.

Check out this link: http://jroller.com/page/eyallupu?entry=hibernate_exception_simultaneously_fetch_multiple, it shows you three ways to fix the issue.

ThoughtWorks is hiring...

Thoughtworks is hiring in US right now. If you want to work with cool and smart people, check it out: http://www.thoughtworks.com/jobs/United-States-Job-Openings.html

How to display an image within a JSP from Database

I'm using Spring/Struts2/Hibernate in my current project. We have a requirement to upload an image into database, then display that image on the website within a jsp page. We wrote a servlet to stream out the image from database, but there is no way to test the code outside of the web container.

Then I tried to find a way to inject the Spring beans into the Servlet. Fortunately, Spring provides FrameworkServlet: Base servlet for servlets within the web framework. Allows integration with an application context, in a JavaBean-based overall solution. By extending FrameworkServlet, I could load Spring WebApplicationContext by setting "contextConfigLocation" parameter in web.xml.

This above solution made my code much simpler. Unfortunately, I still could not test the code outside of the web container, since it's so difficult to setup WebApplicationContext from a unit test. In the end, I had to do some tradeoff, by overwriting the initFrameworkServlet() method in FrameworkServlet, I could unit test the rest of the code but this method.

public class ImageStreamServlet extends FrameworkServlet {

private MyService myService;

protected void setMySerivce(MySerivce myService) {
this.myService= myService;
}

@Override
protected void doService(HttpServletRequest request,
HttpServletResponse response) throws Exception {

String id = request.getParameter("id");
MyObject myObject = MyService.findById(Long.parseLong(id));
if (myObject != null) {
response.reset();
response.setContentType(myObject.getImageType());
IOUtils.write(myObject .getImageData(), response
.getOutputStream());

}

/**
* This method is not covered by test...
*/
protected void initFrameworkServlet() throws ServletException {
super.initFrameworkServlet();
myService = (MyService ) getWebApplicationContext()
.getBean("myService ");
}

}


Basically, MyService can be mocked out in my test now:)

First Impression of Ruby

This week, I attended a company internal ruby/rails training.

Here is some thoughts after the training:

Technically:
1. Ruby on rails uses convention over configuration. The only so called configuration file is "routes.rb". Feeling the pain of adding/modifying 5+ files to create one web page in Tapestry/Spring/Hibernate application, "convention over configuration" is definitely a no-brainer.
2. Ruby class is never final. You can override/overwrite a method on the fly.
3. Implementing a "filter" in Ruby on Rails is simple comparing to Java Servlet Filters. It's plain ruby code, and can be easily tested.

Future:
Ruby/rails requires high quality developers. If you don't have developers following TDD and other agile principles, the project can easily be screwed up. So consulting companies with high quaility developers can easily get high rate for the work.

Consulting companies always try to chase the latest and greatest technology to achieve their financial goals. But with strong typed language like Java or .Net, consulting rate went down quickly after a lot of "regular" developers moved over. But Ruby itself has raised the bar, those companies who have chased ruby/rails should be able to charge the high rate for a longer period of time comparing to java/.net.

On the other hand, due to the above reason, I don't think Ruby/Rails can compete the market with Java/.Net in the near future.

Questions:
1. How is the general performance of the ruby application?
2. How does Ruby on Rails work with legacy code/database?
3. When will the Ruby open source continuous integration server available?
4. For people used to strong typed language, what's the easiest way to switch over?
5. Ajax and RoR?