Webmin private key error when activating SSL mode

After getting your SSL certificate signed by an authority, you may go to Webmin -> Webmin Configuration -> SSL Encryption to enable SSL mode.
The key fields are Private key file, Certificate file and Additional certificate files (for chained certificates). Possible issue: In my case, I just copied the private.key content into /etc/webmin/miniserv.pem but it wasn't that simple. The private.key file was generated by openssl and had the following format:
Once I hit save button, webmin failed to restart with the following error in the log (/var/webmin/miniserv.error)
Failed to open SSL key /etc/webmin/miniserv.pem at /usr/libexec/webmin/miniserv.pl line 4332.
Error: Webmin server did not write new PID file
It took me a little while to realise that webmin couldn't interpret the file due to ENCRYPTED bit indicating it isn't a PEM format. Solution: After googling how to convert private key to PEM format, I came up with this.
mv /etc/webmin/miniserv.pem /etc/webmin/miniserv.pem.key
openssl rsa -outform PEM -in /etc/webmin/miniserv.pem.key -out /etc/webmin/miniserv.pem
Assuming restarting webmin will be all it takes but another problem occurred. Webmin relies on perl and particularly perl-Net-SSLeay module to read SSL encrypted files. However, my key has a passphrase which Webmin requires perl-PAM module to read. So bellow is the result of another google search.
yum install perl-CPAN
perl -MCPAN -e shell
install Authen::PAM
Once, that's done, webmin can be restarted without problem.

Some complex but useful Linux commands

Find upgradable bower dependencies
bower list | sed 's/^[├└─┬│ ]*//g' | sort | uniq | egrep 'available|latest'

Find all bower dependencies
bower list | grep '#' | sed 's/^[├└─┬│ ]*//g' | sed 's/#.*//g' | sort | uniq

Find declared bower dependencies
awk '/dependencies/{f=1;next} /resolutions/{f=0} f' bower.json | grep -v '}' | sed 's/^[ "]*//g' | sed 's/".*//g' | sort | uniq

Find unlisted/undeclared bower dependencies
diff <(bower list | grep '#' | sed 's/^[├└─┬│ ]*//g' | sed 's/#.*//g' | sort | uniq) <(awk '/dependencies/{f=1;next} /resolutions/{f=0} f' bower.json | grep -v '}' | sed 's/^[ "]*//g' | sed 's/".*//g' | sort | uniq)

Check custom elements used vs imports
diff <(grep -hroE --include \*.html "[/\"][a-zA-Z0-9]+(-[a-zA-Z0-9]+)+\.html" . | cut -c2- | rev | cut -c6- | rev | sort | uniq) <(grep -hroE --include \*.html "<[a-zA-Z0-9]+(-[a-zA-Z0-9]+)+[ >]" . | tr -d '< >' | sort | uniq) -y

Search and replace recursively
grep -lrZ --include \*filepattern "searchtext" . | xargs -0 -l sed -i -e 's/searchtext/newtext/g'
SSH Tunnelling from Local to Remote
ssh -f -v -4 user@ssh_server_ip -p <ssh_port> -L <local_machine_bind_ip>:<local_listening_port>:<accessing_ip_from_server>:<accessing_port> -N

Sites to find absolute-free photos for blogs or websites



How to fix Eclipse's black background tooltip in Ubuntu

Insert the following into ~/.config/gtk-3.0/gtk.css
@define-color tooltip_bg_color #FFFFE1;
@define-color tooltip_fg_color #343434;
@define-color theme_tooltip_bg_color @tooltip_bg_color;
@define-color theme_tooltip_fg_color @tooltip_fg_color;

.tooltip {
    background-color:   @theme_tooltip_bg_color;
    color:              shade(@theme_tooltip_fg_color, 0.90);
    text-shadow:        none;
.tooltip * {
    background-color: @theme_tooltip_bg_color;

Bonus: to debug Eclipse (or any Gtk+ program), just launch it from the terminal with the following:
GTK_DEBUG=interactive /path/to/your/program

Creating PDF in PHP

FPDF is a PHP class which allows developers to generate PDF files with straight PHP, without using the PDFlib library.









Mailing list archive:


Demo site:


Sending email in PHP

The mail() function in PHP is prototyped as follows:

bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

This means that in its simplest form, we need only specify the recipient, the subject, and the message. We can also specify extra parameters (for example, the from address).

You’ll notice from the return type of the function that a Boolean is returned upon completion. If PHPsuccessfully passed the email to the SMTP server then true is returned. If an error occurred then false is returned. Please note that even if true is returned the mail may not be sent! (For example if the SMTP is incorrectly configured. In this case you should consult your SMTP server logs to see what went wrong).

To send the email from the previous section – with error checking – we use the following code:

$to = “johndoe@fakedomain.com”;
$from = “janedoe@anotherfakedomain.com”;
$subject = “This is a test email”;
$message = “Dear John, This is a fake email, I hope you enjoy it. From Jane.”;
$headers = “From: $from ”;
$success = mail($to, $subject, $message, $headers);
if ($success) {
echo “The email to $to from $from was successfully sent”;
} else {
echo “An error occurred when sending the email to $to from $from”;

It is also possible to send an email to multiple recipients with a single call to the mail() function. Here is an example. All you need to do is modify the recipient variable as follows:

$to = "johndoe@fakedomain.com, somebodyelse@fakedomain.com";

Sending HTML emails in PHP

There is no real trick to sending HTML formatted email. After all, it’s only text – just as normal emailmessages are. The difference is in how email clients interpret that text.

The main step involved is in telling the email client that the email is HTML and not plain text. To do this we simply add the Content-type header. HTML uses the text/html mime type. Plain text emails use text/plain.

Here is an example:

$to = "johndoe@fakedomain.com";
$from = "janedoe@anotherfakedomain.com";
$subject = "This is a test email";
$message =<<<EOF
<strong>Hello World!</strong>
$headers = "From: $from\r\n";
$headers .= "(anti-spam-content-type:) text/html\r\n";
$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
echo "An error occurred when sending the email to $to from $from";

Simplifying life with PEAR

In the previous two chapters I showed how to send plaintext and HTML emails. The main limitation with doing HTML as I showed in the previous chapter is that in an email client that doesn’t support HTML email, the user sees a bunch of HTML tags.

The solution to this is to send a multi-part email. That is, within the one message, send a plaintext version and a HTML version. Unfortunately this is complicated with the mail() function as-is.

In order to get around this, we use the Mail_Mime class from the Pear repository. This also allows us to send attachments with our email.

In the following example, we use the Mail_Mime class to send an email with both plain text and HTML, as well as an attachment. Comments are included in the code to explain what is happening.

require_once('Mail.php'); // These two files are part of Pear,
require_once('Mail/Mime.php'); // and are required for the Mail_Mime class
$to = "johndoe@fakedomain.com";
// the email address of the person receiving the email
$from = "janedoe@anotherfakedomain.com";
// the email address of the sender
$subject = "This is a test email";
// the subject of the email
$attachment = "/path/to/someFile.pdf";
// the path to the file we are attaching to the email
// Next we must build an array of email headers for the email.
// This is structured slightly differently to the mail() function.
// The array key is the header name. Remember that subject
// is a header too!
$headers = array('From' => $from,
'Subject' => $subject);
// Here we create the plaintext version of the email to be sent
$textMessage = "Dear John,\n\nThis is a fake email, I hope you enjoy it.\n\nFrom Jane.";
// Here we create the HTML version of the email to be send, using
// the heredoc syntax
$htmlMessage = <<<EOF
<strong>Hello World!</strong>
$mime = new Mail_Mime();
// create a new instance of the Mail_Mime class
// set our plaintext message
// set our HTML message
// attach the file to the email
$body = $mime->get();
// This builds the email message and returns it to $body.
// This should only be called after all the text, html and
// attachments are set.
$hdrs = $mime->headers($headers);
// This builds the corresponding headers for the plaintext,
// HTML and any other required headers. It also includes
// the headers we created earlier by passing them as an argument.
$mail = &Mail::factory('mail');
// Creates an instance of the mail backend that we can use
// to send the email.
$mail->send($to, $hdrs, $body);
// Send our email, according to the address in $to, the email
// headers in $hdrs, and the message body in $body.

Ghét người Lào

Việt Nam với Lào luôn là anh em, tình sâu hơn nước Hồng Hà, Cửu Long. Thế nhưng mới đây anh May, một doanh nhân Lào, sang Việt Nam mấy hôm về kể lại:

“Người Việt rất ghét Lào. Cái gì xấu nhất họ cũng gán cho Lào. Thứ thuốc lá rẻ tiền, hôi rình họ gọi là thuốc Lào. Bị ngứa ở chỗ kín họ gọi là hắc Lào. Đi ngang qua trường học, thấy thông báo đề: Cấm học sinh đi dép Lào đến trường.

Hôm vừa rồi tôi ngồi chơi ở ghế đá trong công viên, lát sau có một người đàn ông đến ngồi cạnh, co cả hai chân lên ghế. Một lát, chịu không nổi mùi thối bốc lên từ chân ông ta, tôi bỏ đi chỗ khác. Vừa đi được chục bước thì thấy người đàn ông kia nhảy cẫng lên la lối: Tiên sư thằng Lào lấy dép của bố mày nhớ! Bố mày mà biết mày là thằng Lào, bố mày đập vỡ mõm mày ra!”