Pages

Friday, 6 October 2017

'Hit Refresh': Key Takeaways from Satya Nadella's latest book

'Hit Refresh: The Quest to Rediscover Microsoft's Soul and Imagine a Better Future for Everyone' is Satya Nadella's recent book where he describes his attempts to revive Microsoft and his take on how the recent trends in technology will change the way we lead our lives in the years to come.

The book is divided into nine chapters with a foreword by Bill Gates where he writes briefly about working with Nadella and how the digital transformation the world is undergoing with the rise of AI and other computing trends will make the world a better place for everyone.

Personal Life

The first chapter titled 'From Hyderabad to Redmond' very briefly describes Nadella's childhood and personal story. This book isn't really an autobiography. Rather, it's a collection of his thoughts on leadership and computing. Here, he speaks about his love for cricket, a little about his parents, his school, his colleges and what got him into computer science. 

Being Empathetic

One interesting anecdote he shares was a job interview question at Microsoft where he was asked what he would do if he found a crying baby on the street to which he immediately replied "Call 911." The interviewer puts an arm around him and tells him "You need some empathy young man. If a baby is laying on a street crying, pick up the baby." 'Empathy' turns out to be a recurring theme in the book and is the core of his philosophy.

He takes cues out of his own personal life where as a parent to kids with special needs, he has understood the importance of empathy and why empathy should be at the core of technology and how leaders operate.

The growth mindset

Just before Nadella became CEO, MS apparently was a very different place. There were a lot of teams doing a lot of work but they were all competing in a hostile environment against each other instead of working together. This is where Nadella has been trying to make amends. He takes a lesson out of cricket and says "One brilliant character who does not put the team first can destroy the entire team." 

When Nadella speaks about "Hitting Refresh", he is making a reference to the company's culture.The previous regime under Steve Ballmer was one that payed more importance to hierarchies and competition. And that's what Nadella has been trying to change with what he calls as having a "growth mindset" where he's been trying to get MS to be customer-obsessed, diverse and most importantly unified. 

He gives the example of MS acquiring Minecraft to describe his philosophy where it had been initially been denied under the previous administration but after the head of Xbox persisted and carried out some ground work in the background,it went through under Nadella, and has been one of MS's most successful acquisitions.

The key to the culture change has been individual empowerment where everyone has a voice (like the head of Xbox above) and where action is appreciated over mere words.

Increasing Diversity

He speaks a little about increasing diversity in tech and his own struggles as an immigrant. He had to give up his highly elusive green card earlier on so that he could go back to a H1B which allowed him to bring his spouse into the country.
He describes his efforts towards making MS a more inclusive place and his views on the role and issues concerning women in tech such as unequal pay.

Leadership Lessons
  
"To be a leader in this company, your job is to find the rose petals in a field of shit"
 Nadella's first lesson is to bring clarity among team members that is to develop an understanding between the team members and to define a course of action.

His second lesson for leaders is to keep their team members inspired and to get the energy of the team across the whole company.

His last advice is for leaders to just make thing happen.

On partnering with rivals

Nadella talks about his attempts to get Microsoft to work with rival companies and platforms for mutual profits and how sometimes its important to bury the hatchet for greater good.
For example he talks about MS working with Facebook to get Minecraft working on the Oculus or MS working with Red Hat to get Azure across to Red Hat users. 

He also answers the question "Is it better to get acquired or partner up?" with a counter question "What creates more value for the customer?" and goes on to give the example of MS acquiring LinkedIn.

Computing Trends

The three key technologies he describes in the last few chapters are mixed reality, artificial intelligence and quantum computing. 

He defines his investment strategy across three horizons: growing today's core business, incubating new ideas and investment in long-term breakthroughs.

MS has been trying to experiment with mixed reality with its product HoloLens. He describes his strategy for the product as democratizing access by opening the platform to developers. The tech has been defined as a natural progression from Xbox kinect enabling humans, the environment and objects to give and receive input and output across time and space.

With respect to AI, he defines a layered approach. The first is layer is bespoke, customized wherein a large corporation uses its resources to make an application available to the user. The next layer is democratization wherein every person should be able to access the tools to create their own applications. And the ultimate layer would be the ability for a computer to learn on its own.

And finally he talks about Quantum computing and Microsoft's efforts to make it possible. Interestingly, MS recently even came up with a programming language for the same even though these are still very very early days. (Link)

Role of Ethics

 In the final chapters, Nadella focuses on the difficult questions tech companies face today which is to protect individual privacy while balancing the requirements of law enforcement agencies that may require some of that information to make their case against criminals.

He also talks about having ethical guidelines to regulate how AI will be adopted in the future and how the world could deal with the ramifications of the large scale adoption of AI.

He calls for the tech to not be controlled by a select few living in wealthy and powerful regions and for AI to be controlled to guard against social and cultural biases with also a strong focus on privacy.

Economics and Tech

In the final chapter he makes a case for why technological development is important and how technology can actually create more jobs. He tries to dispel the fears that surround AI and other technological advancements with respect to job losses. 
I really liked his formula for economic growth which he defined as the summation of education and innovation multiplied by the intensity of tech use.  

Interestingly, he tries to make a case for capitalism in this chapter. It's interesting because his own father was a marxist (as described by Nadella himself). Under Nadella, Microsoft has been going all in on open source and a lot of his work and his views on issues seem to portray him as someone who knows how to strike a good balance between corporate goals and social responsibilities: something other tech leaders could seek emulate.

Overall Review

Overall the book is well written. It's a mixture of leadership lessons laced with anecdotes from his personal life and insights into the technologies that will define the future. It also defines his vision for Microsoft and perhaps the people working there would benefit from reading it. On a scale of 1 to 5, I give it a 4.
  

Wednesday, 4 October 2017

How to access and download Coursera materials for free (legally)

Coursera is one of the world's leading platforms for online courses with offerings in nearly every other subject. The best part: Nearly all the material is freely available to audit. You pay only if you want the certificate.

So how do you get all that material? Well...here are the steps:

  • Register on the Coursera website and login. The buttons for the same would be on the upper right corner of the website.

  • Now, move to the page of the desired course. For example I am interested in the course 'A Crash Course in Data Science.' Note that you would have to go the page of the individual course and not the specialization it is a part of.

    From the left corner of the screen, select 'Enroll.' 

  • Look at the very end of this popup. There's the option 'or audit this course.' Hit on 'audit' and baam you now have access to the course materials.



    How to Download the course materials

    You can make use of the following python script: coursera-dl

    Follow the steps in there to set up coursera dl. 

    Open a terminal or command prompt. Navigate to the directory where you want to store the course materials.

    Invoke the script from the terminal with the format: 

    coursera-dl -u <your_user_name> -p <your_password> <name_of_the_course>

    Note that the name_of_the_course parameter is extracted from the url of the course page. For example, the data science course had the url:

    https://www.coursera.org/learn/data-science-course/home/welcome

    The name of the course is from the url: data-science-course BOOM..

    The script does everything for you.

    Have a fun time learning.

Wednesday, 27 September 2017

Java Collections Framework (Part II): Collection Classes and Algorithms

Some important classes:

  1. LinkedList
  2. ArrayList: Implements a dynamic array by extending AbstractList
  3. ArrayDeque: Implements a dynamic double ended queue
  4. HashSet: Extends AbstractSet for use with a hash table
  5. PriorityQueue: Extends AbstractQueue to support a priority based queue
  6. TreeSet: Implements a set stored in a tree
The ArrayList Class 

It's a generic class with the declaration: class ArrayList<E>
It supports dynamic arrays that is the array size grows as per requirement.

Sample program:

import java.util.*;

class ArrayListDEmo
{
  public static void main(String args[])
  {
    //Create an ArrayList
    ArrayList<String> al=new ArrayList<String>();
    System.out.println("Initial size of array list is "+al.size());
    //Add elements to the ArrayList
    al.add("C");
    al.add("A");
    al.add(1,"B");
    System.out.println("Size of al after additions:"+al.size());
    //Display the list
    System.out.println("Contents of al"+al);
    //Remove elements
    al.remove("C");
    System.out.println("Size of al after removal"+al.size());
    System.out.println("Contents of al:"+al);



  }


}

The LinkedList Class 

import java.util.*;

class LinkedListDemo{

  public static void main(String args[])
  {
    LinkedList<String> l1=new LinkedList<String>();
    //Add elements to the linked list
    l1.add("A");
    l1.add("B");
    //Remove elements from the linked list
    l1.remove("A");
    //Remove first and last elements
    l1.removeFirst();
    l1.removeLast();e
    //Get and set a value
    String val=l1.get(2);
    l1.set(2,val+"Changed");
  System.out.println("l1 after change"+l1);
  }
}

The HashSet Class

Creates a collection that uses a hash table for storage. Doesn't guarantee ordering of elements

import java.util.*;

class HashSetDemo
{
  public static void main(String args[])
  {
    HashSet<String> hs=new HashSet<String>();

    hs.add("Beta");
    hs.add("Alpha");
    hs.add("Epsilon");

 }
}

The LinkedHashSet Class 

Maintains a linked list of entries in the set in the order in which they were inserted.

The TreeSet Class

Creates a collection that uses a tree for storage. Objects are stored in sorted in sorted, ascending order. Access and retrieval times are fast.

import java.util.*;

class TreeSetDemo{

  public static void main(String args[])
  {
    TreeSet<String> ts=new TreeSet<String>();
    ts.add("C");
    ts.add("A");
   
  }
}

Other classes: PriorityQueue, ArrayDequeue, EnumSet

Using iterators

import java.util.*;

class IteratorsDemo
{
  public static void main(String args[])
  {
    ArrayList<String> al=new ArrayList<String>();
    al.add("C");
    al.add("B");
    System.out.println("Modified contents of al:");
    Iterator<String> itr=al.iterator();
    while(it.hasNext())
    {
      String ele=itr.next();
      itr.set(ele+"+");
    }
    while(itr.hasNext())
    {
      String element=itr.next();
      System.out.print(ele+"+");
    }
 //Display the list backwards
 while(itr.hasPrevious())
 {
   String element=itr.previous();
   System.out.print(element+" ");
 }
   

   
  }
}

Can use for each styled loops as well

Maps

A map stores the association between key and value pairs.
Map Classes: AbstractMap, EnumMap, HashMap, TreeMap,WeakHashMap, LinkedHashMap, IdentifyHashMap

HashMap

import java.util.*;
class HashMapDemo
{
  public static void main(String args[])
  {
    //Create a HashMap
    HashMap<String,Double> hs=new HashMap<String,Double>();
    //Put elements to the map
    hm.put("John Doe",new Double(3.14));
    hm.put("Tom Smith",new Double(4.31));

    //Get a set of entries
    Set<Map.Entry<String,Double>> set=hm.entrySet();

    //Display the set
    for(Map.Entry<String,Double> me:set)
    {
      System.out.print(me.getKey()+":");
      System.out.print(me.getValue());
    }

    //DEposit 1000 into John Doe's account
    double balance=hm.get("John Doe");
    hm.put("John Doe",balance+1000);

   
  }

 
}
Collections Algorithms

Demo Program

//Demonstrate algorithms
import java.util.*;

class AlgoDemo
{
  public static void main(String args[])
  {
    LinkedList<Integer> l1=new LinkedList<Integer>();
    l1.add(8);
    l1.add(9);
    Comparator<Integer> r=Collections.reverseOrder();
    Collections.sort(l1,r);
    System.out.println("List sorted in reverse:");
    for(int i:l1)
    System.out.print(i+" ");
    System.out.println();
    //Shuffle list
    Colllections.shuffle(l1);
    //Display the randomized list
    System.out.print("List shuffled: ");
    for(int i:l1)
    System.out.print(i+" ");
    System.out.println();
    System.out.println("Minimum: "+Collections.min(l1));
    System.out.println("Maximum: "+Collections.max(l1));


  }


}

 Arrays

import java.util.*;

class ArraysDemo{

public static void main()
{
  int array[]=new int[10];
  for(int i=0;i<10;i++)
    array[i]=-3*i;
  //Display, sort and display the array
  display(array); //make a display function
  Arrays.sort(array);
  display(array);
//Fill and display the array
Arrays.fill(array,2,6,-1); //start,end,ele
//Binary Search
int index=Arrays.binarySearch(array,-9);

}


}












Tuesday, 26 September 2017

Java Collections Framework (Part I) : Collection Interfaces

What is the Java Collection Framework?

The Java Collections framework consists of classes and interfaces that implement some of the most commonly used data structures such as Linked Lists, trees etc and several algorithms.

Features
  • High performance and efficiency
  • They can be easily extended as per requirement
  • All collections are generic
  • All collection classes in the Collections Framework implement the iterable interface allowing us to use for-each style of for loop with them.  
 The Collection Interfaces
  • Collection: Enables you to work with groups of objects
  • Queue: Extends Collection to implement First In First Out data structure
  • Dequeue: Extends Queue to handle a double-ended queue
  • List: Extends Collection to handle sequences
  • Set: Extends Collection for implementing sets 
  • SortedSet: Extends Set for handling sorted sets
The Collection Interface

This defines the core functionality for all the interfaces and classes in the Collections Framework.

Definition: interface Collection<E> where E is the type of object it will hold

Important functions
  1. boolean add(E obj) : Adds obj to invoking collection
  2. boolean addAll(Collection<? extends E> c): Adds all elements of c to the invoking collection
  3. void clear(): Removes all elements from the invoking collection
  4. boolean contains(Object obj): returns true if obj is an element of invoking collection
  5. boolean containsAll(Collection<?> c): returns true if invoking collection contains all the elements of c
  6. boolean equals(Object obj): Returns true if the invoking collection and obj are equal
  7. boolean isEmpty(): returns true if the invoking collection is empty
  8. boolean remove(Object obj): Removes one instance of obj from invoking collection
  9. boolean removeAll(Collection<?> c): Removes all elements of c from the collection
  10. boolean retainAll(Collection<?> c): Keeps only the elements in c
  11. Object[] toArray(): Returns an array that contains all elements in the invoking collection 
The List Interface 
Stores a sequence of elements
  • void add(int index, E obj)
  • boolean addAll(int index,Collection<? extends E> c)
  • E get(int index): returns object stored at that index
  • int indexOf(Object obj)
  • int lastIndexOf(Object obj): Returns the index of the last instance of obj in the invoking list
  • E remove(int index): removes the element at index 
  • E set(int index, E obj): Assigns obj to the element at the index
  • void sort()
  • List<E> subList(int start, int end): Returns a list that includes elements from start to end -1.
The Set Interface 
No duplicates allowed

The SortedSet Interface
  • E first() -> returns the first element in the invoking collection
  • E last()-> returns the last element in the invoking collection
  • SortedSet<E> subSet(E start,E end)-> Returns a Sorted Set that includes elements from start to end-1
  • SortedSet<E> subSet(E start, E end) 

Queue
  • E element()->returns the element at the head of the queue
  • boolean offer(E obj)-> Attempts to add obj to the queue 
  • E peek()-> returns the element at the head of the queue
  • E poll()-> return element at the head and also remove. Gives null if empty
  • E remove()-> return element at the head and also remove. Exception if empty 
Dequeue Interface 
  • void addFirst(E obj): adds obj to head of dequeue
  • void addLast(E obj): adds obj to end of dequeue
  • E getFirst(): first element in the queue
  • E getLast(): last element of the queue
  • boolean offerFirst(E obj)
  • boolean offerLast(E obj)
  • E pollFirst()
  • E pollLast()
  • E pop()-> returns element at the first
  • void push(E obj)
  • E removeFirst()
  • E removeLast()
  • boolean removeFirstOccurrence(Object obj)
  • boolean removeLastOccurrence(Object obj)