Skip to content

Instantly share code, notes, and snippets.

View bertrand-caron's full-sized avatar

Dr. Bertrand Caron, PhD bertrand-caron

View GitHub Profile
@bertrand-caron
bertrand-caron / meetup_date_reformatter.py
Created June 6, 2020 21:29
Script for reformatting Meetup.com exports into Excel friendly formats (requires first converting from Excel to CSV).
import pandas as pd
import numpy as np
from datetime import datetime
from argparse import ArgumentParser, Namespace
DATETIME_COLUMNS = [
"Joined Group on",
"Last visited group on",
"Last Attended",
]
@bertrand-caron
bertrand-caron / IAM.sh
Created May 14, 2020 01:44
List user roles and permissions for a AWS account
module purge
for credential in aws-dev aws-uat; do
echo "Credentials: ${credential}"
module load ${credential}
aws iam list-users
aws iam list-roles
module unload ${credential}
echo ""
done
@bertrand-caron
bertrand-caron / list_bucket_size.py
Last active May 1, 2020 04:48
List AWS buckets and their sizes
# Requires `awscli` (installed with pip) and a modern python version (>=3.6)
from datetime import datetime, timedelta
from subprocess import check_output
from json import loads, dumps
from typing import Tuple, NamedTuple
from multiprocessing import Pool
def sizeof_fmt(num: float, suffix: str = 'B') -> str:
from requests import get
from json import loads
print(
loads(
get('http://pimpyourwaste.bcaron.me/pieces?min_volume=2.0,1.0,1.0').text,
),
)
@bertrand-caron
bertrand-caron / RSA_example.py
Last active June 6, 2018 03:17 — forked from syedrakib/RSA_example.py
An example of asymmetric encryption in python using a public/private keypair - utilizes RSA from PyCrypto library and Python3.5
# Inspired from http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto)
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/
from Crypto import Random
from Crypto.PublicKey import RSA
import base64
def generate_keys():
# RSA modulus length must be a multiple of 256 and >= 1024
modulus_length = 256 * 4 * 4 # use larger value in production
add :: Int -> Int -> Int
add x y = x + y
fs :: [(Int -> Int)]
fs = map (\n -> add n) [1..3]
main = do
print $ map (\f -> f 0) fs