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 –


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");
            }}
        ));

    }
}

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) –


 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);


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.

AngularJS

 

angular-js

AngularJS is a Javascript framework maintained by Google which simplifies the development and testing of web applications for developers and testers.

Core features –

1. MVC Framework –

Model is data. It can be static data or dynamically fetched from a data source using JSON.
View – This is UI (User Interface) or whatever is visible in the browser.
Controller – Controls the business logic of the application.

2. Two-way Data Binding –

It simply means that –
1. When properties in the model get updated, so does the UI.
2. When UI elements get updated, the changes get propagated back to the model.

3. Templates –

It allows you to create templates which can be used in other HTML pages.

4. Single Page Applications –

It simply points to the fact that navigation between different screens of the website is achieved without loading a different web-page in the browser.

Example – GMAIL – When you click on a message in your INBOX, browser stays on the same web-page, but JavaScript code hides the INBOX and brings the MESSAGE BODY on screen.