Sunday, December 4, 2016

Time POY

Time Magazine will be announcing their annual Person of the Year on Wednesday, December 7th. In the past, I have been acknowledging and showcasing this choice by tweeting about it and / or featuring them on my Facebook page.

This year, the popular choice (with 18% of the votes) for Person of the Year (from among the various candidates with Person of the Year moments) is the Indian Prime Minister, Narendra Modi. However, if history is any indication, I am sure that Time will name Donald Trump as their POY.

I am sorry, I cannot bring myself to "celebrate" the announcement of Donald Trump as POY. As a result, I will (in all likelihood) not be featuring Time's choice with a tweet.

I hope (against hope) that Time proves me wrong and elects any other worthy candidate.

Wednesday, October 19, 2016

Debate winner - how to scientifically determine the outcome

Tonight, we will have the third (and final) debate between Hillary Clinton and Donald Trump. The inevitable question after each debate is, "Who won the debate?". Around 15 minutes after the conclusion of the debate, CNN will have a reporter present the "results" with words along the lines of, "This is an unscientific poll. We asked 15 undecided voters on their opinion. They are, however, leaning Democrats. So, you should not give too much credence to these results." Why bother providing us the results of the poll, in that case!

On the days following the debate, each candidate addresses rallies claiming that they "won by a landslide".

So, I decided to explore definitive ways to answer this question and determine the winner by applying scientific methodologies. This way we would not need to "speculate" or take a random person's opinion to determine the outcome.

I came across an example from Indian history of a debate between two famous philosophers, Adi Shankara and Mandan Mishra. They had opposing points of view with Shankara believing in the Advaita philosophy while Mishra was a proponent of the Mimamsa philosophy. In order to determine who won the debate, they both wore flower garlands on their bare chests. The person whose garland withers first is the loser.

While the external appearance can be "coached" and "controlled", it is not possible to control the human body's reaction to lies being told or anger or perspiration or genuine response to, "I am stumped". That is why the loser's garland withers first.

We heard the pundits refer to the number of times Donald Trump "twitched" or drank from his glass of water as an indication of his "unpreparedness" or inability to cope with the situation. While I shudder to imagine a bare chested Donald Trump, it is possible to use modern day technology to get the equivalent of a "withered garland". This way, we can have the debate moderator announce at the end of the debate, "Ladies and Gentlemen. I thank you for attending this evening's debate. Our scientific methodology indicates that the clear winner of the debate is ".

Sunday, October 9, 2016

Enough, already

There is a story about a boy who had difficulty in controlling his temper. His father asked him to hammer a nail into a fence each time he got angry. Over time, the number of nails he drove into the fence on a given day declined until he reached a day when he had not hit a single nail onto the fence. Now, his father asked him to remove a nail each day he was anger free. In a few weeks, all the nails were removed from the fence. The boy proudly showed the nail-free fence to his father. The father said, "Do you see the holes in the fence? It is scarred. When you say things in anger, they leave a scar just like these. No amount of apologies will restore the fence."

Donald Trump's apologies for his reprehensible comments are similar. If his (insignificant) position 11 years ago made him think he had the power that he refers to, imagine the power he would have as commander-in-chief. As Lord John Acton said, "Power tends to corrupt, and absolute power corrupts absolutely." The very thought of absolute power to Donald Trump sends a shiver down my spine.

I want to take cue from the fictional character, Howard Beale, (played by the oscar winning Peter Finch) and say, "I'm as mad as hell, and I am not going to take this any more." I certainly am mad as hell with Donald Trump. I am collectively asking the nation to not take this any more. Earlier, I had requested a favor to not nominate Donald Trump. Now, I am requesting the Commission on Presidential Debates to stop the farce on the debates. I cannot stand to hear more lies and false accusations from this disgrace that is the Republican nominee. I find Mike Pence to be a worthy Presidential candidate. He would still lose to Hillary, but a better candidate, nevertheless.

I have often heard people refer to Hillary Clinton as the "lesser of the two evils". I am with the Corpus Christi Caller Times editors in their endorsement of Hillary Clinton while debunking this myth.

Not everyone is perfect. Even Abraham Lincoln, considered by historians as the greatest US President ever, made several egregious errors. John F Kennedy had his transgressions. Hillary Clinton has her share. Her lifelong public service, her leadership, her ability to listen to people and the respect that she has from world leaders make her the only choice in the elections this November.

Sunday, July 17, 2016

Do us a favor, GOP - do not nominate Mr. Trump

This is a cry in anguish.

As a nation, we are about to commit a travesty and nominate a racist, egomaniac, misogynist and generally unfit for office, candidate for President. To show that these are not merely "labels", allow me to provide instances that illustrate these traits in Donald Trump. In fact, there are so many outrages that is hard to keep track of all of them, put them in context and list them here.

When Indiana-born U.S. District Judge Gonzalo Curiel was hearing a suit against Trump University, Donald Trump went on a tirade against the respected, federal judge "because he is a Mexican". His bigotry does not stop there. When he saw an African American in one of his rallies, he remarked, "Look at my African-American over here".

Aside from Trump's public, sexist behavior (at the Republican debate) against Fox's Megyn Kelly, he has consistently insulted, stereotyped and belittled women. He has taken the time to insult notable women like Sarah Jessica Parker, Bette Middler, Rosie O'Donnell and Cher. In fact, the Telegraph maintains a site that keeps track of all his offensive remarks!

His shocking ignorance of government policy is even more appalling. I think Cheryl Cook-Kallio's We The People students at Irvington High School know more about Government than Donald Trump. He appears to know next to nothing about the issues that would confront him in the job. If you like chilling horror stories, read the transcript of his meeting with the Editorial Board of the Washington Post. It is not as if the editors were trying to play "gotcha" or "trap" him. In response to straightforward questions, Trump's responses are vacuous. On topics ranging from racial disparity to foreign affairs his responses are vague. As Eugene Robinson aptly opined, "How is it conceivable to put a man who knows so little in charge of so much?"

The likes of George Bush (father and son, the 41st and 43rd presidents) and Mitt Romney have shown statesman-like courage and refused to show their support to Trump. In fact, the only living republican president or presidential candidate who will be at the Republican Convention is 92-year old Bob Dole. Even the most ultra conservative republican journalist, George F. Will has written an eloquent, scathing attack on Donald Trump.

I think President Obama summed it best when he said, in six short sentences, everything that is wrong about Donald Trump. This is not party politics playing out. Just a concerned citizen expressing his opinions.

Despite all of this, there are some polls that show Trump ahead of Clinton in the race to the White House. It is too late in the process to find another candidate to represent the Republican Party. So, this is a request to the GOP to sit this one out. Do not endorse Donald Trump. He has indicated that he will run as an independent. That is better than sullying the party of Abraham Lincoln (1861), Theodore Roosevelt (1901), Dwight Eisenhower (1953) and Ronald Reagan(1981). You can have your convention and groom candidates for the 2020 elections. Have the dignity and courage to say that there will not be a representative of the Republican Party in the 2016 elections.

After I published this blog, I came across a video (embedded in the following NY Times article) where David McCollough expresses a similar opinion more eloquently.

Sunday, December 27, 2015

The Martian

Being a Silicon Valley Engineer, one's interest is piqued when reading about Andy Weir's story about how he self-published his book - because no publisher wanted to touch it. After it became popular on Kindle, Crown Publishing finally published the book - that Joe Morgenstern (of Wall Street Journal) said was the best pure science fiction novel in years.

When the book is made into a movie directed by Ridley Scott, it became a "must see".

The movie certainly did not belie expectations. The thesis of the movie is how astronaut Mark Watney (played by Matt Damon) is presumed dead after a fierce storm and gets left behind on Mars. Watney survives the storm and must draw upon all his ingenuity, training, science, engineering, wit and spirit to subsist to find a way to signal to the command center in Earth that he is alive. You love the way Watney uses-science-to-solve-problems. Even the non-science folks in the audience will find themselves applauding and egging him on to succeed. Sometimes he is foiled by Nature and sometimes his is foiled by error. He never gives up even when all hope seems to have faded.

The most appealing facet of the movie to me was the fact that it had no gun-toting, evil-minded villain. There is a sense of humanity and instinct of survival built into every frame. You find yourself rooting for Matt Damon not for some contrived reason (of getting back home to his anxious, forlorn wife or children), but because you want his courage, hope and doggedness to succeed.

Inevitably, this movie will be compared to Appolo 13. Twenty years later, I must admit that I watch reruns of the Ron Howard classic. Appolo 13, however, had too many emotional strings and sentimentality. Martian, on the other had, succeeds with wit and humanity. It is incredibly enjoyable and totally worth watching

Friday, December 19, 2014

Freedom (or lack thereof) of Expression

Earlier today, the FBI formally accused North Korea as the perpetrator of the cyberattack that brought Sony Pictures to its knees resulting in their caving into the demands of pulling the movie The Interview from theaters. This work of fiction has a plot where journalists secure an interview with North Korean dictator, Kim Jon-un. They are subsequently instructed by the CIA to assassinate him. For North Koreans, the plot "touched a nerve inside the regime, which takes a dim view of satirical treatment of its leaders and is notoriously paranoid about perceived threats to their safety." There are a couple of facts in this chain of events that baffles me:
  1. A sophisticated cyberattack (arguably the most damaging attack carried out against an enterprise) was carried out in a country where citizens are thought to lack basic internet access
  2. Hollywood executives reportedly screened the ending of The Interview to the state department and got their "official blessing"
This is certainly not the first controversial film to be made by the film industry. Recently, there was an outcry when the screening of Kamal Hassan's Vishwaroopam was banned in Tamil Nadu because it portrayed Muslims in poor light. This ban, however, was executed by the Government - in the pretext of promoting "Cultural Harmony". If anything, President Obama came out saying that Sony made a mistake in pulling the film. I can't think of any other time in history when the studio capitulated to threats.

The Interview was slated to be released on Christmas Day - along with other blockbusters including the final Hobbit film. Despite its decent reviews, it would have been hard to make a huge impact in the BoxOffice. With the pulling of the film, almost every one will want to see it when it is ultimately released.

Friday, November 21, 2014

Starting replication for a very large MySQL database on Amazon EC2

In this post, I will outline steps used to start replication of a very large MySQL database from scratch.

Here is the problem that we faced:
  1. I had set up Master-Slave replication for a MySQL database in the beginning (using the simple steps outlined here)
  2. On both the Master and the Slave server, I had /var/lib/mysql point to an, IOPS optimized, EBS disk
  3. Since this data was very critical, I had set up a cron job to backup the database on the slave server
  4. I was monitoring the Master MySQL server with NewRelic and set up alerts when CPU, Memory or Disk consumption reached certain thresholds
  5. There were three mistakes that I did (for those of you setting this up from scratch):
    • Not setting up NewRelic on the Slave Server
    • Performing the backup on the same EBS disk as the DB partition
    • Not "cleaning up" or archiving older backups
  6. As a result of these mistakes, the Slave EBS disk became full and replication stopped
  7. I was blissfully unaware of this until a few days passed
  8. I cleaned up the Slave EBS disk, but I did not know where or when the replication stopped. So, I could not just resume the replication
At this time, here were the constraints that we were dealing with:
  1. There were already over 10m records in some tables and 60m records in some other tables.
  2. This was a live, production, system - so shutting it down (with a READ LOCK) was not an option
  3. Performing the replication and doing the database back up remained to be critical
  4. This task had to be completed in a few hours - because without it we ran the risk of being exposed
These constraints ruled out:
  1. Following the replication steps in the beginning of this post - since we could not do a READ LOCK
  2. Backing up the Database (on the Master) and restoring on the Slave - this would take too much time
Given these requirements and constraints, all the documented methods for resuming the Master Slave replication were ruled out. Here are steps taken to accomplish this task:

On the Master server:
  1. Edit my.cnf

  2.  server-id=1  
     binlog-format= mixed  
     binlog-do-db={DB to replicate}  

  3. Restart Master MySQL server

  4. In the mysql command line on the Master, run the following commands:

  5.  CREATE USER replicant@{SlaveDBServerIP};  
     GRANT REPLICATION SLAVE ON *.* to 'replicant'@'{SlaveDBServerIP}' IDENTIFIED BY 'r3pl_us3r';  
     GRANT RELOAD ON *.* TO 'replicant'@{SlaveDBServerIP};  
     GRANT SUPER ON *.* TO 'replicant'@{SlaveDBServerIP};  

  6. Take a back up of the database in the Master MySQL  server using:

  7.  mysqldump -u {user} -p{password} --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 -A > dump.sql  

  8. Get the master_log_file and MASTER_LOG_POS from the MySQL dump:

  9.  head dump.sql -n80 | grep "MASTER_LOG_POS"  

  10. On your AWS console, take a Snapshot of the Volume housing your Master MySQL DB:
  11. Now create a Volume using the Snapshot-Id from above in the same AZ as the SlaveDB

  12. Attach this Volume to the SlaveDB instance
On the Slave Server:
  1. Point /var/lib/mysql to the mysql directory in the newly attached volume

  2. Start MySQL and verify that the MasterDB is now available on the slave server. Note that some records (towards the end) may be missing. That is ok. The steps that we will perform below will sync the DBs.

  3. Edit my.cnf

  4.  server-id=101  
     binlog-format = mixed  
     log-bin = /var/lib/mysql/mysql-bin.log  
     relay-log = /var/lib/mysql/mysql-relay-bin  
     log-slave-updates = 1  
     slave-skip-errors = all  
     read-only = 1  
     binlog-do-db={DBs to be replicated}  

  5. Restart the Slave

  6. In the mysql command line, run the following commands

  7.  change master to master_host={IP.Address.Of.Master},  
     STOP SLAVE;  

    The Output will look similar to this:

     Slave_IO_State: Waiting for master to send event  
     Master_Host: master_ip  
     Master_User: rep_user  
     Master_Port: 3306  
     Connect_Retry: 60  

    It may take a while to reach this state - depending on how many records need to be synced