Sunday 15 December 2013

Adding New short cut to Ubuntu 12.04 Launcher

Adding a new shortcut to ubuntu luncher is easy. I added launcher to SpringToolSuit with following steps. Final output will be as shown in the following image.

add a new file to /usr/share/applications/STS.desktop

Enter the following command in terminal


sudo gedit /usr/share/applications/STS.desktop



Remember to use the '.desktop' with file name and add the follwowing script.

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=STS 3.0.0
Version=1.0
Type=Application
Terminal=false
Exec=/opt/custom/STS_new/sts-3.0.0.RELEASE/STS    #this is path to your launcher
Icon=/opt/custom/STS_new/sts-3.0.0.RELEASE/icon.xpm # this is the icon for the launcher.
Actions=New;
[Desktop Action New]

# Adding new instance functionality add the following lines.
Name=New Instance
Exec=/opt/custom/STS_new/sts-3.0.0.RELEASE/STS &

Now click on dash home and type STS and you will see the icon. Click on it to launche the application. Once the application starts. Right click on the icon and click "Lock to Launcher". Now you can start the application by clicking on the icon.

Thursday 28 November 2013

Javascript to flushout MongoDB databases

Here is a javascript that flushes out data from multiple MongoDB databases. You will not need to open each database and use the command
db.collectionName.remove
on each collection.

Here is the script

getting all mongoDB databases
var dbs = db.getMongo().getDBNames();
 If you want to flushout some specifice databases' data, then add them to an array
var dbs = ["DB1","DB2","DB3","DB4"];
for(var i in dbs){
    db = db.getMongo().getDB( dbs[i] );
    print( "Using Database ==> " + db.getName() );
   
if you want to completely drop the database then just use following one line 
//db.dropDatabase();
if you don't want to drop database and just want to remove data from collection, use following code, it will not remove the indexes or username and password if set for database
    db.getCollectionNames().forEach(function(collection) {
    if(collection != 'system.indexes' && collection != 'system.users') {
    print("Removing Data from collection ==> :" +collection);
        db.getCollection(collection).remove();
    }
  });
}

 Save the script as a .js file (e.g. flushdbs.js). you can run the script with following command
mongo < /path/to/script/flushdbs.js

or start mongodb and enter

> load("/path/to/script/flushdbs.js")




Saturday 20 July 2013

Disable Finger print authentication on Ubuntu 12.04

After Enabling finger print authentication on ubuntu 12.04, i found it frustrating as i needed to scan my finger print multiple times to get authenticated. So i disabled it to use password mechanism again.

To disable finger print authentication use the following command on ubuntu console:

sudo pam-auth-update

It will open a pop up window as show below.

img
uncheck the first two option. You can navigate through arrow keys and press space to check/uncheck the options. Then use "Tab" to navigate to Ok and press "Enter" to complete the process.
Finger print authentication will be gone.