Friday, December 21, 2012

Gnome 3 Extension: System Monitor

I was missing a system monitor icon from the previous release of Gnome and finally had the time to look for a replacement in Gnome 3.
Go to the extension page with your favorite browser.
Install and enable the extension turning the button in the top left corner on.
Don't forget to configure the icon position clicking on the configure button or you'll find the calendar icon squeezed on the right and unreadable.

Tuesday, December 04, 2012

Fedora 17 Microphone not Working

If you can't use your headphones microphone on your newly installed Fedora 17 device, you first need to:
  1. Open your sound settings and check the proper  device is enabled.
  2. If yes, run alsamixer, select the sound card and make sure that the internal microphone and capture are enabled and that both Mic Boost and Capture have high volumes.
  3. Run arecord -D "hw:1,0,0" -f cd -d 4 test-mic.wav. The wav file created should have sound in it.
More details on this thread.

Thursday, November 29, 2012

gnome-tweak-tool to change Gnome 3 Settings

[Updated 2013-06-20]

You can modify the gnome settings using gnome-tweak-tool

E.g. The clock/date settings
If you want to show the date in the clock on the top bar:
  1. Launch the gnome-tweak-tool
  2. Go to the "Shell" menu
  3. Enable "Show date in clock"

Wednesday, November 28, 2012

Fedora 17: em1 Instead of eth0?

Network Interface Controllers (NIC) that are embedded on the motherboard are identified by udev as em1, em2, etc. This is part of an attempt to make interface naming more predictable and meaningful.
That's what you will find instead of eth0, eth1, etc.

To get back the old name go to: /etc/default/.
There you'll find the configuration file for the default Fedora boot loader, GRUB: grub

Add the following command (bold) to the line with the key GRUB_CMDLINE_LINUX:

GRUB_CMDLINE_LINUX="rd.md=0 rd.lvm=0 rd.dm=0 SYSFONT=True  KEYTABLE=us rd.luks=0 LANG=en_US.UTF-8 biosdevname=0 rhgb quiet"

Go to /boot/grub2, make a backup copy of grub.cfg and regenerate the GRUB configuration file:

> grub2-mkconfig -o grub.cfg

Reboot and eth0 will be back!

Hints here and there.

Saturday, October 27, 2012

Get Delete Command in Nautilus File Manager Menu

Hitting delete on a Nautilus file won't work like it used to in the past for "security" reasons.
If you want to, at least, have the delete context menu (right click) item to be able to bypass the send-to-trash behavior in the Nautilus file manager, you need to:
  1. Go to Edit --> Preferences
  2. Behavior Tab
  3. Check the Include a delete command that bypasses trash
That's it!

Friday, October 19, 2012

Upgrading BIOS on an Asus Motherboard

I was trying to upgrade the BIOS on a Asus P8H61-M PRO motherboard on a floppy-less PC.
Luckily this motherboard supports upgrading from the BIOS itself.
The problem was I got this error once the image was selected on a disk partition (strangely enough the BIOS saw only one of the two disks):
Selected file is not an EFI BIOS

It turned out the file should reside on a FAT32 partition while the one it was on was NTFS.
I put the new BIOS on a pen drive and the BIOS saw it, finally ending the story.
Side note: the error message was pretty useless, once again.

Thursday, July 19, 2012

Order of Annotated Controllers When Matching @RenderMapping and @ActionMapping

ConfigurationJDK 7, Spring 3.1.1.RELEASE and Hibernate 4.1.3.Final. Multiple annotated controllers.

When you invoke a Render or Action mapping, it might happen the default mapping is picked up instead of the correct one.
This happens when the controller with the default mapping is first in the list.

DEBUG [http-8080-1] (AbstractMapBasedHandlerMapping.java:74) - Key [view] -> handler [{org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping$RenderMappingPredicate@2e19e=my.package.controller.DefaultController@12a8bad, ...

It's probably a bug or I don't understand the purpose yet.
This can be fixed by forcing Spring to put the controller with the default mapping last. First you scan all others and separately the default one:

    <context:component-scan base-package="it.italiangrid.liferay.doclibadmin.controller" use-default-filters="true">
        <context:exclude-filter type="regex" expression="EmiDocumentController"/>
    </context:component-scan>
    
    <context:component-scan base-package="it.italiangrid.liferay.doclibadmin.controller" use-default-filters="true">
        <context:include-filter type="regex" expression="EmiDocumentController"/>
    </context:component-scan>

Update I found out that if you use @RequestMapping instead of @RenderMapping and @ActionMapping in all methods of the controller with the default action, the problem seems to disappear.
You can use render and action mapping annotations in all other controllers.

References

Thursday, July 12, 2012

Gnome 3: Add a Custom Item to Favorites

Install and run alacarte. This tool allows you to manage the applications you see in the window Activities --> Applications. Those shown there are a subset of the ones available.

  1. Create a new one in Alacarte with New Item in an existing or new menu.
  2. Check the Show checkbox.
  3. Go to Activities --> Applications and right click on the icon to add to the Favorites side bar.

Tuesday, July 10, 2012

Fedora 17: Disable Jetty

From this Fedora 17 announcement:


If you have updated from Fedora 16 and you had jetty installed, it was 
automatically enabled to start on reboot. If you are are not using jetty for 
serving web content, but it was installed as a dependency, please run the 
following command as root user:

# systemctl disable jetty.service

This will stop jetty from running automatically on system reboot. If you also 
want to stop the currently running jetty you can run following:

# systemctl stop jetty.service

Friday, June 29, 2012

BASH's Ctrl-r

Used to search a command in the history.
Usage: type the command and start entering what you're looking for. Once found you can...

Ctrl-r + ENTER = Execute.
Ctrl-r + left/right arrow = put it on the command line to edit.
Ctrl-r + Ctrl-r = Get an older command starting with the same characters typed.

Wednesday, June 13, 2012

Weird Things With Spring, Eclipse and Tomcat?

Everything was working and now an action seemingly still properly configured from a controller is simply ignored?
It's not Spring's or Eclipse's or your sister's fault.
Check you inadvertently didn't start another instance of Tomcat.
That's what happened to me! And I don't have sisters to blame!

Thursday, June 07, 2012

hibernate3:hbm2ddl - Could not determine type for: java.util.List

Trying to generate DB tables from Java classes, I got this error for this one-to-many mapping:

    @ElementCollection(targetClass = DocArea.class)
    @CollectionTable(name = "area_doc",
        joinColumns = @JoinColumn(name = "id_doc"))
    @Column(name = "id_area")
    public List getAreas() {
        return areas;
    }

where Area is an enumeration.
It was a version incompatibility between the hibernate3 plugin and Hibernate itself. I found out you can override a plugin's dependencies in the configuration of the plugin itself thanks to Ivar's post.

Thursday, May 17, 2012

Firefox 12 Way Too Slow on Fedora 16

I found these useful tips on how to customize Firefox and get it faster.
Now, when I have time I need to test if they're working because in the meantime I switched to Chrome despite my lifelong appreciation for the Fox. This is to tell you how unusable it has become.

Monday, May 14, 2012

No Cascade Delete on a Collection Relationship

I had the following relationship in a UserAnswer, the answer(s) a user can give to a question in a survey:

     public SortedSet getSelectedAnswers()

I wanted to propagate all persistence operations to the collection except DELETE. I didn't want an Answer to be deleted when all UserAnswers were removed.
This is how it worked for me: 

    @ManyToMany(targetEntity=Answer.class, cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
    @Cascade(org.hibernate.annotations.CascadeType.SAVE_UPDATE)
    @JoinTable(name="userAnswer_answers",
            joinColumns=@JoinColumn(name="userAnswer_fk"),
            inverseJoinColumns=@JoinColumn(name="answer_fk"))
    @Sort(type = SortType.COMPARATOR, comparator = AnswerPositionComparator.class)
    public SortedSet getSelectedAnswers() {
       
        return selectedAnswers;
    }


If you don't use CascadeType.ALL, Hibernate doesn't cascade the save of an entity's Collection properties when using the PERSIST annotation. You have to explicitly use the org.hibernate.annotations.CascadeType.SAVE_UPDATE annotation.

Source here.

Friday, May 11, 2012

Eclipse Code Templates

If you'd like to have your own text additions to a new file upon its creation, you can customize the way it is created with code templates.
Go to Window --> Properties --> Java --> Code Styles --> Code Templates.

You can customize comments and code components in this way at Eclipse level or project level.

Monday, January 30, 2012

hbm2ddl SchemaExport: You have an error in your SQL syntax near type=InnoDB

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB'

I used to create my MySQL DBs with ant and everything was working. Now, moving to maven and hbm2ddl I get this error.
After some searching it comes out that it's a problem of incompatibility between the MySQL Java connector (5.1) and the MySQL version (5.5) where type InnoDB was dropped and replaced with engine.

The solution is to change the MySQL dialect from org.hibernate.dialect.MySQLInnoDBDialect to org.hibernate.dialect.MySQL5InnoDBDialect.

Places where this generally occurs are hibernate.cfg.xml and hibernate.properties.

Tested on MySQL 5.5.22