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..


Saturday, July 30, 2016

A beautiful morning, a beautiful creature and a simple photo touching tool

On a bright, pleasant  summer morning, I ran into this fellow who seemed to be enjoying the day as much as I was.

My first attempt at touching up a photo with Gimp left a lasting impression.