Skip to content

Instantly share code, notes, and snippets.

View ljmocic's full-sized avatar

Ljubiša Moćić ljmocic

View GitHub Profile
import boto3
iam = boto3.client('iam',
aws_access_key_id='xxxx',
aws_secret_access_key='xxxx')
def user_in_group(user, group_name):
for group in iam.list_groups_for_user(UserName=user)['Groups']:
if group_name == group['GroupName']:
return True
from datetime import datetime
import json
import boto3
import random
print('[INFO] Processing started')
random.seed(datetime.now())
dt = datetime.now()
import os
import requests
import psutil
import time
import json
# Here you can find basic configuration settings set through variables
IP_TO_PING = '192.168.1.1' # IP of your computer on the network for ping
API_ENDPOINT = 'https://www.yoururl.com/' # API endpoint which needs to be notified if everything goes as planned
DATA_FILE = 'data.json' # Since we use the file for saving the counter, here is the name of the file where it will be saved
import boto3
import json
from datetime import datetime, timedelta
REGION = 'us-east-1'
TAG = 'A'
ARN = 'arn:aws:sns:us-east-1:12345678:snsName'
UTILIZATION_PERCENTAGE = 0.5
TIME = 60 * 60 * 2
# Read more about setting it up:
# https://medium.com/@ljmocic/send-an-email-using-python-and-gmail-4ebc980eae9b
import smtplib
from email.mime.text import MIMEText
EMAIL = ''
APP_PASSWORD = ''
RECEIVER = ''
# Read more about setting it up
# https://medium.com/@ljmocic/running-a-script-from-s3-on-ec2-with-7-lines-of-code-59806c07d300
import boto3
REGION = 'us-east-1'
AMI = 'ami-00b94673edfccb7ca'
INSTANCE_TYPE = 'm3.medium'
BUCKET = 'script-bucket'
import os
import json
import boto3
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(os.environ['DYNAMODB_TABLE'])
def detect_event(event):
# Read more about setting it up
# https://medium.com/@ljmocic/deploying-react-application-to-aws-s3-using-github-actions-85addacaeace
on:
push:
tags:
- '*'
jobs:
build:
# Read more about setting it up
# https://medium.com/@ljmocic/make-telegram-bot-for-notifying-about-new-rss-feed-items-4cfbcc37f4fd
from datetime import timedelta, datetime
from dateutil import parser
from pprint import pprint
from time import sleep
import requests
import feedparser
#!/bin/bash
# Run using: chmod a+x mac-setup.sh && ./mac-setup.sh
# Read more about it
# https://medium.com/@ljmocic/quickly-setup-development-environment-on-mac-91bbbd647011
# Request admin permissions
sudo -v
# Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"