Page 2 of 25

Using Python Version Management: Pyenv

https://github.com/pyenv/pyenv

Install via homebrew.

brew update
brew install pyenv

Install multiple versions of python. You can also use this within a virtual environment. pyenv install 3.6.0

pyenv install 3.5.0
pyenv install 2.7.10

Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval “$(pyenv init -)” is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.

eval "$(pyenv init -)"

To check versions installed:

pyenv versions

Helpful resources.

 

IAM Policy To Disable Table Deletion in DynamoDB

    "Version": "2012-10-17",
    "Statement": [
	{
            "Action": [
                "dynamodb:DeleteTable"
            ],
            "Effect": "Deny",
            "Resource": "*"
	}
    ]
}

Hash functions and DynamoDB

What is a hash function

A hash function is a function that takes in input value, and from that input value creates an output value deterministic of the input value. For any x input value, you will always receive the same y output value when the hash function is run. In this way, every input has a determined output.

f(x) = y

As an example we will use the MD5 hash function. You can try on the online generator at md5hashgenerator.com. This function, which from any input data creates a 32 character hexadecimal output. Hash functions are generally irreversible (one-way), which means you can’t figure out the input if you only know the output – unless you try every possible input (which is called a brute-force attack).

md5(‘hash me’) = 17b31dce96b9d6c6d0a6ba95f47796fb

If you go to the generator page and input ‘hash me’ it should output the value above.

How a hash function is used in DynamoDB

The primary key or a combination of the primary key and sort key will be used as input value to an internal hash function. AWS does not revel how the algorithm works for their hash function. The output value is like the example above. AWS will determine from the output value how and where to partition and store an item. The algorithm can use the first 4 characters or any number to determine the partition(s). I found simple explanation on a forum here.

DynamoDB documentation on how partitions work

© 2020 Aldomatic

Theme by Anders NorenUp ↑