Tuesday, February 9, 2016

How to install the Perl module Data::Dumper on Linux - RHEL, CentOS or Amazon AMI?

Below is an error message that could get thrown while installing any Bitnami package (say Bitnami Mediawiki package) on a Linux

Error: Error running /opt/app_name/mysql/scripts/myscript.sh 
/opt/app_name/mysql ****: FATAL ERROR: please install the following 
Perl modules before executing scripts/mysql_install_db:

Data::Dumper

The error states that you have install the Perl Module Data::Dumper. Run the below command :
yum install "perl(Data::Dumper)"

Follow through the rest of the instructions on the command line to complete the installation. 

Sunday, February 7, 2016

How to hide or remove the View History tab on Mediawiki

Below are the steps to remove/disable/hide the View History tab on Mediawiki. This works as of early 2016 on Mediawiki 1.26x. Hope it helps!
  1. Login to your apps/mediawiki/htdocs directory. This is the directory which contains the LocalSettings.php file.
  2. Edit the LocalSettings.php file (open in text editor).  Add (append) the following lines
#====Begin : code to hide/remove View Source tab from Mediawiki====
function efAddSkinStyles(OutputPage &$out, Skin &$skin) {
    if(!$skin->getUser()->isLoggedIn()) {
        if ($skin->getSkinName() == 'vector') {
            $out->addInlineStyle('#ca-history { display:none; }');
        }
    } else {
        if ($skin->getSkinName() == 'vector') {
            $out->addInlineStyle('#ca-view { display:none; }');
        }
    }

    return true;
}


$wgHooks['BeforePageDisplay'][] = 'efAddSkinStyles'; 
#====End of code====

Wednesday, May 27, 2015

Setup WordPress On Amazon EC2 : Installation steps with Linux commands cheat sheet


This is a real quick guide to setup WordPress On Amazon EC2. It is a direct result of following a Youtube tutorial on the same subject by a guy named Avishai Sam Bitton, who is the Marketing Director at Imonomy & Founder of Go Social.

The Youtube tutorial by itself was great. In 10 minutes, Avishai shows you how to go from creating a Linux instance to the WordPress admin page. It is done on the Amazon Linux AMI (not Ubuntu or RHEL). The only missing thing is the Linux commands cheat sheet (copy-paste-able) which I will cover in the following paragraphs. I will try to provide maximum information in minimal words.

Here is the actual video and what follows is my notes on the same :

To setup a WordPress blog on the Amazon EC2 infrastructure, you need to know and do the following as a prerequisite:
  • Have Putty and PuttyGen installed (or ready for use)
  • Have basic understanding of Linux concepts and commands. Know how to use putty, and optionally understand security concepts.
  • You should have created an Amazon AWS account. A credit card signup is required even though the basic Linux instance (micro instance) is free for 12-months.
Once you're ok with the above, follow these steps.

Part A

  1. Login to the Amazon AWS console.
  2. Select :  EC2  - Virtual servers in the cloud.
  3. Under Create Instance, click on Launch Instance.
  4. Select Amazon AMI Linux - 64 bit
  5. Check settings. Maintain defaults. Keep clicking next - until you reach the Configure Security Group section.
  6. Click Add Rule twice : 
    • One for the HTTP (port 80) 
    • another for the HTTPS (port 443). 
    • Also add a third one and select Custom TCP port. Enter port 8080 (if your apache or nginx server runs on this port)
    • The SSH rule is already added with port 22.
  7. Click Review and Launch. Click Launch. This opens a dialog to create a new key pair. 
  8. Create a new key pair. Download the pem file to your local folder.
  9. Now click Launch Instance (wait for 5 mins for startup)
  10. In the meantime, convert the pem file to ppk file
    • Windows :  PuttyGen tool, go to Menu->Convert->Import->Save file with ppk extension to your local drive.
    • If you are on Mac, no need to convert. You can use the pem file to login directly using the generated Elastic IP address (steps given below).

Part B

  1. The instance which you launched couple of steps back should now be running(green tick mark)
  2. On the Left pane -> click Elastic IPs -> Allocate New Address -> Yes,Allocate
  3. Right click on the allocated Elastic IP -> Associate Address -> running instance (some 10-character code). Click Associate.
  4. Go to EC2 Dashboard -> Running Instances. Check the Public IP and Elastic IP (both should be same).
  5. Copy the IP address. Open Putty and copy the IP address (say 11.22.33.44) into putty's Host.
  6. Go to SSH->Auth, browse open the converted ppk file. Go back to Session and click Open. Putty's black screen should open up.
    • Windows  : Login as : ec2-user
    • Mac : 
      ssh -i keyfile.pem ec2-user@11.22.33.44

Part C - The Linux Commands (aka Cheat Sheet)

Once you've logged in as the ec2-user, type in the below commands one after another.
Note: In all the "install" commands, press "y" if the shell asks for install confirmation.
CommandsNotes
sudo yum updateUpdates all software patches on the instance.
sudo suSwitching to root user
yum install httpdInstalls Apache server
service httpd startStarts Apache server
yum install php php-mysqlInstalls PHP
yum install mysql-serverInstalls MySQL
service mysqld startStarts MySQL server
mysqladmin -uroot create myblogmyblog will the name of the database in this example)
mysql_secure_installationFollow these steps:
* Enter current password for root: just press enter key
* Set root password? : Y (enter password twice)
* Remove Anonymous Users? : Y
* Disallow root login remotely: Y
* Remove test database and access to it? : Y
* Reload privileges table now? : Y
cd /var/www/htmlGo to this directory
wget http://wordpress.org/latest.tar.gzDownload the latest version of Wordpress
tar -xzvf latest.tar.gzExtract Wordpress
mv wordpress myblogRename the the blog to myblog
cd myblogGo to the myblog directory
mv wp-config-sample.php wp-config.phpRename the php config file.
vi wp-config.phpEdit the wp-config.php file with the given information :
* define('DB_NAME', 'myblog')
* define('DB_USER', 'root')
* define('DB_PASSWORD', 'yourpassword')
* press escape key
* :wq! (to save and exit)
service httpd restartRestarts Apache server


Now, open your browser, and enter : http://IPAddress/myblog  (in our case, http://11.22.33.44/myblog).
Your Wordpress blog's Admin installation page should be ready for configuration.
If your web server is running on port 8080, then use the url : http://11.22.33.44:8080/myblog.

Saturday, May 23, 2015

How to find lines not containing (matching) a string in Notepad++

 In Notepad++, you might have a requirement to find or replace lines which do NOT match a particular string.
Lets say you have the following lines in your text file - and you would like to the find lines NOT containing the string "USA"

Apple - USA
Airbus - France
Google -USA
IBM - USA
SAP - Germany
TESCO - UK


For this, you will have to use the Notepad++ Regex find option

Here's how:
  • Press Ctrl + F to pop open the Find dialog box
  • Select the Regular Expression radio button
  • Type in the find box : ^(?!.*USA).*$ 
  • Now find or replace.
Here are couple of awesome books to understand more about Regular expressions :

Here's a screenshot of my notepad++ screen.

 

Friday, July 5, 2013

How to install Beautiful Soup or BS4 on Windows?

BeautifulSoup is a Python module which is meant for web scraping. That is, using Python, you can fetch an html webpage (using a module such as urllib2), and then obtain meaningful information out of the html file (using the BeautifulSoup module).

Here are the steps to download and install BeautifulSoup on Windows. It assumes you have already installed python and you know how to use an archiving tool such as 7-zip.

1) Download the BeautifulSoup compressed file from the below link:
http://www.crummy.com/software/BeautifulSoup/bs4/download/

In my setup, I have downloaded a file named beautifulsoup4-4.2.1.tar.gz.

2) Extract the archive using a tool such as 7-zip. Once you have extracted the files, open cmd prompt, and go to directory named beautifulsoup4-4.2.1

3) Run the following command to install BeautifulSoup
C:\>python setup.py install

4) Test the installation with this command :
>>>from bs4 import BeautifulSoup

If you see the python prompt (>>>) in the next line without any errors, then it means BS4 is successfully installed.

For detailed coverage, check out this book : Getting Started with Beautiful Soup

Thursday, June 21, 2012

Oracle SQL Query to print Unix Timestamp

The actual query is available in http://jehiah.cz/a/oracle-date-to-unix-timestamp , but here is a slightly modified version which strips the decimal points and prints only the elapsed seconds.
---
SELECT abs(to_number(((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400)))) as dt FROM dual;
---

Tuesday, May 15, 2012

Ubuntu Linux - Change from GUI mode to Command line / Text mode

Simple stuff - just documenting my learnings

So here's how we change Ubuntu from its usual GUI mode to the Command line mode (black screen / text mode)

Note : If"sudo" is used before a command, then you will have to enter root password.


  • Open the Terminal, and cd /etc/default
  • Open the "grub" file in vi editor as root : sudo vi grub
  • Change the property GRUB_CMDLINE_LINUX_DEFAULT from "quiet splash" to "text". See below
    • ========
    • #GRUB_CMDLINE_LINUX_DEFAULT = "quiet splash"
    • GRUB_CMDLINE_LINUX_DEFAULT = "text"
    • ========
  • Run this command to update grub : sudo update-grub
  • Reboot Ubuntu : sudo /sbin/reboot
On reboot, you should be able to see the command-line screen instead of GUI.

Saturday, May 12, 2012

Automate Sphinx - Create rst files automatically from a list of topics

You have lots of topics to document using Sphinx, but bored of creating each .rst file manually? Not to worry at all. Here is a script that will just automate the file-creation task for you. Here we go:

First, download the zip or gz package from https://github.com/thyag/SphinxAutomation/downloads


And read the below to get your stuff donne : 

Friday, May 11, 2012

Create a PDF document from your Sphinx Documentation using rst2pdf

Pre-requisites & Assumptions

  • You have installed Python.
  • You have installed and used Sphinx documentation generator.
  • You have created an HTML documentation using Sphinx

Friday, May 4, 2012

Buying books online - some how tos, tips and thoughts


  • Ask in quora.com for the best books in your topic of interest
  • Read the reviews about those books in amazon.com. Make sure that the rating is good, if not great. Beware of those reviews which are done by the author's buddies. Check the date of publication and the date of review to get some idea ( usually fake reviews are added immediately after publication date, and they are added in the same week or month)
  • Even if a book's rating is good, read the contents and the first chapter on amazon. Make sure it captivates you. The best book still may not work for you, so watchout.
  • Search for the price of the book in atleast 4 e-commerce sites. In India, I search at flipkart.com, indiaplaza.com, homeshop18.com, bookadda.com, and sapnaonline.com. Don't buy immediately. Impuse is maya. Just put the book on wishlist. Give atleast 1 week, sleep over the book, and decide if you really need the book. There are also sites like mysmartprice.com and junglee.com which do price comparisons. 
  • If you really need the book, order the book based on what is priority for you - cost, delivery time,quality of service, etc.

Tuesday, April 24, 2012

Share your local folder over HTTP - The easist way

Here is a one liner to share your local folder in a LAN environment :
  • Install Python
  • Open cmd prompt or terminal, and navigate to your desired directory. Type the command :
  • python -m SimpleHTTPServer
  • Open http://localhost:8000 on your browser.
To use a different port number (say 17740) :
  • python -m SimpleHTTPServer 17740

Friday, April 20, 2012

The Read More link option in Blogger / Blogspot post

This is a minimal tutorial to add a "Read More" link in your Blogger  / Blogspot post
  • Login to your Blogger account. Click on Compose and start typing your post. Or Click Edit if it is an existing post.
  • Place the cursor on the text section where you want to add the Read More link (usually after the 3-4 lines of the first paragraph)
  • Click on the "Insert Jump Break" button (on the toolbar above).
  • Publish or Update your post.

Thursday, April 19, 2012

Pune to Shirdi and Shani Shinganapur - Our one day trip


Sunday, 08 April 2012
People : Abinash, Sachin, Kushal, and Me
We started the trip from Magarpatta city, Pune at 5.15 am. We were late by about 30 mins, but wasn't much of a problem.

We took the Pune-Nasik route and the road was bad. (The best route is to take the Ahmadnagar road). At 7.30 am, we had breakfast at a place called Kamat's. There was car parking, toilet facilities, and decent+expensive food.

We reached Shirdi at 11 am. We left our slippers, mobile and other belongings at the car. Later we realized that leaving the slippers in the car was a big mistake because walking barefoot literally burned our foot.
Lesson : if you are visiting a hot place, always wear (inexpensive) slippers and leave them at the temple entrance.

When we entered the temple premises, a couple of shopkeepers misguided us and made us buy a lot of prasad and pooja items. That was mistake number 2. Don't be fooled by some strangers who are accosting you. Take your time, analyze the place and then buy only when necessary.
On reaching the temple's main gate, we came to know that the Darshan is closed from 11 to 1 pm. So we spent some time within the temple premises visiting the other smaller shrines.
We visited the dargah where Shirdi baba spent his childhood days. We also visited the museum which has the photos and items that belonged to Shirdi baba.

At 1 pm, we started lining up for the darshan at Gate 1. As it was Sunday, there was a lot of rush. We stood in a kind of managed queue  system where within the railings there were benches to sit (which was useful). The queue passed through 3 huge halls. And finally we hit the main hall which houses the statue of Shirdi baba. We gave the pooja items and the prasad to the priest sitting infront of the statue. We did our darshan for about 30 seconds and the service folks quickly escorted us out. It was 2.30 pm by then. We came out of the temple and jumped into the car.
Our next desitnation was Shani Shinganapur - the town without doors or locks. It was an 80 km drive from Shirdi.

Legend has it that Shani bhagwan descended into this village in the form of a 5 foot stone one fine day. The villagers, after seeing the stone, were naturally curious and started piercing the stone with a sharp tool. To their surprise, they saw blood oozing out of the stone.  Yes, blood.

Following the blood oozing incident, during the next few days, the villagers started reporting that they were getting dreams where Shani bagwan spoke to them - asking them to erect him (the stone) on a platform without any roofing. Its like, the stone should be erected on an open space. The whole idea is about openness. This explains why all the houses and shops in the Shinganapur town do not have doors or locks. People don't really bother about their belongings as they believe that Shani bhagwan will bring it back. They also believe that Shani would punish the wrong-doers, which is the reason why the locals are scared about stealing.

So yeah, we reached Shani real quick. The darshan was straightforward. Just park the car, enter the temple, pray, and exit. Its not as time-consuming or as procedural as Shirdi.

We also took some sesame oil and poured it at a particular spot near Shani's shrine. According to legend, Shani was once injured by Hanuman. They say one must pour oil on Shani to alleviate his pains. To understand more, you might want to check Dr Robert Svoboda's beautiful book : The Greatness of Saturn
That was it. We took the Pune-Ahmadnagar highway in the evening, and reached our place at night. Overall, it was a nice day out (one day is more than enough). It is better to go on a Saturday (because of Shani).

Where is the Dunkirk Lines Post Office in Pune?

Update: This article was relevant back in 2012-13. Please validate before any action as I have left Pune many years ago.
The Dunkirk lines post office is named " DUKIRKLINE" in the Indiapost tracking website : http://www.indiapost.gov.in/tracking.aspx

I was struggling to find the location of this post office and found it somehow after 2 days. To start with, you will have first check this wikimapia link to get the approxmate location of the post office:
This is how you reach this place : 
  1. If you are in Kharadi,

GIT Commands - My notes from Michael Hartl's Rails Tutorial

# initial one-time setup
git config --global <options> 

#Necessary each time you create a new repository.
#Commands need to be executed from the the project directory. Eg : C:/rails_tutorial/first_app

# To initialize a new repository
git init


A Compilation of Ayurveda websites, blogs, articles,etc

Good Books on Ayurveda:

  • Ayurveda and Panchakarma: The Science of Healing and Rejuvenation  - Dr. Sunhil, M.D. Joshi
  • Ayurveda: The Science of Self Healing - A Practical Guide - Dr, Vasant Lad
  • Ayurveda: Life, Health, and Longevity - Robert Svoboda
  • Prakriti: Your Ayurvedic Constitution by Robert Svoboda (Jun 1, 1998)


Some links on Ayurveda
http://www.ayurvedicdietsolutions.com/incompatible-foods.php