Skip to content

Instantly share code, notes, and snippets.

Avatar

Gene Wood gene1wood

View GitHub Profile
@gene1wood
gene1wood / all_aws_lambda_modules_python.md
Last active Feb 25, 2021
AWS Lambda function to list all available Python modules for Python 2.7 3.6 and 3.7
View all_aws_lambda_modules_python.md

This gist contains lists of modules available in

in AWS Lambda.

It also contains the code to run in Lambda to generate these lists. In addition there is a less_versbose module in the code that you can call to get a list of the top level modules installed and the version of those modules (if they contain a version

@gene1wood
gene1wood / batch-delete-gmail-emails.js
Last active Feb 24, 2021
A Google Apps Script script to bulk delete large amounts of email in Gmail while avoiding the error #793 which Gmail encounters normally
View batch-delete-gmail-emails.js
/*
This script, when used with Google Apps Scripts will delete 500 emails and
can be triggered to run every minute without user interaction enabling you
to bulk delete email in Gmail without getting the #793 error from Gmail.
Configure the search query in the code below to match the type of emails
you want to delete
Browser to https://script.google.com/.
Start a script and paste in the code below.
After you past it in, save it and click the little clock looking button.
@gene1wood
gene1wood / bugzillarc-for-use-at-Mozilla
Created Feb 24, 2021
The ~/.config/python-bugzilla/bugzillarc file to use for bugzilla.mozilla.org
View bugzillarc-for-use-at-Mozilla
[DEFAULT]
url = https://bugzilla.mozilla.org/xmlrpc.cgi
[bugzilla.mozilla.org]
api_key = xxxxxxxxxxxxxxx
@gene1wood
gene1wood / aws-lambda-relative-import-no-known-parent-package.md
Last active Feb 24, 2021
Python relative imports in AWS Lambda fail with `attempted relative import with no known parent package`
View aws-lambda-relative-import-no-known-parent-package.md

Python relative imports in AWS Lambda fail with attempted relative import with no known parent package

The Problem

In AWS Lambda if I attempt an explicit relative import like this

.
├── lambda_file.py
└── example.py
@gene1wood
gene1wood / postfix-debconf-get-selections.txt
Last active Feb 18, 2021
postfix debconf-get-selections using myhost.example.com as an example domain name
View postfix-debconf-get-selections.txt
# Internet protocols to use:
# Choices: all, ipv6, ipv4
postfix postfix/protocols select all
# System mail name:
postfix postfix/mailname string myhost.example.com
# Add a 'mydomain' entry in main.cf for upgrade?
postfix postfix/mydomain_warning boolean
# Correct tlsmgr entry in master.cf for upgrade?
postfix postfix/tlsmgr_upgrade_warning boolean
# Root and postmaster mail recipient:
@gene1wood
gene1wood / bitwarden-amazon-aws-credential-setup.md
Last active Feb 8, 2021
How to get BitWarden to differentiate between amazon.com consumer retail logins, AWS root logins and AWS IAM user logins
View bitwarden-amazon-aws-credential-setup.md

Here's how to get BitWarden to treat these three different types of Amazon logins as separate

  • amazon.com consumer retail business login
  • AWS root user login (AWS logins that use an email address)
  • AWS IAM user login (AWS logins that use a username)

amazon.com consumer retail

  • Set URI 1 to Exact with a value of

    https://www.amazon.com/ap/signin?_encoding=UTF8&ignoreAuthState=1&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_custrec_signin&switch_account=

View set-whitebalance
#!/bin/bash -x
if [ -n "$2" ]; then
percent="$2"
else
percent=0
fi
camera="$(v4l2-ctl --list-devices | grep -A1 "$1" | tail -1 | awk '{print $1}')"
$(v4l2-ctl -d "$camera" -l | awk '$1 == "white_balance_temperature" {print "export "$5" "$6}')
(( range = max - min ))
@gene1wood
gene1wood / example_aws_lambda_cloudformation_context.md
Last active Feb 2, 2021
Details on the AWS Lambda Python LambdaContext context object when instantiated from a CloudFormation stack
View example_aws_lambda_cloudformation_context.md

LambdaContext

Here is the raw output from examining the Python LambdaContext context object in a AWS Lambda function when called from a CloudFormation stack. More information on the context object can be found here : http://docs.aws.amazon.com/lambda/latest/dg/python-context-object.html

LambdaContext object : print(context)

<__main__.LambdaContext object at 0x7fd706780710>

LambdaContext vars : vars(context)

@gene1wood
gene1wood / all_aws_managed_policies.json
Last active Feb 1, 2021
A list of all AWS managed policies and they're policy documents as well as a short script to generate the list
View all_aws_managed_policies.json
This file has been truncated, but you can view the full file.
{
"APIGatewayServiceRolePolicy": {
"Arn": "arn:aws:iam::aws:policy/aws-service-role/APIGatewayServiceRolePolicy",
"AttachmentCount": 0,
"CreateDate": "2019-10-22T18:22:01+00:00",
"DefaultVersionId": "v6",
"Document": {
"Statement": [
{
@gene1wood
gene1wood / 01_get_account_id_for_user_ec2instance_role_or_lambda.py
Last active Jan 22, 2021
Method to determine your AWS account ID using boto3 for either a user or an ec2 instance or lambda function
View 01_get_account_id_for_user_ec2instance_role_or_lambda.py
import boto3
print(boto3.client('sts').get_caller_identity()['Account'])