Skip to content

Instantly share code, notes, and snippets.

Avatar

Bertrand Caron bertrand-caron

View GitHub Profile
@bertrand-caron
bertrand-caron / meetup_date_reformatter.py
Created Jun 6, 2020
Script for reformatting Meetup.com exports into Excel friendly formats (requires first converting from Excel to CSV).
View meetup_date_reformatter.py
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
List user roles and permissions for a AWS account
View IAM.sh
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
List AWS buckets and their sizes
View list_bucket_size.py
# 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:
View fab.py
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 Jun 6, 2018 — 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
View RSA_example.py
# 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
View closure.hs
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