How to show custom favicon in Vaadin UI ?

Add this custom Vaadin servlet to show a different favicon (other than the Vaadin default) in your UI application –

[java]

import com.vaadin.server.*;
import com.vaadin.spring.server.SpringVaadinServlet;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;

@Component(“vaadinServlet”)
public class CustomServlet extends SpringVaadinServlet {

@Override
protected void servletInitialized() throws ServletException {
super.servletInitialized();

getService().addSessionInitListener((SessionInitListener) event -> event.getSession().addBootstrapListener(new BootstrapListener() {

@Override
public void modifyBootstrapFragment(
BootstrapFragmentResponse response) {
// TODO Auto-generated method stub

}

@Override
public void modifyBootstrapPage(BootstrapPageResponse response) {
response.getDocument().head().
getElementsByAttributeValue(“rel”, “shortcut icon”).attr(“href”, “./images/favicon.png”);
response.getDocument().head()
.getElementsByAttributeValue(“rel”, “icon”)
.attr(“href”, “./images/favicon.png”);
}}
));

}
}

[/java]

Openfire does not listen to port 5222

Problem : Openfire server does not listen to port 5222.

Symptoms :

  1. netstat -tulpn | grep LISTEN
    • – will not show ports 5222 or 5223.
  2. tail -1000 /opt/openfire/logs/stderror.log
    • Will show these entries –
      • Error starting 5222: null
        Error starting 5223: null
        Error starting 5275: null
        Error starting 5276: null
        Error starting 5262: null
        Error starting 5263: null

Reason : Unknown – but related to OpenJDK.

Fix : Run OpenFire on Oracle JDK (v8 worked, didn’t test on v9)

Extract a selected polygon from an image to a new image file in Java

A reference code to extract a selected shape (this case polygon, could be another shape like Rectangle) –

[java]

BufferedImage in = ImageIO.read(new File(sourceFilePath));

Rectangle bounds = inputPolygon.getBounds(); // Polygon inputPolygon

BufferedImage extractor =new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_INT_ARGB);

Graphics2D g = extractor.createGraphics();

polygon.translate(-bounds.x, -bounds.y);

g.setClip(polygon);

g.drawImage(in, -bounds.x, -bounds.y, null);

File extImageFile = new File(targetFilePath);

ImageIO.write(extractor, “png”, extImageFile);

[/java]

Torch installation fails with message “Error. OpenBLAS could not be compiled”

Problem : Torch installation fails to install dependencies (“bash install-deps”) with the message “Error. OpenBLAS could not be compiled”

Reason : gfortran dependencies could not be located.

Fix : Make sure gfortran and gcc are of the same versions. On terminal –

gcc --version
gfortran --version
sudo update-alternatives --config gcc
Enter the number corresponding to the version of gfortran. (my case 5)
Run install-deps again.

Should finish to completion this time.

Fix : No sound on Ubuntu (16.04) after a Bluetooth audio device power off.

Problem : After Bluetooth speakers were abruptly switched off, Ubuntu 16.04 on Alienware (17 R2) stopped producing sounds on its analog sound card.

Reason : Doubt an inviable configuration was left behind for the sound card.

Solution :

  • Open terminal
  • Run –
    killall pulseaudio; rm -r ~/.config/pulse/* ; rm -r ~/.pulse*
  • Wait for 10 seconds.
  • Reboot the machine. (Fully power off and then boot)
  • This should fix the problem, else look into the reference link below.

Reference : https://help.ubuntu.com/community/SoundTroubleshootingProcedure

Installing NetBeans IDE in Linux

Go to the link – https://netbeans.org/downloads/
Select Platform as Linux(x86/x64).

Download the installer for NetBeans.

Net1
From the terminal, navigate to the directory that contains the installer (netbeans-8.1-linux.sh)
Run the following command to change the permissions –
$ chmod +x netbeans-8.1-linux.sh

Start the installer using the command –
$ ./netbeans-8.1-linux.sh

Follow the steps and NetBeans would be installed.