Friday, January 29, 2016

Postgres - Seeing what connections exist and where they are to and from

Found this Postgres command to show all the connections, their sources, what dbs they are connected to.

SELECT * FROM pg_stat_activity


Wednesday, January 20, 2016

Windows command line aws dynamodb update-item example

Here is an example of using update-item on an AWS dynamoDB

aws --region us-east-1 dynamodb update-item ^
--table-name my-dynamo-table-name --key ^
"{""Id"":{""S"":""IdToMatch""}}" ^
--update-expression "SET #H = :h" ^
--expression-attribute-names "{""#H"":""ColumnName""}" ^
--expression-attribute-values "{"":h"":{""S"":""TestString""}}"

This was inspirational:
http://docs.aws.amazon.com/cli/latest/reference//dynamodb/update-item.html

Windows command line aws dynamodb get-item example

It was a pain in the butt figuring out how to do dynamodb get-item using the Windows command line version of aws.

Here is what ended up working for me:

aws --region us-east-1 dynamodb get-item --table-name my-dynamo-table-name --key "{""Id"":{""S"":""IdToMatch""}}"

In my case the table just had a Hash key only and the name of the key is "Id" and the value of Id for the row I wanted was "IdToMatch"

See this for what _MAY_ explain how to use keys of types that are not "S":
http://docs.aws.amazon.com/cli/latest/reference/dynamodb/get-item.html




Tuesday, January 19, 2016

bash ssh magic with heredoc

I don't yet understand this:


ssh user@server "$( cat <<'EOT'
echo "These commands will be run on: $( uname -a )"
EOT
)"

But it probably is a good way to send args to a program as a block.
Seems like the chars between the 'EOT' are piped as input into the program that is before the <<

See this as one of the answers to
http://stackoverflow.com/questions/7114990/pseudo-terminal-will-not-be-allocated-because-stdin-is-not-a-terminal


Friday, January 15, 2016

Python argparse is great at handling command lines

Python argparse is great at handling command lines.
Be sure to look at it if you need to handle parameters.

You can create it multiple times in the same program if need be.

Wednesday, January 6, 2016

When will my Domain Password Expire

I needed to know when my Domain Password would expire.
This command reports it.

! Type it exactly like this, you don't need to substitute any values for anything !

In a CMD shell run this:

net user %USERNAME% /DOMAIN

One of the results will be something like this:

Password expires             1/10/2016 9:52:20 AM