- The Pragmatic Programmer
- Javascript
- Docker, Kubernetes and hosting the whole lot in AWS
import boto3 | |
def retrieve_public_url(s3_bucket_name, s3_file_name): | |
""" | |
Given a s3 bucket name and key this method will figure out the location of the bucket | |
and the respective url | |
:param s3_bucket_name: S3 bucket name | |
:param s3_file_name: S3 file name | |
:return: formatted object URL giving publicly accessible URL for object (presuming permissions are set | |
accordingly) |
import base64 | |
import boto3 | |
def upload_base_64_to_s3(s3_bucket_name, s3_file_name, base_64_str): | |
""" | |
Allows for the upload of a base64 string to a s3 object, may need fleshing out down the line, returns location | |
of file in S3 | |
:param s3_bucket_name: S3 bucket name to push image to | |
:param s3_file_name: File name | |
:param base_64_str: base 64 string of the image to push to S3 |
Change the author information on historic git commits | |
> https://help.github.com/en/articles/changing-author-info | |
Change the commit date on historic git commits | |
> https://stackoverflow.com/questions/21112557/is-possible-change-the-commit-date-on-git?noredirect=1&lq=1 | |
Change the date of most recent commit (before pushing) | |
GIT_COMMITTER_DATE="Mon 25 Nov 2019 20:19:19 GMT" git commit --amend --no-edit --date "Mon 25 Nov 2019 20:19:19 GMT" | |
Create New branch and checkout |
import hashlib | |
def sha_3_hex_digest(input_string): | |
""" | |
Given an input string a sha3 - 384 bit hex digest result | |
:param input_string: string to hash | |
:return: hexdigest string representation of input_string | |
""" | |
encoded_input = input_string.encode("utf-8") | |
return hashlib.sha3_384(encoded_input).hexdigest() |
git filter-branch --env-filter \ | |
'if [ $GIT_COMMIT = 7e9f69cf5708ae32ac3f8f9211ee63b4efa7802e ] | |
then | |
export GIT_AUTHOR_DATE="Mon Sep 2 16:38:53 2019 -0000" | |
export GIT_COMMITTER_DATE="Mon Sep 2 17:01:01 2019 -0000" | |
fi' |
aws lambda add-layer-version-permission --layer-name <insert_lambda_layer_name> --statement-id xaccount --action lambda:GetLayerVersion --principal <insert_account_id_to_give_permissions_to> --version-number <insert_layer-version> --output text |
https://medium.com/@matthewleak/aws-lambda-functions-with-a-static-ip-89a3ada0b471 |
# Windows script to set up Cognito Pool | |
# Handy guide for Server to Server credentials using Cognito @ https://lobster1234.github.io/2018/05/31/server-to-server-auth-with-amazon-cognito/ | |
# CREATE COGNITO USER POOL | |
SET POOLNAME="PoolName" | |
SET ENV="DEV" | |
aws cognito-idp create-user-pool --pool-name %POOLNAME%%ENV% | |
# MANUAL STEP (FOR NOW - COPY THE ID FROM THE OUTPUT ABOVE) | |
# Take the UserPool->Id, everything below is created from it: eu-west-1_g***** |
import boto3 | |
#boto3 client | |
ddb = boto3.client('dynamodb', endpoint_url='http://localhost:8000') | |
response = ddb.list_tables() | |
print(response) | |
#boto3 service resource | |
ddb = boto3.resource('dynamodb', endpoint_url='http://localhost:8000') | |
print(list(ddb.tables.all())) |