Thursday, January 1, 2015

2015 Federal Holidays

2015 Holiday Schedule
DateHoliday
Thursday, January 1New Year’s Day
Monday, January 19Birthday of Martin Luther King, Jr.
Monday, February 16*Washington’s Birthday
Monday, May 25Memorial Day
Friday, July 3**Independence Day
Monday, September 7Labor Day
Monday, October 12Columbus Day
Wednesday, November 11Veterans Day
Thursday, November 26Thanksgiving Day
Friday, December 25Christmas Day
*This holiday is designated as "Washington’s Birthday" in section 6103(a) of title 5 of the United States Code, which is the law that specifies holidays for Federal employees. Though other institutions such as state and local governments and private businesses may use other names, it is our policy to always refer to holidays by the names designated in the law.
** July 4, 2015 (the legal public holiday for Independence Day), falls on a Saturday. For most Federal employees, Friday, July 3, will be treated as a holiday for pay and leave purposes. (See 5 U.S.C. 6103(b).)

Monday, December 1, 2014

Sending Mail in Perl

Using MIME::Lite module

You could write your own email client using MIME:Lite perl module. You can download this module from MIME-Lite-3.01.tar.gz and install it on your either machine Windows or Linux/Unix. To install it follow the following simple steps:
$tar xvfz MIME-Lite-3.01.tar.gz
$cd MIME-Lite-3.01
$perl Makefile.PL
$make
$make install
That's it and you will have MIME::Lite module installed on your machine. Now you are ready to send your email with simple scripts explained below.

SENDING A PLAIN MESSAGE

Now following is a script which will take care of sending email to the given email ID:
#!/usr/bin/perl
use MIME::Lite;
 
$to = 'abcd@gmail.com';
$cc = 'efgh@mail.com';
$from = 'webmaster@yourdomain.com';
$subject = 'Test Email';
$message = 'This is test email sent by Perl Script';

$msg = MIME::Lite->new(
                 From     => $from,
                 To       => $to,
                 Cc       => $cc,
                 Subject  => $subject,
                 Data     => $message
                 );
                 
$msg->send;
print "Email Sent Successfully\n";

SENDING AN HTML MESSAGE

If you want to send HTML formatted email using sendmail then you simply need to add Content-type: text/html\n in the header part of the email. Following is the script which will take care of sending HTML formatted email:
#!/usr/bin/perl
use MIME::Lite;
 
$to = 'abcd@gmail.com';
$cc = 'efgh@mail.com';
$from = 'webmaster@yourdomain.com';
$subject = 'Test Email';
$message = '<h1>This is test email sent by Perl Script</h1>';

$msg = MIME::Lite->new(
                 From     => $from,
                 To       => $to,
                 Cc       => $cc,
                 Subject  => $subject,
                 Data     => $message
                 );
                 
$msg->attr("content-type" => "text/html");         
$msg->send;
print "Email Sent Successfully\n";

SENDING AN ATTACHEMENT

If you want to send an attachement then following script serve the purpose:
#!/usr/bin/perl
use MIME::Lite;
 
$to = 'abcd@gmail.com';
$cc = 'efgh@mail.com';
$from = 'webmaster@yourdomain.com';
$subject = 'Test Email';
$message = 'This is test email sent by Perl Script';

$msg = MIME::Lite->new(
                 From     => $from,
                 To       => $to,
                 Cc       => $cc,
                 Subject  => $subject,
                 Type     => 'multipart/mixed'
                 );
                 
# Add your text message.
$msg->attach(Type         => 'text',
             Data         => $message
            );
            
# Specify your file as attachement.
$msg->attach(Type        => 'image/gif',
             Path        => '/tmp/logo.gif',
             Filename    => 'logo.gif',
             Disposition => 'attachment'
            );       
$msg->send;
print "Email Sent Successfully\n";
You can attache as many as files you like in your email using attach() method.

Using SMTP Server

If your machine is not running an email server then you can use any other email server available at remote location. But to use any other email server you will need to have an id, its password, URL etc. Once you have all the required information, you simple need to provide that information in send()method as follows:
$msg->send('smtp', "smtp.myisp.net", AuthUser=>"id", AuthPass=>"password" );
You can contact your email server administrator to have above used information and if a user id and password is not already available then your administrator can create it in minutes.

Thursday, November 13, 2014

Isolating CPUs from the general scheduler in Linux.

It could be done using the kernel parameters:

isolcpus=

Format:

<cpu number>,...,<cpu number>

or

<cpu number>-<cpu number>

(must be a positive range in ascending order) or a mixture

<cpu number>,...,<cpu number>-<cpu number>

This option can be used to specify one or more CPUs to isolate from the general SMP balancing and scheduling algorithms. You can move a process onto or off an "isolated" CPU via the CPU affinity syscalls or cpuset.

<cpu number> begins at 0 and the maximum value is "number of CPUs in system - 1".

This option is the preferred way to isolate CPUs. The alternative -- manually setting the CPU mask of all   tasks in the system -- can cause problems and suboptimal load balancer performance.

Taken from /usr/share/doc/kernel-doc-2.6.32/Documentation/kernel-parameters.txt

Boot parameters of the running kernel in Linux

Let's say I need to find out with what parameters did the kernel boot?

The following command will give you the answer:

cat /proc/cmdline

For example:

janeiros@harlie:~$ cat /proc/cmdline
BOOT_IMAGE=/vmlinuz-3.0.0-32-generic-pae root=/dev/mapper/harlie-root ro quiet


Tuesday, October 28, 2014

Endianness mnemotechnic


A long time ago I had a difficult time trying to remember the differences between Big Endian and Little Endian. I came out with this little trick to make it easier to remember: associate Low with 0.

In Big Endian, you store the most significant byte in the smallest address. In Little Endian, you store the least significant byte in the smallest address.

http://en.wikipedia.org/wiki/Endianness