Skip to content

Instantly share code, notes, and snippets.

View koleror's full-sized avatar

Hugo Defrance koleror

  • Epic games
  • Paris
View GitHub Profile
@koleror
koleror / cleanup_lambda_versions.py
Last active June 19, 2020 15:05
Cleanup lambda functions versions
import boto3
client = boto3.client('lambda')
def _clean_function(function_data, dry_run, max_versions):
skipped_items = 0
while True: # list_versions_by_function returns up to 50 versions per call
versions = client.list_versions_by_function(
FunctionName=function_data['FunctionArn']
@koleror
koleror / export-simple-membership-users.sql
Created April 17, 2020 15:55
Export users from Simple WP Membership
SELECT member_id, first_name, last_name, member_since, last_accessed, email FROM dbqsv_swpm_members_tbl
LEFT JOIN dbqsv_swpm_membership_tbl
ON ( membership_level = id )
WHERE membership_level=3;
@koleror
koleror / manage-instance.sh
Created July 2, 2018 19:47
Manage AWS instance from command line
#!/bin/bash
AWS_PROFILE=<ENTER AWS PROFILE NAME HERE>
AWS_REGION=<ENTER INSTANCE REGION>
AWS_INSTANCE_ID=<ENTER INSTANCE ID HERE>
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
@koleror
koleror / migrate_s3.py
Last active March 5, 2018 14:53
Migrate AWS S3 bucket content to another bucket, keeping metadatas
import boto3
old_access_key_id = '***'
old_secret_access_key = '***'
old_bucket_name = '***'
new_access_key_id = '***'
new_secret_access_key = '***'
new_bucket_name = '***'
@koleror
koleror / aws2factor.sh
Last active July 2, 2018 19:50
Regenerate two factor tokens for AWS and add them to your environment
#!/bin/bash
command -v aws
if [[ $? != 0 ]]; then
echo "Please install awscli and try again"
return;
fi
set -e