Pages

Wednesday, 3 October 2012

Solution for Skype crashing on Linux Mint or Ubuntu

It seems a familiar error with Ubuntu/Linux Mint users, Skype silently crashes and you can't receive messages without any notifications, the simplest resolution to check is try to change your status (Online, Away, ...) and if it can't change status, just kill Skype and restart. But it becomes really annoying when it occurs repeatedly and you have to check your status regularly.

On my Linux Mint 11 (Katya), this problem often occurs along with the sound crashing error. So I guess maybe there's some conflict between sound system and Skype. Just try to remove all Skype notifications sound (the popups remain), go to Options --> Notifications then uncheck all 'Play sound file' radios.

Now the Skype and sound run so smoothly :).

Monday, 16 July 2012

Restart Linux Mint sound without reboot machine

Sometimes the sound in Linux Mint (I used 11 Katya) seems crashed, especially if you often use hibernate mode, then you can't play sound, music or Youtube video... The simplest solution, of course, is reboot your machine, but it's really annoying, after do some searches, I've found a better way to restart sound system.

Refer to this page http://superuser.com/questions/17312/restart-ubuntu-sound-processes-via-command-line

The solution for Mint is almost the same, first find which process is holding PCM:
 lsof | grep pcm 

The result is something like:
 chrome   3145     admin mem    REG    8,8  22076    5892 /usr/lib/alsa-lib/libasound_module_pcm_pulse.so 
 plugin-co 7171     admin mem    REG    8,8  22076    5892 /usr/lib/alsa-lib/libasound_module_pcm_pulse.so 
 pulseaudi 12954     admin mem    CHR   116,3        2394 /dev/snd/pcmC0D0p 
 pulseaudi 12954     admin  29u   CHR   116,3   0t0    2394 /dev/snd/pcmC0D0p 

Then kill the appropriate process with:
 kill -9 12954 

Restart the sound:
 sudo service alsa-store start 

Friday, 8 June 2012

Override maven plugin dependencies

I met the problem about the conflict versions of datanucleus-core between the one I declared in pom dependencies section and the datanucleus-core dependency in datanucleus maven plugin.

The root cause is the datanucleus maven plugin always check for newest datanucleus-core version (it's declared  as (2.9, ) in maven-datanucleus-plugin pom), so the plugin get the datanucleus-core-3.1.0-m3 while the datanucleus-core used in my project is 3.0.5 and error happened.

The simple solution is to force the maven plugin to use datanucles-3.0.5

<plugin>
  <groupid>org.datanucleus</groupid>
  <artifactid>maven-datanucleus-plugin</artifactid>
  <version>3.0.1</version>
  <configuration>
    <api>JDO</api>
    <verbose>true</verbose>
  </configuration>
  <executions>
    <execution>
      <phase>compile</phase>
      <goals>
        <goal>enhance</goal>
      </goals>
    </execution>
  </executions>
  
  <dependencies>
    <dependency>
      <groupid>org.datanucleus</groupid>
      <artifactid>datanucleus-core</artifactid>
      <version>3.0.5</version>
    </dependency>
  </dependencies>
</plugin>

Friday, 2 March 2012

GWT: Trick for SuggestBox to make it work as ListBox

For example, when user selects Country from Country SuggestBox, we want to get not only the country name (as display string and replacement string of this suggestion) but also country id, code, ... from the corresponding Country object.



public static class CountryOracle extends MultiWordSuggestOracle { 

  public Map countries = new HashMap(); 

  @Override public void requestSuggestions(Request request, Callback callback) {  
    super.requestSuggestions(request, callback); 
  } 

  public void add(Country country) {
    super.add(country.getName()); 
    countries.put(country.getReplacementString(), country); 
  } 
} 

CountryOracle oracle = new CountryOracle();
List countries = DataProvider.getCountries();
if (countries != null) {
  for (Country c : countries) {
    oracle.add(c);
  }
}

SuggestBox suggestBox = new SuggestBox(oracle);
suggestBox.addSelectionHandler(new SelectionHandler() {
  @Override
  public void onSelection(SelectionEvent event) {
   // now we can get the country id via:
   // oracle.countries.get(event.getSelectedItem.getRepleacementString()).getId()
  }
}); 


Saturday, 25 February 2012

GWT KeyPressHandler doesn't work for your widget? Use KeyDownHandler instead.

If you want to catch the 'Enter' or 'Escape' key press event on your GWT widget (FocusPanel, TextBox, ...) and have tried the KeyPressHandler but not success, try to switch to the KeyDownHandler


outer.addKeyDownHandler(new KeyDownHandler() {     
  public void onKeyDown(KeyDownEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
      loginButton.click();
    } else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
    cancelButton.click();
    }
  }
});

Monday, 6 February 2012

Hadoop: My first play with HDFS

Meet Hadoop!!!
Finally, I have started to explore the popular, robust and scalable framework for distributed and high parallel computing application. I have a plan to work with Hadoop long time before, but till now, I can experience Hadoop in a serious project. And I will move fast forward from now because Hadoop will hold a important role in my current data processing project :)




Sunday, 5 February 2012

JDO Sample project with DataNucleus 3

/**updating ...*/

In this article, I will write a simple demo program to demonstrate the use of JDO to persist data to database.

This program will show a simple sport store, the products in store are sport clothes, kits, shoes, accessories, ...

So, the database schema here looks simple: we have two types of entity, one for category, and one for product. We also have an one-to-many relation from a product to a list of categories, it means that a product maybe belongs to more than one categories. Also notice that, of  course, in a category, we can have a number of products, but in this simple example, I will not use a many-to-many relation, so the categories don't know anything about product.

We have some prerequisites use in this example:
  1. MySQL 
  2. Data Nucleus 3.0
You can find these components from the pom.xml of this sample project.

Initialize project structure


Write POJOs to leverage JDO, ORM


Data persistent class


Put some UI to manage your store


Conclusion