Skip to content

Instantly share code, notes, and snippets.

View Burekasim's full-sized avatar

Avi Keinan Burekasim

  • DoiT International
  • Israel
  • 05:11 (UTC +03:00)
View GitHub Profile
@Burekasim
Burekasim / associate_elastic_ip.py
Created December 25, 2022 16:16
associate elastic ip for ec2 instances
#!/usr/bin/python36
import boto3
import requests
import os
def ec2_associate_eip(aws_instance, region_name, tag_name, tag_value):
client = boto3.client('ec2', region_name=region_name)
eip_list = client.describe_addresses(Filters=[{'Name': f'tag:{tag_name}', 'Values': [tag_value]}])
free_eips = []
@Burekasim
Burekasim / Ses-to-s3.py
Created November 22, 2022 19:27
Ses to sns to lambda to s3
import boto3
import json
from datetime import datetime
import email
from email import policy
def print_with_timestamp(*args):
print(datetime.utcnow().isoformat(), *args)
@Burekasim
Burekasim / reinvent_export_2022.py
Created October 12, 2022 07:27
Export reinvent 2022 sessions to Google Calendar
from datetime import datetime
import json
import pytz
def return_day(timestamp: str, local_timezone: str):
return datetime.fromtimestamp(int(timestamp/1000)).astimezone(pytz.timezone(local_timezone)).strftime(
'%m/%d/%Y')
@Burekasim
Burekasim / ssm-ssh.py
Created September 14, 2022 08:14
ssm port forwarder wrapper
#!/usr/local/bin/python3
import argparse
import botocore.exceptions
import socket
import random
import shlex
import boto3
import json
import os
@Burekasim
Burekasim / pdf_merger.py
Created August 10, 2022 12:26
Pdf merger (Regina 2000)
import datetime
from PyPDF2 import PdfFileMerger
import os
def get_pdf_files_from_current_folder(current_folder: str):
output_list = []
for item in os.listdir(current_folder):
if item.endswith('.pdf'):
output_list.append(item)
@Burekasim
Burekasim / mfa-token.py
Created June 28, 2022 09:13
MFA aws cli token generation
#!/usr/local/bin/python3
import configparser
import boto3
import pyotp
import keyring
if __name__ == '__main__':
try:
# mfa-secret - the name of secret in MacOS keychain access
mfa_token_secret = keyring.get_password("mfa-secret", "mfa-secret")
@Burekasim
Burekasim / salesforce_ip.py
Last active March 6, 2022 12:01
salesforce_ip.py
import re
from selenium import webdriver
from pprint import pprint
BROWSERSTACK_URL = 'https://XXXX:YYYY@hub-cloud.browserstack.com/wd/hub'
desired_cap = {
'os': 'Windows',
'os_version': '10',
'browser': 'Chrome',
'browser_version': '80',
@Burekasim
Burekasim / gcp_associate_static_ip.py
Created February 24, 2022 15:37
Python script to associate a static ip to gcp instance
import requests
import googleapiclient.discovery
from oauth2client.client import GoogleCredentials
from time import sleep
from random import randint
'''
permissions
compute.addresses.get
compute.addresses.list
@Burekasim
Burekasim / fortigate.txt
Created January 31, 2022 08:10
Fortigate with Google workspaces (Gsuite) LDAP authentication
This is a simple guide that explains how to use forticlient with Gsuite LDAP.
* Google workspaces LDAP is available for customers with one of the following subscriptions: Business Plus; Enterprise; Education Fundamentals, Standard, Teaching and Learning Upgrade, and Plus.
Requirements:
1. Google workspaces subscription.
2. Fortigate.
3. Server for stunnel.
Setup instructions:
1. Enable Google workspaces LDAP, and download the certificate. more details are available in this guide: https://support.google.com/a/answer/9048434?hl=en
@Burekasim
Burekasim / interfaces.yaml
Created November 7, 2021 18:30
interfaces.yaml
network:
ethernets:
ens5:
addresses:
- <ENS5_IP>/32
match:
macaddress: <ENS5_MAC_ADDRESS>
routes:
- table: 2
to: <ENS5_GATEWAY>/32