Skip to content

Instantly share code, notes, and snippets.

View sundarsrst's full-sized avatar

sundar shrestha sundarsrst

View GitHub Profile
@xxxVxxx
xxxVxxx / gist:9648264fd6f41bbb1f65
Last active November 25, 2022 06:52
boto3 aws find all IAM accesskeys details for the account
import boto3
boto3.setup_default_session(profile_name='IAM')
resource = boto3.resource('iam')
client = boto3.client("iam")
KEY = 'LastUsedDate'
for user in resource.users.all():
@burdandrei
burdandrei / telegraf.conf
Last active August 20, 2021 10:01
Receive consul and nomad telemetry in influx in usable form
# Templates are updated to be compatible with nomad > 0.7.1
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "3s"
precision = ""
@chemar
chemar / ec2volList.py
Created March 3, 2017 18:33
AWS EC2 list volumes and attributes using boto3
import boto3
ec2 = boto3.resource('ec2')
volume_iterator = ec2.volumes.all()
for v in volume_iterator:
for a in v.attachments:
print "{0} {1} {2}".format(v.id, v.state, a['InstanceId'])
@amalgjose
amalgjose / GetEC2Instances.py
Created March 8, 2017 23:58
Simple python code snippet to get the list of all the running ec2 instances across regions. The code will dynamically pick the list of available regions. So this will work perfectly without a code change even if a new region gets added.
import boto3
access_key = "XXXXXXXXXXXXXXXXXX"
secret_key = "XXXXXXXXXXXXXXXXXX"
client = boto3.client('ec2', aws_access_key_id=access_key, aws_secret_access_key=secret_key,
region_name='us-east-1')
ec2_regions = [region['RegionName'] for region in client.describe_regions()['Regions']]
@sudharsans
sudharsans / ec2-running-time.py
Created March 1, 2018 11:50
Python Boto3 script to find the number of minutes an instance has been running.
import boto3
from datetime import datetime, timezone
from functools import reduce
import operator
ec2 = boto3.client('ec2')
cloudtrail = boto3.client('cloudtrail')
def get_events(instanceid):
response = cloudtrail.lookup_events (
@pnhoang
pnhoang / howto-download-youtube-videos.md
Last active July 4, 2024 03:18
How to download ALL videos of ANY YouTube Channel
@thealphadollar
thealphadollar / fb_accept_friends.js
Last active July 24, 2024 17:48
Script To Accept All Facebook Friend Requests
// If the script does not work, you may need to allow same site scripting https://stackoverflow.com/a/50902950
Facebook = {
config: {
actionDelay: 1000,
scrollDelay: 5000,
// set to -1 for no limit
maxRequestsToAccept: -1,
totalRequestsAccepted: 0,
// set string to be present in names to be accepted, leave empty to accept all