Skip to content

Instantly share code, notes, and snippets.

View grizax's full-sized avatar
🎯
Focusing

Nick Foster grizax

🎯
Focusing
View GitHub Profile
@grizax
grizax / list_s3_buckets_and_show_size.sh
Created October 2, 2018 18:33
List all S3 buckets per account and then view each buckets total size.
#!/bin/bash
aws_profile=('profile1' 'profile2' 'profile3');
#loop AWS profiles
for i in "${aws_profile[@]}"; do
echo "${i}"
buckets=($(aws --profile "${i}" --region your_region s3 ls s3:// --recursive | awk '{print $3}'))
#loop S3 buckets
for j in "${buckets[@]}"; do
sudo tcpdump -X -s0 host example.org
##Check IP
import socket
import sys
import re
<p>
My programming language of preference is python for the simple reason that I feel I write better code faster with it then I do with other languages. However also has a lot of nice tricks and idioms to do things well. And partly as a reminder to myself to use them, and partly because I thought this might be of general interest I have put together this collection of some of my favourite idioms. I am also putting this on <a href="https://gist.github.com/codefisher/9d7993ddbf404c505128">gist.github.com</a> so that anyone that wants to contribute there own things can, and I will try and keep this post up to date.
</p>
<h2>enumerate</h2>
<p>
A fairly common thing to do is loop over a list while also keeping track of what index we are up to. Now we could use a <code>count</code> variable, but python gives us a nicer syntax for this with the <code>enumerate()</code> function.
<script src="https://gist.github.com/codefisher/9d7993ddbf404c505128.js?file=enumerate.py"></script>