Skip to content

Instantly share code, notes, and snippets.

View ross-humphrey's full-sized avatar
🧨

Ross ross-humphrey

🧨
  • @SysGroupPLIC
  • Reading, United Kingdom
  • 18:27 (UTC +01:00)
  • LinkedIn in/rosshumphreyuk
View GitHub Profile
@ross-humphrey
ross-humphrey / retrieve_public_url.py
Last active August 19, 2019 09:14
🐍 Python - Retrieve Public URL From AWS S3 Object 💻
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)
@ross-humphrey
ross-humphrey / upload_base_64_to_s3.py
Last active September 7, 2023 15:53
🐍 Python - Upload a base 64 image (as string) to AWS S3
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
@ross-humphrey
ross-humphrey / git-links.txt
Last active May 4, 2020 08:19
🔗 Links to helpful GIT command resources
@ross-humphrey
ross-humphrey / hashing_sha_3.py
Last active September 2, 2019 15:45
🥢 Hasing using SHA-3 in Python
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()
@ross-humphrey
ross-humphrey / change_git_commit_times.sh
Created September 3, 2019 08:09
🐱 Changing historic commit times on GIT
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'
@ross-humphrey
ross-humphrey / aws_change_lambda_layer_account_permissions.sh
Created September 10, 2019 13:23
🔐 Add permissions for an AWS account outside of account where an AWS Lambda layer is hosted
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
@ross-humphrey
ross-humphrey / static-ip-lambda.txt
Created September 10, 2019 16:34
🔗Link to set up Lambda Function with static IP
https://medium.com/@matthewleak/aws-lambda-functions-with-a-static-ip-89a3ada0b471
@ross-humphrey
ross-humphrey / cognitopool.sh
Created November 5, 2019 18:14
🐱‍👤 Create a cognito pool for server to server authentication using Windows commands
# 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*****
@ross-humphrey
ross-humphrey / what_am_i_learning.md
Last active November 24, 2021 23:43
📚 What I am Learning / Reading 📚

Book

  • The Pragmatic Programmer

Programming Language:

  • Javascript

General:

  • Docker, Kubernetes and hosting the whole lot in AWS
@ross-humphrey
ross-humphrey / connecting-to-local-dynamo-db.py
Created November 27, 2019 09:25
🏭 How to connect to a local dynamo db
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()))