Tags » Scripts » Page 2

Sorting Tumblrs you are following by their last activity

It seems, migration to GitLab stimulated me to code more in unusual for me languages and environments. First, it pushed me to do something in PowerShell: … 171 more words

My Projects

Change the background highlight of PDF form fields in a document

During the CreativePro conference in New Orleans, a question was raised during Chad Chelius’ session about Designing forms in InDesign and Acrobat: how to change the background highlight colour of the fill-in forms within Adobe Acrobat. 346 more words


Python Lambda script for Cleaning Up unused Amazon EC2 instances

lThis script performs following:

import boto3
import collections
import datetime
import time
import sys 

ec = boto3.client('ec2', 'eu-west-1')
ec2 = boto3.resource('ec2', 'eu-west-1')
from datetime import datetime
from dateutil.relativedelta import relativedelta

#create date variables 

date_after_month = datetime.now()+ relativedelta(days=7)

def lambda_handler(event, context):
  #Get instances with Owner Taggs and values Unknown/known
    instance_ids = []
    reservations = ec.describe_instances().get('Reservations', []) 

    for reservation in reservations:
     for instance in reservation['Instances']:
        tags = {}
        for tag in instance['Tags']:
            tags] = tag['Value']
        if not 'Owner' in tags or tags['Owner']=='unknown' or tags['Owner']=='Unknown':

                #Check if "TerminateOn" tag exists:

              if 'TerminateOn' in tags:
                  #compare TerminteOn value with current date
                    if tags["TerminateOn"]==today:

                    #Check if termination protection is enabled
                     terminate_protection=ec.describe_instance_attribute(InstanceId =instance['InstanceId'] ,Attribute = 'disableApiTermination')
                     #if enabled disable it
                     if protection_value == True:
                        ec.modify_instance_attribute(InstanceId=instance['InstanceId'],Attribute="disableApiTermination",Value= "False" )
                    #terminate instance
                     print "terminated" + str(instance_ids)
                     #send email that instance is terminated

                    #Send an email to engineering that this instance will be removed X amount of days (calculate the date based on today's date and the termination date."

                      TerminateOn = datetime.strptime(future, "%d/%m/%Y")
                      days= (TerminateOn-now).days
                      print str(instance_ids) +  " will be removed in "+ str(days) + " days"

                 if not 'TerminateOn' in tags:#, create it

                  print "was shut down "+format(','.join(instance_ids))

Amazon Web Services (AWS)

Having mind blocks during exams ? Here's the perfect antidote !

While some may opine that reading other material would only be a waste of time instead of the books prescribed in your courses of study during an examination ,I do not agree with the same. 401 more words

Death by 10,000 Happy Moments - A Vlog

Oh my God, I like soda. And I drink a lot of it.

People–like me–who consume soda and sugar-heavy products on a regular basis are favoring small hits of joy over avoiding massive pains in the future. 491 more words