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.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




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.

Installing Oracle Database XE in Linux

To install Oracle Database XE:

1. Log on to your computer with root permissions.

2. Go to the following Web site:

3. Accept License Agreement and download the Linux version of Oracle Database XE.

4. Run the Oracle Database XE executable oracle-xe-11.2.0-1.0.x86_64.rpm to install Oracle Database XE using the command –
# rpm -ivh downloads/oracle-xe-11.2.0-1.0.x86_64.rpm

The installation displays a status of its progress.

5. When prompted, run the following command –
# /etc/init.d/oracle-xe configure

6. Enter the following configuration information –
A valid HTTP port for the Oracle Application Express (the default is 8080)
A valid port for the Oracle database listener (the default is 1521)
A password for the SYS and SYSTEM administrative user accounts
Confirm password for SYS and SYSTEM administrative user accounts
Whether you want the database to start automatically when the computer starts (next reboot)

This completes configuration.

Using Database Link in Oracle

Suppose data from a table X in database D is to be copied into table Y in the same database, then the problem can be solved easily by executing the query –


X(C(1),C(2),C(3)….C(N)) == Y(C(1),C(2),C(3)….C(N)) where C(1),C(2),etc. denote the columns of the table.


Problem –

Data from a table X in database D1 has to be copied to table Y in database D2.

Assumption –

X(C(1),C(2),C(3)….C(N)) == Y(C(1),C(2),C(3)….C(N)) where C(1),C(2),etc. denote the columns of the table.

Workaround –

Oracle SQL Developer allows you to create INSERT query for each record in the table. The queries generated can be executed in database D2. But, suppose the table contains 2,00,000 records, it would take approximately 30 minutes to generate the INSERT script and almost an hour to execute the script.

Solution –

Login as SYSDBA(Database Administrator) using the query –


Allow the user to create database links using the query –

GRANT CREATE DATABASE LINK TO <userSchemaName(D2 in this case)>;

Connect to schema D2 and execute the query –


Execute the query –


Add Desktop Shortcut in Ubuntu



Here’s how to create a desktop shortcut in Ubuntu –

  1. Go to the location of the file you want to access from Desktop (using the file explorer).
  2. Right click => Make Link
  3. Right click newly created link file => Click Move to..
  4. Select Desktop as the location in the target selection dialog box.

Number system in Treta Yuga


These interesting slokas from Ramayana, gives an understanding of the number system used during Thretha yuga

शतम् शतसहस्राणाम् कोटिमाहुर्मनीषिणः ||
शतम् कोटिसहस्राणाम् शङ्कुरित्यभिधीयते |

100 = Shatham

1000 = Sahasram

100,000 = ShathaSahasram (or Sahasranam Shatham or Laksham)

10^7 = Koti

10^12 = Shanku

शतम् शङ्कुसहस्राणाम् महाशङ्कुरिति स्मृतः ||
महाशङ्क्य्सहस्राणाम् शतम् वृन्दमिहोच्यते |

10^17 = MahaShanku

10^22 = Vrundam

शतम् नृन्दसहस्राणाम् महावृन्दमिति स्मृतम् ||
महावृन्दसहस्राणाम् शतम् पद्ममिहोच्यते |

10^27 = MahaVrundam

10^32 = Padmam

शतम् पद्मसहस्राणाम् महापद्ममिति स्मृतम् ||
महापद्मसहस्राणाम् शतम् खर्वमिहोच्यते |

10^37 = MahaPadmam

10^42 = Kharvam

शतम् खर्वसहस्राणाम् महाखर्वमिति स्मृतम् ||
महाखर्वसहस्राणाम् समुद्रमभिधीयते |

10^47 = MahaKharvam

10^52 = Samudram

शतम् समुद्रसाहस्रमोघ इत्यभिधीयते ||
शतमोघसहस्राणाम् महौघ इति विश्रुतः |

10^57 = Ogha

10^62 = Mahaugha

Higher numbers were presented using combinations of above numbers. Great, isn’t it ?

Installing Ubuntu on Alienware 17 R2



Heres how I could get my Alienware 17 working on Ubuntu –

  1. Connect the machine to Internet using a LAN cable.
  2. Change these after entering BIOS setup
    1. Set boot mode to Legacy
    2. Bring up the priority of the USB drive above hard disk in boot device list.
    3. Save and restart.
  3. Install Ubuntu from a USB stick.
  4. After booting to newly installed Ubuntu –
    1. Install Wifi
      1. Open Terminal
      2. sudo apt-get upgrade
      3. yeah that’s it. Atheros Qualcomm Killer Wifi driver would now be installed.
      4. Restart the system, look for Wifi icon in status bar to verify.
    2. Install NVidia GeForce Graphics card driver
      1. Open Terminal
      2. sudo add-apt-repository ppa:graphics-drivers/ppa
      3. sudo apt-get update
      4. sudo apt-get install nvidia-358 nvidia-settings  ( nvidia-358 was the latest version when I installed. Please find the current version from here )
      5. Restart, verify if “GeForce GTX ** ” is shown as the Graphics card in “About This Computer” dialog.
    3. Fix issue with headphones not working –
      1. Open Terminal
      2. alsamixer
      3. Press F6
      4. Select “HDA Intel PCH” card
      5. Press right arrow till the Item shown is “HP/Speaker Auto Detect”
      6. Press M to set it on.
      7. Connect headphones and verify if it works.

Your Linuxed Alienware should now be up with sound, graphics and Wifi and Bluetooth working without issues.

References :