Sunday 23 February 2014

Disable Google Chrome Notifications on Mac OS X

All Mac OS X users using Google Chrome browser might have recently noticed a new Google Notification icon ( a grey bell ) on the OSX menu bar.

You'll quickly notice that it's settings menu does not provide any intuitive way to exit or disable it.

In order to disable it, do the following :

Open Google Chrome browser.

In address bar, type chrome://flags

Now search for the option "Enable Rich Notifications" and change "Default" to "Disabled" from its drop down menu. Hope it helps.


Saturday 22 February 2014

Luxury Uber launches in Mumbai

Uber - the luxury pickup company has launched its operations in Mumbai. The current car fleet will feature Audi A8 and Mercedes E-class as well.

Signup now at this link and enter the promo code UberMumbaiLaunch to avail 2 free rides, valid till March 31 '14. Make sure you own an iPhone or an Android fone.

Costs : 

Base price : INR 100

For every kilometer : INR 17

Per minute surcharge : INR 2




Friday 21 February 2014

Getopts Tutorial - Command line options in Perl

In Perl, if we want the user to pass certain options at command line, we can define the switches in the program code using Getopts. Following is a brief tutorial underlying it's usage with a practical example.

First of all, search the CPAN for Getopt and you'll see a lot of available modules - each with a slightly distinct functionality. All serve the same purpose though - providing a framework for passing user-defined command line options.

Now, install either the Getopt::Long or Getopt::Compact or Getopt::Lucid module from CPAN. I assume you know how to install modules from the terminal. If not, dig in through this blog. You'll get the answers.

In this example, I'll use the highly rated Getopt::Long module. Make sure you refer the module's official documentation link for more details. The following illustration is about it's simple basic usage, just to give you a feel. I'll cover an advanced usage tutorial for this module in another post.

Ok guys, enough talk. Lets code some stuff. Here we go...

use strict;
use warnings;
use Getopt::Long;

my $name;
my $location;

GetOptions (

               'name=s' => \$name,
               'location=s' => \$location,
);

if ($name) {
          print "Welcome $name \n";
}

if ($location) {
          print "Hows the weather at $location \n";

}

Here, "name" and "location" are the options to which we pass an argument. Note that we have mentioned name=s and location=s. The alphabet 's' implies the switch will be of string type. If you want the switch to be of integer type, use i. ( Eg : 'age=i' => \$age ).

Also, the equal sign = indicates that it is a mandatory option. If you want an option to be optional, use the colon : sign ( Something like - 'help:h' => \$help ).

Save the program as Getopts_Ex.pl and now open the terminal. From the command line, run the program as follows :

perl Getopts_Ex.pl -name "IronCladZone" -location "New York"

The output would be as follows :


Note that you have to pass an argument for each mandatory option. If you don't pass an argument, you will get an error. You can also play around by defining a separate function with customized error messages or switches' usage. This can be extremely helpful to a newbie or a layman, informing him how to run the program and how to use the custom switches defined in the script.

The above code contains print statements within the "if" block. You can instead tweak the "if" block to call custom user-defined functions a.k.a subroutines from here and put the print codes in the subroutine. The output will be the same, but the below structure makes it more graceful and secure. In fact, I plan to cover the topic of subroutines in another fresh post. Stay tuned for that as well.

use strict;
use warnings;
use Getopt::Long;

my $name;
my $location;

GetOptions (

               "name=s" => \$name,
               "location=s" => \$location,
);

if ($name) {
          func_name();
}

if ($location) {
          func_location();

}


sub func_name()  {
            print "Welcome $name \n";
}

sub func_location()  {
            print "Hows the weather at $location \n";
}

Folks, do let me know your comments about this post and suggestions on how to improve the quality of the content. Ciao.

Tuesday 18 February 2014

Repeat last run command in Linux, Unix, OSX

In order to repeat the last run command on Linux, Unix, Apple OS X machines, type the following in terminal :

!!

Yes. That's precisely 2 exclamation marks.

Monday 17 February 2014

Perl Message Box Tutorial

Previously, we covered the Perl Listbox example using the Tk module. In this post, we will discuss about using Tk to create a simple Message Box.

First of all, install the Tk Msgbox module from the command line as follows:

sudo cpan Tk::MsgBox

Then consider the following code snippet : 

---------------------------------------------------------

use Tk;
use Tk::MsgBox;

my $m = MainWindow->new;

my $x = $m->MsgBox(
-title=> 'Perl MsgBox Example'
-message=> "Welcome to Tk Message Box"
-type=> 'okcancel'
);

my $button = $x->Show;

---------------------------------------------------------

The output window will be as follows :


In above example, we've used the okcancel box type. The msgbox type can be changed to one of the following : ok, okcancel, yesno, yesnocancel, retrycancel, abortretrycancel.

Even the info icon can be changed to error, warning types if needed.


List all Perl CPAN modules installed on the system

In order to list all the CPAN modules installed on a system, use the following command :

instmodsh

Now you'll see the following menu : 

Available commands are:
   l                      - List all installed modules
   m <module>   - Select a module

   q                     - Quit the program

cmd? l

On entering option l, it will display the complete list of modules installed on the system.

Eg: 

   Net::HTTP
   PDF::API2
   PDF::Report
   PDF::Report::Table
   PDF::Table
   Params::Validate
   Parse::CPAN::Meta
   Perl
   Perl::Destruct::Level
   Perl::OSType
   Probe::Perl
   SOAP::Lite

Wednesday 12 February 2014

Oracle Weblogic 12c Installation Guide on Mac OSX

This post will walk you through the installation of Oracle Weblogic Application Server 12c on a Mac OSX machine.

First of all, visit the official Oracle Weblogic download page and download the latest generic version. You would need to create a Oracle ID first. Accept the agreement and start the download. In this example, we would download the Weblogic v12.1.2. The filename in this case is wls_121200.jar

Also, note that the generic version does not come with JVM / JDK for its installation. So make sure, you have Java installed on your machine.

Once downloaded, note the following steps :

Run the following command to initiate the installer

java -d64 -Dspace.detection=true -Xmx1024m -jar wls_121200.jar

This will start the extraction of the wls_121200.jar and also perform some routine system pre-requisite checks. Note the arguments that we passed. The space.detection parameter is set to true to detect available space. Also, the max memory usage size by JVM is set to 1024m i.e 1 GB.


Now, you'll the following installer GUI screens.



In the next screen, you'll see the option to modify or change location of Oracle_Home directory. Leave it to default option if you don't want to modify the location. Click Next.


In the following screen, you have to choose the type of installation. Choose the default option. However, choosing the Complete Installation will also install OPatch and some examples like medrec. 


In next screen, you can see the overall Installation summary. Save the response file if you intend to perform silent installations in the future. Check this link for reference. Click Next.


This will start the installation process. This will take a few minutes. You can observe the overall progress here.



Once the installation is completed, you'll see the following screen. Click Finish. This will initiate the next step - Configuration Wizard.


Below is the welcome screen of the Wizard.


Following is the first screen of the Configuration Wizard. Here you can set the Weblogic Administrator account and define the Parent domain location. Click Next.


In next screen, you'll see the progress of the domain creation.


Now, in the next and final screen, you'll see the Configuration success scene. Here you can check the option to start domain. Leave it unchecked, so that we can start it manually. Click Finish. That's pretty much a plain vanilla installation of Oracle Weblogic server 12c on Mac OSX machines.

In my next post, I'll cover how to start and stop Weblogic 12c and any associated issues related to it.
Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker