The Contrarian’s Guide to Leadership

Leadership is not science but art which is highly situational. This book discusses a few contrarian principles to help leader break free of the wisdom of the herd. Theses principles are not dogma but can be useful reference to guide us. Overall the book is a little bit hard to read compared to other books, simple words are not always used and the content in each chapter is not that well structured for easy understanding. Nevertheless it won’t affect the true value of these principles if we put into practice.

Think Gray and Think Free: Think gray is to avoid forming firm opinions about ideas or people unless and until you have to. Think free is to think several steps beyond to contemplate really outrageous ideas and only subsequently apply the constraints of practicality. This will help leader to avoid his established prejudices and be creative and open.

Artful Listening: One important skill for leader is to understand other’s thinking. So listen first, talk later and when you listen, do it artfully. Think gray will help you to listen different inputs openly and also know when to stop listening.

Experts: Experts can be helpful but they’re no substitute for your own critical thinking.

You Are What You Read: Again the importance of reading books and particularly for the supertexts including The Princes, Republic, Hamlet, Antigone and etc. to learn about some timeless truths about human nature. Only read things that matter.

Decisions, Decisions: Again the decision making. The suggestion is to never make a decision yourself that can reasonable be delegated to a lieutenant and never make a decision today that can reasonable be put off to tomorrow. Delegating authority while retaining ultimate responsibility, artful procrastination, ignoring sunk costs and taking luck into account are finest traits during decision making.

Give the Devil His Due: The contrarian leader won’t be naive about the people and circumstances he’s dealing with. Many decisions will be very complex and the leader must discern the pitfalls of various options and choose the best on offer, knowing that there is no perfect solution. Don’t unnecessarily humiliate a defeated opponent.

Know Which Hill You’re Willing to Die On: Moral and ethical concerns insinuate themselves into almost every aspect of leadership. Know what matters most to your beliefs and your choice may at some point require you to retreat from all the surrounding hills.

Work for Those Who Work for You: This is the one I firmly believe in. For majority of time the lead should do everything you can to help your direct reports succeed. Choosing the right people, motivating them, supporting them, helping them grow, inspiring them, evaluating them and firing them are among the most important things a leader does.

Follow the leader: Leaders don’t really run organizations, rather leaders lead individual followers who collectively give motion and substance to the organization.

Being President vs Doing President: Don’t delude yourself into thinking that people are intrinsically better or worse than they really are. Working to bring the best of your followers while minimizing the worst.

With practice and flexibility, principles will help you become a more effective leader. 

Essentialism: The Disciplined Pursuit of Less

In today’s world we’re facing too many choices every day, with the social pressure and the ideas that you can have it all makes lots of us overwhelmed while not results in the maximum results. It’s true for person and also true for companies like Meta today. This book shares the mindset and framework for us to focus on the less but real critical things by explore, eliminate and execute.

First part the book introduces the core logic of an essentialist including the power of choice that we have control to ourselves, the unimportance of practically everything, the reality of trade-off. There are only a small percent of efforts yield the higher rewards than others while meaning most things are non-essential. The time and energy is limited so what you don’t do is just as important as what you do.

With the right mindset, the first step is explore to discern the trivial many from the vital few. Essentialists spend as much time as possible to explore, listen, debate, question and think. To do this you need space to escape and explore life including concentrating and reading. Lots of successful people like Bill Gates keeps time to read and think. Then it’s to look to see what really matters. Keep eye on the big picture, pay attention to the signal in the noise, filter for the essence of information. Keeping a journey, getting out into the filed, keeps eyes peeled for usual details and clarifying the question will all help you to tap into your inner journalist. While explore and look, it’s important to remember to play to embrace the wisdom of your inner child. Play is essential to a happy life and sparks exploration. Also another critical things in life is sleep to protect our ability to promise. Sleep is priority and breeds creativity. Then it’s to select with the extreme criteria. “If the answer isn’t a definite yes then it should be a no” and you should focus on only the top 10% of the opportunities. They should align with your passion, talent and value.

The second step is to eliminate to cut out the trivial many. To clarify the essential intent that’s concrete and inspirational and how it means be done. Living with intent. Dare to say no gracefully. The main thing is to keep main thing the main thing. There are different ways to say no and it’s much more graceful than a vague or noncommittal yes. Say no with options is a common strategy to reject gracefully. We need learn for quick no and slow yes. Another hard part to make the tradeoff is the sunk-cost bias. To make the right choice we need be comfortable to cut loss. Admit past failure is important for future success. Also be caution to make commitment to others too quick, a 5 seconds pause could help. Eventually we need edit to keep reducing distracting details just like movies. Last but not least it’s critical to set boundaries. To know that you have limits you will be limitless, with the rule in advance will eliminate the need for the direct “no”. It’s a source of liberation and with practice it’ll become easier and easier.

The third step is to execute on the few vital things effortless. First is the importance of buffer, as we know the only thing we can expect is the unexpected so we need practice extreme and early preparation. This is true to lots of time when we estimate the effort and the book suggested to add at least 50% to the estimated time. Then it’s find the obstacles and remove them instead of doing more. After that it’s important to keep the progress with small wins. Start small and gets big results and celebrate small acts of progress. Then it’s about the importance of routine to design it that makes achieving what you have identified an essential to the default position. Do the hard thing first and do one thing at one time to makes things look easy. Keep asking what’s important now to focus on the present and enjoy the moment. Eventually it’s BE the essentialist and make it habits of every day in the little moments in life. With more clarify in the purpose, more control to your power, more joy in the journey and eventually live a life that really matters.

This book actually reminds me lots of principles I read from books in the past. Think big, start small and move fast. Focus on what really matters, Realize the importance of routine and saying no. The 20/80 rules and decision framework. It’s good to keep repeating the good principles and practicing to really internalize them.

The appendix discussed about leadership essentials which worth writing down here. The less but better mindset, the ridiculously selective on talent, define the essential intent by ask what the one thing we could do, focus on each team members’ highest role and goal and attribution, listen to get what is essential, check with people on how to remove obstacles to enable small wins and eventually build a unified team that breaks through to the next level of contribution.

Book Summary: Measure What Matters

Good ideas with great execution are how you make magic. The book “Measure What Matters” introduces what is OKRs , why it works and how to integrate it with the process and culture.

OKRs, short for Objectives and Key Results, which is a collaborative goal-settings protocol for companies, teams, and individuals. It has been widely adopted in industry including Intel, Sun, Google and etc. Obviously it’s not a silver bullet, as we know what happened to Sun and what is happening to Intel now, but nevertheless it’s a great framework to map the ideas into concrete objectives and measurable outcomes.

What is OKR?

Objectives are WHAT is to be achieved and they should be significant, concrete, action oriented and ideally inspirational. Key results benchmark and monitor HOW we get to the objective. Most importantly they are measurable and verifiable. Either we meet the key results or not and there shouldn’t be gray areas.

Why does it work?

The book introduces four superpowers from the OKR framework. The first is Focus and Commit to priorities. OKRs forced leaders to make the hard choices to focus on the most important things needed to win. The second is Align and Connect for Teamwork. OKRs make everyone’s goals very transparent and individuals can link their objectives to the company/org’s priorities, identify the dependencies and collaborate with other teams. Top-down alignment brings meaning and motivation to work while owning their OKRs depending on people’s sense of ownership from bottom-up to boot engagement and innovations. The third is Track for Accountability.  OKSs are measurement and driven by data. The periodic check-ins, objective grading and continuous reassessment trigger actions to make sure things are on track and update timely as needed. The last is Stretch for Amazing. OKRs motivates the team to excel by doing more than we’d thought possible, the challenge helps release the creative and ambitious selves.

How to integrate it with process and culture?

CFRs (Conversation, Feedback, Recognition), a framework for continuous performance management can team up together with OKRs to lift people to a whole new level. Conversation is an authentic ,richly textured exchange between manager and contributor, aimed at driving performance. Feedback is bidirectional communication among peers to evaluate progress and guide future improvement. Recognition expresses appreciation to deserving individuals for contributions of all sizes. CRFs and OKRs, champion for transparency, accountability and empowerment to encourage people to drive the excellence outcome measurement OKRs toward the objective. This will help organizations to establish a common framework for decision making and talking about the same thing with meaning, which is an important part of culture.

After reading this one, I found this framework contains principles that’s very similar with another book “The 4 Disciplines of Execution ” including Focus on the Wildly Important, Act on the Lead Measures, Keep a Compelling Scoreboard, and Create a Cadence of Accountability. They’re all about focus, measurable, tracking and accountability leading to great execution.  

Influence: The Psychology of Persuasion

In our daily and professional life, there are lots of times we need persuade others and this book provides six good principles that we can use to influence other’s decision. As what mentioned in the book, nothing will grantee the success but combining of them together will greatly improve the chance of success.

Weapons of Influence: The first chapter introduced that some small tactics has huge impact to influence others. For example with a simple reason attached with your request, even the reason doesn’t quite makes sense, it will greatly increase the chance that others will accept your request like to cut the line. Also the comparison like show most expensive things first then less one will make people feel the price is more acceptable, similar trick might be used by real estate agent to show a pretty old low quality house first then the normal one.

Reciprocity: This principle says that when we receive something, we feel obliged to give something back. This is something embed into our genes as in history we as human need to group together to survive. It’s common to see free sample in supermarket like the Costco, which is proven a very success strategy to get more people to by the product as after people eat the free sample they feel obliged to give something back leading to more purchase. Also in negotiation the reject-then-retreat is a common trick to ask for something big (still reasonable) then fall back to the next option when got reject, as the fallback option gives the other party the impression that you’re making compromise already so they need do something. At the same time to avoid been manipulated by this, it’s useful to think about other’s true intention.

Consistency: This principle shows that we feel compelled to be consistent with what we have said/done in the past. A common tactic is to get someone to say YES to some small thing first to make commitment, then ask something more bigger. Interesting that the author used example from prisoner-of-war camps by China after the Korean war to successfully get corporations from the captives.

Social Proof:” When we’re uncertain how to behavior or react, we look to others for answers. We view a behavior as more correct in a given situation to the degree that we see others performing it. This is why we’re seeing so many “best-selling products” in Ads, and also “national bestseller” on lots of books’ cover including this book. Also it can be used to explain why the suicide contagion and jonestown massacre.

Liking: This tells us that we’re more likely to agree to someone’s request if we know and like him/her. Friendships and personal relationships can have strong influence in our choice. There are a few things including physical attractiveness, similarity, compliments, contact and cooperation will create the liking effect that more easily to get other’s buy-in. This is actually also very helpful during recruiting to convince others to join team, by sharing the common things for similarity, find PoC with similar background with candidate and etc. 

Authority: We tend to obey figures of authority (people with titles or expertise), this is what most of people taught since kids. That’s why in so many Ads we are seeing something pretend to be doctor/teacher will have bigger influence to people’s purchase decision. Also celebrity endorsements in advertising is useful overall.

Scarcity: We perceive something to be more valuable when it’s less available. Hunger marketing is a typical example here, usually offering products with barging pricing while stock is limited with limited time offer, deadline and etc. The trigger is that the fear of loss is always greater than the desire for gain, we weigh more on worry that we lost the scared items.

All these actually remind another book thinking fast and slow. It’s in our genes that we need make fast decisions with mental shortcuts, which likely to very critical as our ancestor had to make quick decisions in dangerous situations to survive. These short cuts works well in most cases but become possible vulnerabilities in our decision making which comes out the six principles of influences here.

Can’t ping some IP addresses in the same subnet – Updated

This is followup from last post about connectivity issue between two computers in same subnet, somehow the arp -s workaround stopped working. I have tried different ways to figure out the root cause, including using tool like tcpdump to sniffer ARP/ICMP request/response, but no luck.

I doubt it’s caused by the wifi router, which model is Zyxel nbg-418n. Eventually I found the workaround to add static DHCP table for one of the machine, and everything works magically.

Static DHCP

Build a real website from scratch Part 1: Setup Dev Environment

Recently I started to learn PHP, and one of the best ways to learn is to practice. So I planned to build a real website using PHP, and write down the steps.

First we need setup the development environment.

CentOS 7:

Download the ISO image and copy it to USB stick.

$ wget http://mirror.vcu.edu/pub/gnu_linux/centos/7/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso
$ diskutil list
$ diskutil unmountDisk /dev/disk<#id>
$ dd if=CentOS-7-x86_64-Minimal-1511.iso of=/dev/rdisk<#id> bs=1m

After installation, let’s make sure the time is correctly set, otherwise we may see strange issues later.

# sudo yum install -y ntp
# sudo systemctl enable ntpd
# sudo systemctl start ntpd
# date

LAMP

Next we need to setup the Apache web server,  MySQL database and PHP module. There are lots of good tutorials on this topic, for example howtoforge. Bascially we need following steps to install Apache web server.

# sudo yum install httpd
# sudo systemctl start httpd.service
# sudo systemctl enable httpd.service

// if you have firewall setup.
# sudo firewall-cmd --zone=public --add-service=http
# sudo firewall-cmd --zone=public --list-services

Followed by MySQL server and PHP module.

# sudo yum -y install mariadb-server mariadb
# sudo systemctl start mariadb.service
# sudo systemctl enable mariadb.service
# sudo mysql_secure_installation
# sudo yum -y install php
# sudo systemctl restart httpd.service

Add php file and visit it from http://<ip>/info.php to verify installation succeeded.

# sudo echo -e "<?php\n phpinfo(); \n?>" > /var/www/html/info.php

Git

Now let’s install the version control tool git.

# sudo yum -y install git
# git config --global user.name "You Name"
# git config --global core.editor "emacs"

There are different choices for where to host the repository, for example Github or Visual Studio Online,  are both free if you only have one or two repository. For Visual Studio Online, sign in using your Microsoft ID, create your project, get the repository URL. Let’s clone that project to existing folder /var/www.

# sudo chmod -R 777 /var/www
# ln -s /var/www ~/www
# git clone https://{name}.visualstudio.com/_git/idphotoweb temp
# mv temp/.git ~/www/.git
# rm -rf temp

Now let’s check in the info.php file.

# cd ~/www
# git add html/info.php
# git commit -m "first checkin"
# git push origin master

Go back to visual studio online and verify info.php is there, and now we finish the basic development environment setup.

Can’t ping some IP addresses in the same subnet

Recently I have tried to setup Linux machine as dev box, and remote from Mac via SSH. But one strange issue is that I was not able to connect the dev box at all, no matter CentOS 7, CentOS 6.8 and Ubuntu 16.04.

Let me clarify. There are three machines A, B, C connected to wifi. All of them can access external network without any issue. A is Mac, B is the dev box, and C is another test machine. The ping between B and C, A and C works perfectly. But A cannot ping B and B cannot ping A at all. It seems they’re isolated.

$ ping 192.168.1.59
PING 192.168.1.59 (192.168.1.59): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3

To diagnostic, first I run “tcpdump icmp” on machine B, and ping from A results nothing, which means the ping request cannot reach to destination. Then check the arp table:

$ arp -a
nbg-418n (192.168.1.1) at cc:5d:4e:48:3d:9e on en0 ifscope [ethernet]
fewang-dev.hsd1.wa.comcast.net (192.168.1.59) at (incomplete) on en0 ifscope [ethernet]

That’s weird as it shows as incomplete, which means we cannot translate the IP address to related physical address.

I don’t know why that could happen, but fixing this can be adding static route with IP address and physical address (MAC address).

$ sudo arp -a -d
$ sudo arp -s 192.168.1.59 00:21:6a:a6:b7:fa

$ ping 192.168.1.59
PING 192.168.1.59 (192.168.1.59): 56 data bytes
64 bytes from 192.168.1.59: icmp_seq=0 ttl=64 time=19.469 ms
64 bytes from 192.168.1.59: icmp_seq=1 ttl=64 time=11.742 ms
64 bytes from 192.168.1.59: icmp_seq=2 ttl=64 time=15.606 ms

Install and configure CentOS 7 on a Raspberry Pi 3

I just bought the Raspberry Pi 3 from Amazon.com CanaKit Raspberry Pi 3 Complete Starter Kit – 32 GB Edition. It seems the Amazon One Day delivery never worked for me, last time my order with one day delivery got cancelled, and this time better it took two days :).

I don’t want to use the default Raspbian OS and instead CentOS 7 is preferred, which is the version I’m using for daily work. The installation is pretty straight forward with help from Google. Basically you need find the correct disk id, download the image, unzip it and copy it the USB MicroSD with your Mac. There is one MicroSD reader included in above Kit.

$ diskutil list
/dev/disk0 (internal, physical):
   ....
/dev/disk1 (internal, virtual):
   ....

/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.4 GB    disk2
   1:             Windows_FAT_16 RECOVERY                1.2 GB     disk2s1
   2:                      Linux                         33.6 MB    disk2s5
$ wget http://buildlogs.centos.org/centos/7/isos/armhfp/CentOS-Userland-7-armv7hl-Minimal-1602-RaspberryPi3.img.xz
$ unxz CentOS-Userland-7-armv7hl-Minimal-1602-RaspberryPi3.img.xz
$ diskutil unmountDisk /dev/disk<#diskid>
$ sudo dd bs=1m if=CentOS-Userland-7-armv7hl-Minimal-1602-RaspberryPi3.img of=/dev/disk<#diskid>

The copy of dd will take a few minutes.

Now insert the SD card to the RespberryPi 3 and boot, then use root/centos to login.

After login we will immediately find that wireless doesn’t work, actually wlan0 device is not recognized by OS.

[root@centos-rpi3 ~]# nmcli d
DEVICE  TYPE      STATE         CONNECTION
eth0    ethernet  connected     eth0
lo      loopback  unmanaged     --

In order to setup the wireless connection, we have to connect to wire connection first and make sure we have internet access. If you want, you can ssh root@<ip> to the Raspberry Pi from you Mac, with the ip address by run ifconfig from the Raspberry Pi.

Now we need first make sure the time is correct by setting up the ntp service, otherwise download later will fail with error complaining certificate error.

# yum install -y ntp
# systemctl enable ntpd
# systemctl start ntpd

Verify the date is correct now:

[root@centos-rpi3 ~]# date
Fri Jun 17 04:20:43 UTC 2016

Then we need download updated firmware from github, update it, then reboot.

# yum -y install git
# git clone https://github.com/RPi-Distro/firmware-nonfree.git
# mv /lib/firmware/brcm{,.org}
# cp -R firmware-nonfree/brcm80211/brcm /lib/firmware/brcm
# curl -L --output /usr/bin/rpi-update https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update
# chmod +x /usr/bin/rpi-update
# rpi-update
# reboot

After reboot finished, the wlan0 interface will be available.

[root@centos-rpi3 ~]# nmcli d
DEVICE  TYPE      STATE         CONNECTION
eth0    ethernet  connected     eth0
wlan0   wifi      disconnected  --
lo      loopback  unmanaged     --

Now find the SSID of your wifi connection point, and connect to it.

[root@centos-rpi3 ~]# nmcli d wifi
*  SSID               MODE   CHAN  RATE       SIGNAL  BARS  SECURITY
   kobuk              Infra  5     54 Mbit/s  60      ▂▄▆_  WPA2
   --                 Infra  1     54 Mbit/s  20      ▂___  WPA1 WPA2
   .....

[root@centos-rpi3 ~]# nmcli d wifi connect <your_uuid> password <your_pwd>
[root@centos-rpi3 ~]# nmcli d
DEVICE  TYPE      STATE      CONNECTION 
eth0    ethernet  connected  eth0       
wlan0   wifi      connected  <your_uuid>    
lo      loopback  unmanaged  --

Now confirm the wifi connection state and with the ip address we can remove the wire network connection.

root@centos-rpi3 ~]# nmcli d show wlan0
GENERAL.DEVICE:                         wlan0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         B8:27:EB:6F:DF:97
GENERAL.MTU:                            0
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     ....
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/2
IP4.ADDRESS[1]:                         192.168.1.56/24
IP4.GATEWAY:                            192.168.1.1
IP4.DNS[1]:                             192.168.1.1
IP4.DOMAIN[1]:                          hsd1.wa.comcast.net
IP6.ADDRESS[1]:                         ....
IP6.GATEWAY:

 

Visualizing Word2Vec Embeddings using t-SNE

t-distributed stochastic neighbor embedding(t-SNE) is a machine learning algorithm for dimensionality reduction developed by Laurens van der Maaten and Geoffrey Hinton. It is a nonlinear dimensionality reduction technique that is particularly well suited for embedding high-dimensional data into a space of two or three dimensions, which can then be visualized in a scatter plot. Specifically, it models each high-dimensional object by a two- or three-dimensional point in such a way that similar objects are modeled by nearby points and dissimilar objects are modeled by distant points.

Word2vec is a group of related models that are used to produce word embeddings. These models are shallow, two-layer neural networks that are trained to reconstruct linguistic contexts of words. Word2vec takes as its input a large corpus of text and produces a vector space, typically of several hundred dimensions, with each unique word in the corpus being assigned a corresponding vector in the space, it was created by a team of researchers led by Tomas Mikolov at Google.

This tutorial shows how to use the t-SNE to visualize the words embedding from Word2Vec, it should be similar to apply it to other kinds of embedding tasks. By the end of this tutorial we’ll get plot looking like following digram, from which we can see  similar words are close to each other, similarity can be meaning, location and so on.

Visualization word2vec using t-SNE

 

Prerequisite

Python version of the t-SNE is used, and it requires matplotlib.

Training

First download the word2vec and build the source code.

wget https://storage.googleapis.com/google-code-archive-source/v2/code.google.com/word2vec/source-archive.zip
unzip source-archive.zip
cd word2vec/trunk
make

If there is error complaining about “‘malloc.h’ file not found”, then go the related file and replace malloc.h to stdlib.h.

Then we are going to train use text corpus from Matt Mahoney.

wget http://mattmahoney.net/dc/text8.zip -O text8.gz
gzip -d text8.gz -f
./word2vec -train text8 -output vectors.txt -cbow 1 -size 200 -window 8 -negative 25 -hs 0 -sample 1e-4 -threads 20 -binary 0 -iter 15

Now we have the embeddings file named vectors.txt.

Visualization

Let’s download the tsne.py, and two helper scripts I have written.

wget https://raw.githubusercontent.com/kingwind/tsneplot/master/tsnePlot.py
wget https://raw.githubusercontent.com/kingwind/tsneplot/master/prepareForTsNE.py
wget https://raw.githubusercontent.com/kingwind/tsneplot/master/tsne.py

Usually we don’t want to plot all the embeddings at same time as it’s too noisy. For this Lab Notes suppose we are only interesting in the words from the analogy test used in word2vec.

wget https://raw.githubusercontent.com/dav/word2vec/master/data/questions-words.txt

Next step is to prepare the input for visualization using the prepareForTsNe.py. The output label_w2v.txt contains the word to plot, and the output embed_w2v.txt contains the related vectors.

python prepareForTsNE.py -e vectors.txt -s questions-words.txt -l label_w2v.txt -x embed_w2v.txt

There are maybe some warning about some words not found, which is OK.

Now it’s ready to visualize the results using t-SNE. 200 is the dimension of the vector and p is perplexity usually ranged from 20 to 50.

python tsnePlot.py -l label_w2v.txt -v embed_w2v.txt -d 200 -p 50

Please note that it’s possible that every time we run the t-SNE, we may get a slightly difference plot. That’s expected and explanation can be found on FAQ from t-SNE.