Sunday, December 8, 2013

Exit polls and fallacy of mutiplicity of India media.

Today, the 8th of dec'2013 marks a historic day for urban middle class in India, particularly in Delhi where Aam Admi Party (AAP), a party born out of popular imagination for a political class free of corruption and performance put up a stellar show by winning 28 of the 70 assembly seats though falling short of the majority mark of 32. How far can the AAP can build upon this mandate and convert this into long term substance is yet to be seen, as every young urban voter (and non-voter) looks upon AAP to bring a change to the Indian political class of highhanded and blatantly corrupt office bearers. 

This day is also significant to highlight the utter discontent people have against the Congress party across the nation. The results spell that out in no unclear terms where, from being a party in power for the last 15 years in Delhi to being reduced to just a meager 8 seats and to having its worst ever performance in Rajasthan. Also it signifies a bleak future for the prince in waiting of Congress at least for the near term.

The other aspect these results highlight is the explosion of media houses in the country, each conducting its own exit polls and each claiming to be an expert at predicting future ala an Oracle. The variations in these predictions are wider than the content of statements made by our very own Piggy Singh. For example one of the predictions predicted 6 seats for AAP at one end and 28 at the other and yet each channel today claims to be spot on with their exit polls notwithstanding the mathematical impossibility of the same (unless some math-equivalent of Heisenberg's uncertainty principle is at play). Each time these channels escape with either utterly asinine claims and shameless lies. Here I plan to give each on you a sense of the non-sense rolled out by the multitude of Indian media house by comparing their various exit polls predication and the reality of the results.

The exit-polls data is as shown on the various news channels and their websites on 4th of December and the actual results as shown on the Election commission website on 8th Dec'2013.


Fallacy of exit-polls and reality


 Clearly no one came any close to "Spot-onNess" as each one of them have been ranting the whole day.

Monday, September 23, 2013

Drupal: Getting started for programmers.

Well if you are a programmer and understand how software works and know how to quickly code up HTML/CSS/JS/PHP and you are thinking to move to Drupal, then mate you are where I was a week back.

There are tons of tutorials on the web from very basic to advanced, but its too much to go through and completely unorganized. Here I will give you links (mostly video) to understand important parts of drupal as quickly as possible and just get started with making our own website with the looks and features you want.

Some Important parts of Drupal.

What is Drupal?





Views : http://www.mustardseedmedia.com/podcast/episode9  
 https://learndrupal.stanford.edu/video/drupal-6-views-introduction





How to customize a Website's look and feel :







By now you know basics, I suggest you should now get started to do some theming. If you need to dig dipper and need advanced tutorials:



Best of luck.





And hence it rains .!!!!

It rains once again, splashing waters, dim and blue, creating a miniature waterfall across the stairs. Few umbrellas, white and blue, wading through ... the world has come to a torpid pace unsettled but a sudden rain ..some rupture, some imprecate, as i look through, pressed against a tainted glass ..world was never so beautiful as I muse ...

Alas!! as I look over my shoulder, eyes glued to the iridescent flats, minds shackled in worry, souls oblivious to the beauty one must behold ..confined in seedy space which they rather refer to as cubicles, a mathematical term if you will, imprisoned in some vicious cycle, I wonder, set out to achieve the unachievable, sits the perpetual fools ..

The heavenly pours shattering again the indignant walls, squeaking  to wake the "Awake", imploring them to heed, hard and heavy it falls, but the deaf are adamant to what they think a pious goal, glued to the futile cause, blinded by the illusion, unable to descry the beauty the world holds .. 
A few enlightened ones get up and walk up to the glass, peek a sight or two, revel in the majesty for nigh seconds and then are back to the unending cause..,
the waterfall has gained ...the rain, now, dancing with the wind, nature unfolding to its full glory to the cheering of the sane !!!!!

Thank you!

When the gruesome day at work refuses to wane 
When the clouds are dark but still it never rains 
When the muscles cramp and the mind is drained  
It is then that the soothing voice of that friend 
makes yet another cruel day worth the pain. 

It is that voice on the phone, 
the silly jokes and the stupid yawn,
the office gossip and the manager bashing,
the wild trips to the mountain tops,
the dances and the romances, 
and all the other crap that never sucks,
makes the overpriced postpaid plan worth the bucks

The endless crushes and the aerobics guy,
the constant proposals from some desperate souls,
and the adamant grandpa on a marriage mission,
to the cuteness of your friend's roommate 
the meaningless discussions which go on pretty late,

Times change and changes the location,
people change and changes the relation,
sometimes it is  wonderful day,
sometimes it is a mornful day
and at others life is in a million shades of gray
But you my friend is the one who is always there,
to support, to care, to advice and to bring a smile wide with joy.

I thank you for being there when I needed you the most
thank you for doing all you have for me
in this labyrinth thank you for keeping me sane 
It is you that  makes yet another cruel day worth the pain. 
   

Why the hope still lingers on ????

I met an angel years ago,
twinkling eyes and smile so fresh,
chirpy and always so fun,
I could look at her face for ages at a go

She felt like the love of my life,
the relief from the sorrows and the pain,
she was like the sunlit dawn after
years of dusk smeared in the sinister rain,

We went places together,
had a lot of fun, explored the city
which now felt like a heaven,
Days flew in wait for her,
Nights vanished in the dreams of her.

We looked the best together,
as if made just for each other,
we loved the similar things,
as if destined to remain such forever

Happy was I, in the thoughts of her,
Ecstatic was I, in the company of her,
Life was fun, and nothing bothered,
With her around , nothing else mattered.

And then came the dreadful day,
when she from me, drifted away,
Shocked was I , unable to comprehend,
Scared was I, the pain never so severe.

The world came crashing down,
I knew nothing, what else to do,
I felt nothing, who else to go,
Shattered was I, didn't know what to do.

I could do anything to get her back,
if one tells me what shall that be,
She says you are the best and deserve much better,
if only I could ask, if I am the best why settle for any lesser,
She says time will heal every wound,
if only I could tell her how this feels.

I don't meet her anymore,
we don't talk much now,
people tell me to just move on,
She is not the one meant to be,
it seems she is long gone,
Why then the hope still lingers on ????

Thursday, September 12, 2013

Quick start with AWS: Create a new instance, install LAMP and Drupal.

Step-by-step guide to getting started with a new AWS (Amazon web services) account and hosting a Drupal powered website.

Estimated time to complete 40 minutes. For more info or help on any of the sub-steps, please do a quick Google search.


1. Create a new AWS account.
2. Launch a new instance :
 > make sure the volume, i.e the disk is of type ebs, increase the size if  you want.
 > use a AMI, i.e the OS from the list.
 > Generate a key value pair. Download the .pem file.
 > In the security group enable TCP port 80 (for HTTP) and 22 for SSH.

3. Generate an elastic IP
4. Associate the IP with the generated instance.
5. Create a monitoring alarm for the instance for high CPU.

6. Copy the .pem in some secure location.

7. Set up SSH to the instance, by configuring the ~/.ssh/config file.

Host ANY_NAME_YOU_WANT_TO_CALL_THE_INSTANCE.
HostName: ec2-xxxxxxx.compute-1.amazonaws.com
User: ec2-user
IdentityFile "~/.ssh/ec2.pem"

>chmod 700 ~/.ssh/config
>ssh Hostname <--- as="" config="" file.="" in="" p="" ssh="" the="" used="">

// Set up all utilities: Fedora


sudo yum -y update
sudo yum -y install httpd mysql mysql-server php php-cli php-gd php-intl php-mbstring php-mysql php-pdo php-pear php-xml php-xmlrpc 

// Check apache version for apache1

httpd -v

// for apache2
apache2 -v

// check php version 

echo '' | php


Make sure services automatically start on a reboot:
sudo chkconfig httpd on
sudo chkconfig mysqld on
sudo service httpd start
sudo service mysqld start 
 
Edit your httpd.conf:
sudo cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.old
sudo vi /etc/httpd/conf/httpd.conf
 
find and under that change AllowOverride None to AllowOverride All
Press Ctrl + C and type :wq to save and quit.
Restart apache for changes to take effect:
sudo service httpd restart 


Set your mysql root password
sudo mysqladmin -u root password 'change-password' 
 
Mysql security:
sudo mysql -u root -p
mysql> DROP DATABASE test; 
mysql> DELETE FROM mysql.user WHERE user = ''; 
mysql> FLUSH PRIVILEGES; 
 
Create the database that drupal will use:
mysql> CREATE DATABASE drupal;
 
Press Ctrl + C to exit mysql.
Now your server is ready for drupal. I'm going to use drush to install:
pear is a php tool which allows reuse of php code and patches etc.
drush is a tool used to manage all of drupal.
sudo pear upgrade
sudo pear channel-discover pear.drush.org
sudo pear install drush/drush 
 
Next use drush to download the latest drupal version and then move it to the web root directory (Make sure to substitute the the name of the latest distribution for "drupal-7.x")
cd /var/www/html/
sudo drush dl
sudo mv drupal-7.x/* ./
sudo mv drupal-7.x/.htaccess ./
sudo rm -r drupal-7.
 
Create the files directory and the settings.php file
sudo mkdir sites/default/files
sudo chmod 777 sites/default/files/
sudo cp sites/default/default.settings.php sites/default/settings.php
sudo chmod 777 sites/default/settings.php 

Open your site in a browser and complete drupal install process, your site can be reached at the public DNS listed in your AWS console when you select an instance and should look something like ec2-00-00-000-00.compute-1.amazonaws.com.

After that go back to your terminal and set the permissions on the settings.php file.
sudo chmod 644 sites/default/settings.php 
That's it, you should now have the latest version of drupal up and running on your ec2 instance.


Running Appache as a different user:

If php needs to create log files while running under appache, apache should be run under a proper user:

Depending on your OS, this might be 'www-data', 'nobody', 'http', or any variation. If your website is the only website running, this is easy to change by changing the user Apache runs under. If you have Debian, like I tend to, you can edit the file /etc/apache2/envvars (as root), and change the value for APACHE_RUN_USER. Depending on your OS, this variable might be set in a different configuration file, so if you can't find it in /etc/apache2/envvars, try to search for the variable declaration by using:

More info: 
http://stackoverflow.com/questions/5165183/apache-permissions-php-file-create-mkdir-fail

This might cause PHP to loose access to session variables:


open(/var/lib/php/session/sess_isu2r2bqudeosqvpoo8a67oj02, O_RDWR) failed: Permission denied (13) in Unknown on line 0
you have to check file permission change mode this /var/lib/php/session/

Giving permissions to file so that apache works (apache runs as www-data)

Keep the owner as yourself for the folder:
chown -R eve contoso.com
Make group as the apache group. 
 chgrp -R www-data contoso.com
Change permission for the folder.
 chmod -R 750 contoso.com
 Make the folder permissions sticky, such that new files created insider the folder also has the same permissions.
 chmod g+s contoso.com ; needs to be run as sudo, 'g' is for group, 's' is for sticky
Make a apache writeble folder.
chmod g+w uploads

SetUp Mysql User:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
 GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';  (*.* == db.table)

FLUSH PRIVILEGES;


Install AWS SDK for PHP:

Via Composer:
   > In the project file create a file named: composer.json and add the aws dependency as:
    {
       "require": {
          "aws/aws-sdk-php": "2.*"
       }
   }

> Install composer and move it to make it a utility.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
Now Install the dependencies via composer by running the below in the project root directory:
composer install
More info: https://getcomposer.org/doc/00-intro.md
This will create a folder 'vendor' with all the libraries, use composer autoloader to load all libs.
require '/path/to/sdk/vendor/autoload.php';
include the AWS namespaces by
use Aws\someserices\xyz

AWS setting up credentials profile:

 Use a cred file in the home dir to store access keys:
            http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html#credential-profiles

 AWS email service:

Sending emails via SES:
     Creating a email client:
                   http://docs.aws.amazon.com/aws-sdk-php/guide/latest/service-ses.html
   
      Things that can be included in an email via sendEmail() function:

           http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Ses.SesClient.html#_sendEmail