Wednesday, October 19, 2016

Simple behavioral changes via "Tiny Habits"


I read a book once that convinced me that habits can only be replaced, not created. To me, that was extremely convenient and served as the rationale for not changing things that worked well for me, but not so much for others.

Till I came across Dr B J Fogg and his "tiny habits". Its a very simple approach, basically trying to engender small behavioral changes by weaving in what he calls "tiny habits", and repeating them till they are ingrained.

For these to be successful, a tiny habit :
  • has an anchor .
  • is what it is - tiny. Involves an activity that can be done in less than 30 seconds and you're seeking to make a habit 
With gusto, I signed up for his session on Tiny Habits, looking to change my world, before I changed other's. Have to admit, for a free coaching session that was trying to effect behavioral change, the process was remarkably efficient.

I set out to change 3 of my behaviors that I noticed was - surprisingly - annoying others.

  • inject some positivism into my day by reminding myself, first thing in the morning, of the great day I was going to have.
  • put my shoes away once home from work
  • load my lunch box in the dishwasher once home from work.


What surprised me the most was how the changes threw up the inefficiencies around how I was organized. eg with the goal of putting away my shoes on walking in, I realized that my prevailing approach was rooted in where I'd park my car once home( in the driveway), where the shoe rack was(in the garage) and how I'd enter my home(via the front door rather than the garage!).And once I walk in thru the door, I dislike walking around the house with my shoes on, so it needs to be off and there it would lie till the next day.

Cultivating this tiny habit called for:

  • taking off shoes on walking in
  • picking them up and walking into the garage thru the connecting door(which is slightly jammed)
  • bend down to stow away the shoes on the lowest spots(age, bad back etc) - the upper ones are taken by whoever came in before me.

I think the key is to determine the sequences that help or hinder the development of a habit. And address them one by one.

Having encountered success with this, I set out to try it and help Junior who was having a hard time memorizing words to strengthen his vocabulary. So once the flash cards showed up from Walmart, we loaded a few cards on the ring that came with the set and I sat back while the process of goal-setting to cram the set of cards playing out.


The ring hardly saw any movement in the following days.

Tiny habits to the rescue. What would be a good anchor and goal to develop this tiny habit?

Anchor: ?

After a lot of deliberation, we anchored on "After I hit the bed at the end of my day". Now onto the goal.

First iteration: I will go through my set of flash cards.

Fails the sniff test. Takes more than 30 seconds and is not really tiny.

Second iteration: Reduce the number of cards to , say , 10. Still fails. It takes about 5 seconds to go through a word, especially if its new.

Third iteration: I will pick up the ring the cards are on.

Eureka!  If you've managed to remember to pick up the ring, the rest is a matter of course.


Monday, October 10, 2016

Simplest bread ever...

Since watching Heather Pierce Giannone educate me on what went into bread, I've been reading the ingredients in what I buy more carefully.

This is particularly true of bread and I think now I've found the simplest of breads in the market. Check out Trader Joe's Petit Pain Pauline. They used to have a round loaf about twice this size(I dont  think they call it "Petit" - could be wrong -  but seem to have retired it in favor of this smaller size).



How simple can it get?


Just 3 ingredients:

  • Whole wheat flour
  • Water
  • Salt
(How in the world did they manage without yeast? Defies every cooking book I've read since elementary school!)

And here's the list of ingredients on the bread that it has replaced on the menu:




Sunday, October 9, 2016

My experiments with DynamoDB:



Been playing with this amazing machine called the Amazon Echo and I too am blown away at the way the future has talked back to me.

During the course of my travels, I discovered that while the documentation is extensive, I've come face to face with a paucity of good examples on how to do CRUD operations in DynamoDB.

My experiments involved maps, lists and sets and here are some snippets from what I could get to work by going thru the documentation and the limited content available out there. All examples were tried via Lambda functions executing in AWS, writing and reading from a DynamoDB instance in AWS.

Here is the table structure against which these were performed:



With lists:


Create:


from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError


dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')

def insert_data():
    actors=["A","B","C"]

    response = table.update_item(
   Key={
        "name":"SOME_RANDOM_KEY"
   },
   UpdateExpression="set partners = :v",
   ExpressionAttributeValues={
       ':v': actors
   },
   ReturnValues="UPDATED_NEW"
    )

    print ("Insert successful!",response)



def lambda_handler(event, context):
    # TODO implement
    insert_data()
    return 'Hello from Lambda'


..gives us...


Modify:

from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError


dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')


def modify_data():
    response = table.update_item(
        Key={
             "name":"SOME_RANDOM_KEY"
        },
        UpdateExpression="SET #p = list_append(#p, :v)",  
        ExpressionAttributeNames={
            '#p': 'partners'
        },
        ExpressionAttributeValues={
            ':v': ["99"]
        },
        ReturnValues="UPDATED_NEW"
    )
    print ("Update successful!",response)


def lambda_handler(event, context):
    # TODO implement
    modify_data()
    return 'Hello from Lambda'

..gives us...



Delete:


from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')
def remove_data():
    response = table.update_item(
        Key={
             "name":"SOME_RANDOM_KEY"
        },
        UpdateExpression="REMOVE partners[1]",
        ReturnValues="UPDATED_NEW"
    )
    print ("Del successful!",response)
 
def lambda_handler(event, context):
    # TODO implement
    remove_data()
    return 'Hello from Lambda'


..gives us...




With Sets:


Create:


from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError


dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')

def insert_data():
    actors={"A","B","C"}

    response = table.update_item(
   Key={
        "name":"SOME_RANDOM_KEY"
   },
   UpdateExpression="set partners = :v",
   ExpressionAttributeValues={
       ':v': actors
   },
   ReturnValues="UPDATED_NEW"
    )

    print ("Insert successful!",response)

    
def lambda_handler(event, context):
    # TODO implement
    insert_data()
    return 'Hello from Lambda'

..gives us..


Modify:

from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError


dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')


def modify_data():
    response = table.update_item(
        Key={
             "name":"SOME_RANDOM_KEY"
        },
        UpdateExpression="ADD partners :v",  
        ExpressionAttributeValues={
            ':v': {"99"}
        },
        ReturnValues="UPDATED_NEW"
    )
    print ("Update successful!",response)

def lambda_handler(event, context):
    # TODO implement
    modify_data()
    return 'Hello from Lambda'

..gives us..


Delete:

from __future__ import print_function
import logging,time
import boto3
import botocore
import json
import decimal
import sys
from boto3.dynamodb.conditions import Key, Attr
from botocore.exceptions import ClientError


dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('Test2')

def remove_data():
    response = table.update_item(
    Key={
        "name":"SOME_RANDOM_KEY"
    },
    UpdateExpression="DELETE partners  :v ",  
    ExpressionAttributeValues={
       ':v': {"A"}    
    } ,
    ReturnValues="UPDATED_NEW"
)
    print ("Del successful!",response)
    
def lambda_handler(event, context):
    # TODO implement
    remove_data()
    return 'Hello from Lambda'

...gives us..